1
0
forked from x/ContextOS
This commit is contained in:
shaoying 2019-06-06 18:42:50 +08:00
parent ee2a7e5107
commit 8fbd3ffa15
5 changed files with 59 additions and 45 deletions

View File

@ -4,5 +4,6 @@ import (
"contexts/ctx" "contexts/ctx"
) )
func sysinfo(m *ctx.Message, c *ctx.Context, key string, arg ...string) { func sysinfo(m *ctx.Message, c *ctx.Context, key string, arg ...string) error{
return nil
} }

View File

@ -5,7 +5,7 @@ import (
"contexts/ctx" "contexts/ctx"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/PuerkitoBio/goquery" // "github.com/PuerkitoBio/goquery"
"github.com/go-cas/cas" "github.com/go-cas/cas"
"html/template" "html/template"
"io" "io"
@ -656,6 +656,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
m.Put("option", "data", result).Cmdy("mdb.temp", "url", uri+uri_arg, "data", "data", m.Meta["temp"]) m.Put("option", "data", result).Cmdy("mdb.temp", "url", uri+uri_arg, "data", "data", m.Meta["temp"])
case parse == "html": case parse == "html":
/*
page, e := goquery.NewDocumentFromReader(res.Body) page, e := goquery.NewDocumentFromReader(res.Body)
m.Assert(e) m.Assert(e)
@ -702,6 +703,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
}) })
m.Table() m.Table()
*/
default: default:
if m.Options("save") { if m.Options("save") {
f, e := os.Create(m.Option("save")) f, e := os.Create(m.Option("save"))

View File

@ -513,6 +513,7 @@ var page = Page({
} }
return conf return conf
}) })
page.onlayout(null, page.conf.layout) page.onlayout(null, page.conf.layout)
page.footer.State("action", "") page.footer.State("action", "")
page.footer.Order(["action", "text"]) page.footer.Order(["action", "text"])

View File

@ -1,4 +1,4 @@
html, body, fieldset { html, body {
background-color:#d8d8d8; background-color:#d8d8d8;
padding:0px; padding:0px;
height:100%; height:100%;
@ -6,8 +6,11 @@ html, body, fieldset {
margin:0px; margin:0px;
} }
fieldset { fieldset {
background-color:#d8d8d8;
padding:0px;
min-width:160px; min-width:160px;
overflow:auto; overflow:auto;
margin:0px;
} }
legend { legend {
margin-left:10px; margin-left:10px;

View File

@ -1,10 +1,46 @@
var page = Page({ var page = Page({
initTree: function(field, option, output) { conf: {
border: 4,
scroll_x: 50,
scroll_y: 50,
},
onlayout: function(event, sizes) {
return
var height = document.body.clientHeight-page.conf.border
var width = document.body.clientWidth-page.conf.border
page.conf.height = height
page.conf.width = width
sizes = sizes || {}
sizes.header == undefined && (sizes.header = page.header.clientHeight)
sizes.footer == undefined && (sizes.footer = page.footer.clientHeight)
page.header.Size(width, sizes.header)
page.footer.Size(width, sizes.footer)
sizes.tree == undefined && (sizes.tree = page.tree.clientHeight)
page.tree.Size(width, sizes.tree)
sizes.text = height - sizes.tree - sizes.header - sizes.footer
page.text.Size(width, sizes.text)
},
initList: function(page, pane, form, output) {
ctx.Runs(page, form, function(msg) {
output.innerHTML = ""
kit.AppendChild(output, [{"tree": ctx.Table(msg, function(value, index) {
return {"leaf": [value.file, function(event, target) {
ctx.Search("wiki_favor", value.file)
}]}
})}])
})
return
},
initTree: function(page, pane, form, output) {
// if (!ctx.isMobile) { // if (!ctx.isMobile) {
// field.style.float = "left" // pane.style.float = "left"
// } // }
ctx.Runs(page, option, function(msg) { ctx.Runs(page, form, function(msg) {
output.innerHTML = "" output.innerHTML = ""
var back = [{"button": ["知识", function(event) { var back = [{"button": ["知识", function(event) {
ctx.Search({"wiki_level": "", "wiki_class": "", "wiki_favor": ""}) ctx.Search({"wiki_level": "", "wiki_class": "", "wiki_favor": ""})
@ -42,19 +78,8 @@ var page = Page({
}) })
return return
}, },
initList: function(field, option, output) { initText: function(page, pane, form, output) {
ctx.Runs(page, option, function(msg) { ctx.Runs(page, form, function(msg) {
output.innerHTML = ""
kit.AppendChild(output, [{"tree": ctx.Table(msg, function(value, index) {
return {"leaf": [value.file, function(event, target) {
ctx.Search("wiki_favor", value.file)
}]}
})}])
})
return
},
initText: function(field, option, output) {
ctx.Runs(page, option, function(msg) {
if (!msg.result) { if (!msg.result) {
return return
} }
@ -75,7 +100,7 @@ var page = Page({
}) })
ui.text.querySelectorAll("a").forEach(function(value, index, array) { ui.text.querySelectorAll("a").forEach(function(value, index, array) {
kit.OrderLink(value, field) kit.OrderLink(value, pane)
}) })
@ -85,7 +110,7 @@ var page = Page({
var id = "" var id = ""
var level = 0 var level = 0
var text = value.innerText var text = value.innerText
var ratio = parseInt(value.offsetTop/field.scrollHeight*100) var ratio = parseInt(value.offsetTop/pane.scrollHeight*100)
if (value.tagName == "H2") { if (value.tagName == "H2") {
j=k=0 j=k=0
@ -125,12 +150,10 @@ var page = Page({
var width = ui.menu.offsetWidth var width = ui.menu.offsetWidth
var height = ui.menu.offsetHeight>400?ui.menu.offsetHeight:600 var height = ui.menu.offsetHeight>400?ui.menu.offsetHeight:600
field.style.marginLeft = width+10+"px" pane.style.marginLeft = width+10+"px"
ui.menu.style.marginLeft = -width-20+"px" ui.menu.style.marginLeft = -width-20+"px"
ui.text.style.height = height+"px" ui.text.style.height = height+"px"
ui.text.style.width = field.offsetWidth-30-width+"px" ui.text.style.width = pane.offsetWidth-30+"px"
// ui.text.style.width = field.offsetWidth-ui.menu.offsetWidth+"px"
} }
if (location.hash) { if (location.hash) {
location.href = location.hash location.href = location.hash
@ -138,32 +161,16 @@ var page = Page({
}) })
return return
}, },
init: function(page) {
page.initField(page, function(init, pane, form) {
var output = pane.querySelector("div.output")
onaction: function(event, target, action) {
var page = this
switch (action) {
case "scroll":
break
}
},
init: function(exp) {
var page = this
document.querySelectorAll("body>fieldset").forEach(function(field) {
var option = field.querySelector("form.option")
var output = field.querySelector("div.output")
var init = page[field.dataset.init]
if (typeof init == "function") { if (typeof init == "function") {
var conf = init(field, option, output) var conf = init(page, pane, form, output)
if (conf) { if (conf) {
kit.AppendChild(output, conf) kit.AppendChild(output, conf)
} }
} }
}) })
}, },
conf: {
scroll_x: 50,
scroll_y: 50,
},
}) })