From 8fbd3ffa1586a17b7e65f45dab2777ab883b9207 Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 6 Jun 2019 18:42:50 +0800 Subject: [PATCH] zyb --- src/contexts/cli/cli_windows.go | 3 +- src/contexts/web/web.go | 4 +- usr/librarys/chat.js | 1 + usr/librarys/example.css | 5 +- usr/librarys/wiki.js | 91 ++++++++++++++++++--------------- 5 files changed, 59 insertions(+), 45 deletions(-) diff --git a/src/contexts/cli/cli_windows.go b/src/contexts/cli/cli_windows.go index dfa0c1c8..5a9aff1f 100644 --- a/src/contexts/cli/cli_windows.go +++ b/src/contexts/cli/cli_windows.go @@ -4,5 +4,6 @@ import ( "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 } diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index bb08486b..9936b73b 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -5,7 +5,7 @@ import ( "contexts/ctx" "encoding/json" "fmt" - "github.com/PuerkitoBio/goquery" + // "github.com/PuerkitoBio/goquery" "github.com/go-cas/cas" "html/template" "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"]) case parse == "html": + /* page, e := goquery.NewDocumentFromReader(res.Body) m.Assert(e) @@ -702,6 +703,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", }) m.Table() + */ default: if m.Options("save") { f, e := os.Create(m.Option("save")) diff --git a/usr/librarys/chat.js b/usr/librarys/chat.js index 741d9e3f..21ae2f68 100644 --- a/usr/librarys/chat.js +++ b/usr/librarys/chat.js @@ -513,6 +513,7 @@ var page = Page({ } return conf }) + page.onlayout(null, page.conf.layout) page.footer.State("action", "") page.footer.Order(["action", "text"]) diff --git a/usr/librarys/example.css b/usr/librarys/example.css index 92e7eae0..18f11f7c 100644 --- a/usr/librarys/example.css +++ b/usr/librarys/example.css @@ -1,4 +1,4 @@ -html, body, fieldset { +html, body { background-color:#d8d8d8; padding:0px; height:100%; @@ -6,8 +6,11 @@ html, body, fieldset { margin:0px; } fieldset { + background-color:#d8d8d8; + padding:0px; min-width:160px; overflow:auto; + margin:0px; } legend { margin-left:10px; diff --git a/usr/librarys/wiki.js b/usr/librarys/wiki.js index a3112251..947aa2ea 100644 --- a/usr/librarys/wiki.js +++ b/usr/librarys/wiki.js @@ -1,10 +1,46 @@ 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) { - // field.style.float = "left" + // pane.style.float = "left" // } - ctx.Runs(page, option, function(msg) { + ctx.Runs(page, form, function(msg) { output.innerHTML = "" var back = [{"button": ["知识", function(event) { ctx.Search({"wiki_level": "", "wiki_class": "", "wiki_favor": ""}) @@ -42,19 +78,8 @@ var page = Page({ }) return }, - initList: function(field, option, output) { - ctx.Runs(page, option, 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) { + initText: function(page, pane, form, output) { + ctx.Runs(page, form, function(msg) { if (!msg.result) { return } @@ -75,7 +100,7 @@ var page = Page({ }) 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 level = 0 var text = value.innerText - var ratio = parseInt(value.offsetTop/field.scrollHeight*100) + var ratio = parseInt(value.offsetTop/pane.scrollHeight*100) if (value.tagName == "H2") { j=k=0 @@ -125,12 +150,10 @@ var page = Page({ var width = ui.menu.offsetWidth 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.text.style.height = height+"px" - ui.text.style.width = field.offsetWidth-30-width+"px" - - // ui.text.style.width = field.offsetWidth-ui.menu.offsetWidth+"px" + ui.text.style.width = pane.offsetWidth-30+"px" } if (location.hash) { location.href = location.hash @@ -138,32 +161,16 @@ var page = Page({ }) 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") { - var conf = init(field, option, output) + var conf = init(page, pane, form, output) if (conf) { kit.AppendChild(output, conf) } } }) }, - conf: { - scroll_x: 50, - scroll_y: 50, - }, })