1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 01:04:06 +08:00
ContextOS/usr/librarys/example.js
2019-05-13 02:16:26 +08:00

60 lines
1.6 KiB
JavaScript

exp = example = {
__proto__: ctx,
_init: function(page) {
page.__proto__ = this
var body = document.body
body.onkeydown = function(event) {
page.onscroll && page.onscroll(event, body, "scroll")
}
return this
},
initHeader: function(page, field, option, output) {
return [{"text": ["shycontext", "div", "title"]}]
},
initField: function(page, field, option, output) {
return
},
initBanner: function(page, field, option, output) {
field.querySelectorAll("li").forEach(function(item) {
item.onclick = function(event) {
ctx.Search("componet_group", item.innerText)
if (item.innerText == "login") {
ctx.Cookie("sessid", "")
}
}
})
return [{"text": ["shylinux", "div", "title"]}]
},
initFooter: function(page, field, option) {
return [{"view": ["title", "div", "<a href='mailto:shylinux@163.com'>shylinux@163.com</>"]}]
},
onscroll: function(event, target, action) {
var page = this
switch (action) {
case "scroll":
if (event.target == document.body) {
kit.ScrollPage(event, page.conf)
}
break
}
},
onresize: function(event) {},
reload: function() {
location.reload()
},
}
function Page(page) {
window.onload = function() {
page.init(exp._init(page))
}
return page
}
function Pane(pane) {
pane.showDialog = function(width, height) {
kit.showDialog(this, width, height)
}
}