1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

opt chat.js

This commit is contained in:
shylinux 2019-06-24 08:09:17 +08:00
parent a24fc9cdcf
commit b16edbe23c
4 changed files with 98 additions and 102 deletions

View File

@ -461,8 +461,7 @@ Page({
init: function(page) { init: function(page) {
page.onlayout(null, page.conf.layout) page.onlayout(null, page.conf.layout)
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.isMobile? "最宽": "最大") page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.isMobile? "最宽": "最大")
page.footer.Pane.Order({"site": "", "ip": "", "text": "", ":":""}, kit.isMobile? ["site", "ip", "text"]: ["ip", "text", ":"], function(event, item, value) { page.footer.Pane.Order({"site": "", "ip": "", "text": "", ":":""}, kit.isMobile? ["site", "ip", "text"]: ["ip", "text", ":"], function(event, item, value) {})
})
page.header.Pane.Order({"logout": "logout", "user": ""}, ["logout", "user"], function(event, item, value) { page.header.Pane.Order({"logout": "logout", "user": ""}, ["logout", "user"], function(event, item, value) {
switch (item) { switch (item) {
case "title": case "title":

View File

@ -252,7 +252,7 @@ function Page(page) {
initHeader: function(page, field, option, output) { initHeader: function(page, field, option, output) {
var state = {}, list = [], cb = function(event, item, value) {} var state = {}, list = [], cb = function(event, item, value) {}
field.onclick = function(event) { field.onclick = function(event) {
page.pane.scrollTo(0,0) page.pane && page.pane.scrollTo(0,0)
} }
return { return {
Order: function(value, order, cbs) { Order: function(value, order, cbs) {

View File

@ -13,150 +13,148 @@ var page = Page({
sizes = sizes || {} sizes = sizes || {}
sizes.header == undefined && (sizes.header = page.header.clientHeight) sizes.header == undefined && (sizes.header = page.header.clientHeight)
sizes.footer == undefined && (sizes.footer = page.footer.clientHeight) sizes.footer == undefined && (sizes.footer = page.footer.clientHeight)
page.header.Size(width, sizes.header) page.header.Pane.Size(width, sizes.header)
page.footer.Size(width, sizes.footer) page.footer.Pane.Size(width, sizes.footer)
sizes.tree == undefined && (sizes.tree = page.tree.clientHeight) sizes.tree == undefined && (sizes.tree = page.tree.clientHeight)
// page.tree.Size(width, sizes.tree) // page.tree.Size(width, sizes.tree)
sizes.text = height - sizes.tree - sizes.header - sizes.footer - page.conf.border * 3 sizes.text = height - sizes.tree - sizes.header - sizes.footer - page.conf.border * 3
page.text.Size(width, sizes.text) page.text.Pane.Size(width, sizes.text)
}, },
oncontrol: function(event) { oncontrol: function(event) {
if (event.ctrlKey) { if (event.ctrlKey) {
switch (event.key) { switch (event.key) {
case "t": case "t":
page.tree.Tree() page.tree.Pane.Tree()
break break
case "m": case "m":
page.text.Menu() page.text.Pane.Menu()
break break
case "n": case "n":
page.tree.Tree("none") page.tree.Pane.Tree("none")
page.text.Menu("none") page.text.Pane.Menu("none")
break break
} }
} }
}, },
initTree: function(page, pane, form, output) { initTree: function(page, field, form, output) {
var ui = kit.AppendChild(output, [ var ui = kit.AppendChild(output, [
{"view": ["back"], "name": "back"}, {"view": ["gap"]}, {"view": ["back"], "name": "back"}, {"view": ["gap"]},
{"view": ["tree"], "name": "tree"}, {"view": ["gap"]}, {"view": ["tree"], "name": "tree"}, {"view": ["gap"]},
{"view": ["list"], "name": "list"}, {"view": ["gap"]}, {"view": ["list"], "name": "list"}, {"view": ["gap"]},
]) ])
pane.Conf("tree.display", "", function(value, old) { return {
pane.style.display = value Tree: function(value) {
page.onlayout() page.Conf("tree.display", value || (page.Conf("tree.display")? "": "none"))
}) },
pane.Tree = function(value) { Show: function() {
pane.Conf("tree.display", value || (pane.Conf("tree.display")? "": "none")) page.Conf("tree.display", "", function(value, old) {
field.style.display = value
page.onlayout()
})
ctx.Runs(page, form, function(msg) {
ui.back.innerHTML = "", kit.AppendChild(ui.back, [
{"button": ["知识", function(event) {
ctx.Search({"wiki_level": "", "wiki_class": "", "wiki_favor": ""})
}]},
].concat(ctx.Search("wiki_class").split("/").map(function(value, index, array) {
return value && {"button": [value, function(event) {
location.hash = "", ctx.Search({"wiki_class": array.slice(0, index+1).join("/")+"/", "wiki_favor":""})
}]}
})))
ui.tree.innerHTML = "", kit.AppendChild(ui.tree, ctx.Table(msg, function(value, index) {
return value.filename.endsWith("/") && {"text": [value.filename, "div"], click: function(event, target) {
location.hash = "", ctx.Search({"wiki_class": ctx.Search("wiki_class")+value.filename, "wiki_favor": ""})
}}
}))
ui.list.innerHTML = "", kit.AppendChild(ui.list, ctx.Table(msg, function(value, index) {
return !value.filename.endsWith("/") && {"text": [value.time.substr(5, 5)+" "+value.filename, "div"], click: function(event, target) {
location.hash = "", ctx.Search("wiki_favor", value.filename)
}}
}))
})
},
} }
ctx.Runs(page, form, function(msg) {
ui.back.innerHTML = "", kit.AppendChild(ui.back, [
{"button": ["知识", function(event) {
ctx.Search({"wiki_level": "", "wiki_class": "", "wiki_favor": ""})
}]},
].concat(ctx.Search("wiki_class").split("/").map(function(value, index, array) {
return value && {"button": [value, function(event) {
location.hash = "", ctx.Search({"wiki_class": array.slice(0, index+1).join("/")+"/", "wiki_favor":""})
}]}
})))
ui.tree.innerHTML = "", kit.AppendChild(ui.tree, ctx.Table(msg, function(value, index) {
return value.filename.endsWith("/") && {"text": [value.filename, "div"], click: function(event, target) {
location.hash = "", ctx.Search({"wiki_class": ctx.Search("wiki_class")+value.filename, "wiki_favor": ""})
}}
}))
ui.list.innerHTML = "", kit.AppendChild(ui.list, ctx.Table(msg, function(value, index) {
return !value.filename.endsWith("/") && {"text": [value.time.substr(5, 5)+" "+value.filename, "div"], click: function(event, target) {
location.hash = "", ctx.Search("wiki_favor", value.filename)
}}
}))
})
return
}, },
initText: function(page, pane, form, output) { initText: function(page, field, form, output) {
var ui = kit.AppendChild(output, [ var ui = kit.AppendChild(output, [
{"view": ["menu", "div", "", "menu"]}, {"view": ["menu", "div", "", "menu"]},
{"view": ["text", "div", "", "text"]}, {"view": ["text", "div", "", "text"]},
]) ])
ui.text.onscroll = function(event) { ui.text.onscroll = function(event) {
page.footer.State("text", kit.Position(ui.text)) page.footer.Pane.State("text", kit.Position(ui.text))
} }
ui.menu.onscroll = function(event) { ui.menu.onscroll = function(event) {
page.footer.State("menu", kit.Position(ui.menu)) page.footer.Pane.State("menu", kit.Position(ui.menu))
} }
return {
Menu: function(value) {
page.Conf("menu.display", value || (page.Conf("menu.display")? "": "none"))
},
Size: function(width, height) {
if (page.Conf("menu.float")) {
ui.menu.className = "menu left"
} else {
ui.menu.className = "menu"
}
if (page.Conf("menu.float") && page.Conf("menu.scroll")) {
ui.menu.style.height = (height-8)+"px"
ui.text.style.height = ((ui.menu.clientHeight||height)-8-20)+"px"
} else {
ui.menu.style.height = " "
ui.text.style.height = " "
}
pane.Conf("menu.display", "", function(value, old) { if (location.hash) {
ui.menu.style.display = value location.href = location.hash
}) }
pane.Conf("menu.float", !kit.isMobile, function(value, old) { ui.text.onscroll()
page.onlayout() ui.menu.onscroll()
}) },
pane.Conf("menu.scroll", true, function(value, old) { Show: function() {
page.onlayout() page.Conf("menu.display", "", function(value, old) {
}) ui.menu.style.display = value
pane.Menu = function(value) { })
pane.Conf("menu.display", value || (pane.Conf("menu.display")? "": "none")) page.Conf("menu.float", !kit.isMobile, function(value, old) {
page.onlayout()
})
page.Conf("menu.scroll", true, function(value, old) {
page.onlayout()
})
ctx.Runs(page, form, function(msg) {
ui.menu.innerHTML = "", ui.text.innerHTML = msg.result? msg.result.join(""): ""
kit.AppendChild(ui.menu, [{"tree": kit.OrderText(field, ui.text)}])
page.footer.Pane.State("count", msg.visit_count)
page.footer.Pane.State("visit", msg.visit_total)
page.onlayout()
return
})
},
} }
pane.Size = function(width, height) {
if (pane.Conf("menu.float")) {
ui.menu.className = "menu left"
} else {
ui.menu.className = "menu"
}
if (pane.Conf("menu.float") && pane.Conf("menu.scroll")) {
ui.menu.style.height = (height-8)+"px"
ui.text.style.height = ((ui.menu.clientHeight||height)-8-20)+"px"
} else {
ui.menu.style.height = " "
ui.text.style.height = " "
}
if (location.hash) {
location.href = location.hash
}
ui.text.onscroll()
ui.menu.onscroll()
}
ctx.Runs(page, form, function(msg) {
ui.menu.innerHTML = "", ui.text.innerHTML = msg.result? msg.result.join(""): ""
kit.AppendChild(ui.menu, [{"tree": kit.OrderText(pane, ui.text)}])
page.footer.State("count", msg.visit_count)
page.footer.State("visit", msg.visit_total)
page.onlayout()
return
})
return
}, },
init: function(page) { init: function(page) {
page.initField(page, function(init, pane, form) { page.footer.Pane.Order({"text": "", "menu": "", "count": "0", "visit": "0"}, ["visit", "count", "menu", "text"])
var output = pane.querySelector("div.output") page.header.Pane.Order({"tree": "tree", "menu": "menu"}, ["tree", "menu"], function(event, item, value) {
if (typeof init == "function") {
var conf = init(page, pane, form, output)
if (conf) {
kit.AppendChild(output, conf)
}
}
})
page.footer.Order({"text": "", "menu": "", "count": "0", "visit": "0"}, ["visit", "count", "menu", "text"])
page.header.Order({"tree": "tree", "menu": "menu"}, ["tree", "menu"], function(event, item, value) {
switch (item) { switch (item) {
case "menu": case "menu":
page.text.Menu() page.text.Pane.Menu()
break break
case "tree": case "tree":
page.tree.Tree() page.tree.Pane.Tree()
break break
default: default:
page.confirm("logout?") && page.login.Exit() page.confirm("logout?") && page.login.Pane.Exit()
} }
}) })
page.header.style.height = "32px"
page.footer.style.height = "32px"
page.tree.Pane.Show()
page.text.Pane.Show()
}, },
}) })

View File

@ -43,7 +43,6 @@
{{range $index, $lib := option . "scripts"}} {{range $index, $lib := option . "scripts"}}
<script src="/static/librarys/{{$lib}}"></script> <script src="/static/librarys/{{$lib}}"></script>
{{end}} {{end}}
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=LTkHoAidsaDWfEEIwY7u4Lx3Vuo05Iq6"></script>
</body> </body>
{{end}} {{end}}