mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
opt Event.js
This commit is contained in:
parent
985413fcd4
commit
3a793c7a9d
@ -176,7 +176,7 @@ var page = Page({check: true,
|
|||||||
initRiver: function(page, field, option, output) {
|
initRiver: function(page, field, option, output) {
|
||||||
return {
|
return {
|
||||||
Show: function(which) {var pane = field.Pane
|
Show: function(which) {var pane = field.Pane
|
||||||
ctx.Event(event, {}, {name: "river.show"})
|
pane.Event(event, {}, {name: pane.Zone("show", page.who.get())})
|
||||||
output.innerHTML = "", pane.Update([], "text", ["nick", "count"], "key", which||ctx.Search("river")||true)
|
output.innerHTML = "", pane.Update([], "text", ["nick", "count"], "key", which||ctx.Search("river")||true)
|
||||||
},
|
},
|
||||||
Action: {
|
Action: {
|
||||||
@ -211,7 +211,7 @@ var page = Page({check: true,
|
|||||||
return field.style.display == "none"
|
return field.style.display == "none"
|
||||||
},
|
},
|
||||||
Show: function(i) {var pane = field.Pane
|
Show: function(i) {var pane = field.Pane
|
||||||
field.Pane.Back(river, output)
|
field.Pane.Load(river, output)
|
||||||
|
|
||||||
var foot = page.footer.Pane, cmds = [river, "brow", i||which[river]||0]
|
var foot = page.footer.Pane, cmds = [river, "brow", i||which[river]||0]
|
||||||
cmds[2] || (output.innerHTML = ""), pane.Tickers(page.conf.refresh, cmds, function(line, index, msg) {
|
cmds[2] || (output.innerHTML = ""), pane.Tickers(page.conf.refresh, cmds, function(line, index, msg) {
|
||||||
@ -274,6 +274,7 @@ var page = Page({check: true,
|
|||||||
},
|
},
|
||||||
initAction: function(page, field, option, output) {
|
initAction: function(page, field, option, output) {
|
||||||
var river = "", storm = 0, input = "", share = ""
|
var river = "", storm = 0, input = "", share = ""
|
||||||
|
var temp = ""
|
||||||
output.DisplayRaw = true
|
output.DisplayRaw = true
|
||||||
return {
|
return {
|
||||||
Tutor: function() {var pane = field.Pane
|
Tutor: function() {var pane = field.Pane
|
||||||
@ -290,8 +291,8 @@ var page = Page({check: true,
|
|||||||
"聊天", "help target", "help target list",
|
"聊天", "help target", "help target list",
|
||||||
], 0)
|
], 0)
|
||||||
},
|
},
|
||||||
Core: function(event, line, args, cbs) {
|
Core: function(event, line, args, cbs) {var pane = field.Pane
|
||||||
var msg = ctx.Event(event)
|
var msg = pane.Event(event)
|
||||||
var plugin = event.Plugin || page.plugin && page.plugin.Plugin || {}, engine = {
|
var plugin = event.Plugin || page.plugin && page.plugin.Plugin || {}, engine = {
|
||||||
share: function(args) {
|
share: function(args) {
|
||||||
return ctx.Share({"group": option.dataset.group, "names": option.dataset.names, "cmds": [
|
return ctx.Share({"group": option.dataset.group, "names": option.dataset.names, "cmds": [
|
||||||
@ -429,9 +430,9 @@ var page = Page({check: true,
|
|||||||
event.shiftKey? engine._msg(): engine._run()
|
event.shiftKey? engine._msg(): engine._run()
|
||||||
},
|
},
|
||||||
Show: function() {var pane = field.Pane
|
Show: function() {var pane = field.Pane
|
||||||
if (field.Pane.Back(river+storm, output)) {return}
|
if (river && storm && field.Pane.Load(river+"."+storm, output)) {return}
|
||||||
|
|
||||||
ctx.Event(event, {}, {name: "action.show"})
|
pane.Event(event, {}, {name: pane.Zone("show", river, storm)})
|
||||||
pane.clear(), pane.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
pane.clear(), pane.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
||||||
pane.Core(event, line, args, cbs)
|
pane.Core(event, line, args, cbs)
|
||||||
})
|
})
|
||||||
@ -442,10 +443,10 @@ var page = Page({check: true,
|
|||||||
return layout.value
|
return layout.value
|
||||||
},
|
},
|
||||||
Listen: {
|
Listen: {
|
||||||
river: function(value, old) {river = value},
|
river: function(value, old) {temp = value},
|
||||||
storm: function(value, old) {
|
storm: function(value, old) {
|
||||||
field.Pane.Save(river+"."+storm, output)
|
river && storm && field.Pane.Save(river+"."+storm, output)
|
||||||
storm = value, field.Pane.Show()
|
;(river = page.river.Pane.which.get(), storm = value) && field.Pane.Show()
|
||||||
},
|
},
|
||||||
source: function(value, old) {input = value},
|
source: function(value, old) {input = value},
|
||||||
target: function(value, old) {share = value},
|
target: function(value, old) {share = value},
|
||||||
@ -565,13 +566,18 @@ var page = Page({check: true,
|
|||||||
prev? prev.click(): output.lastChild.click()
|
prev? prev.click(): output.lastChild.click()
|
||||||
},
|
},
|
||||||
Show: function(which) {var pane = field.Pane
|
Show: function(which) {var pane = field.Pane
|
||||||
ctx.Event(event, {}, {name: "storm.show"})
|
var data = river && field.Pane.Load(river, output)
|
||||||
pane.which.get("") == which && page.action.Pane.Show()
|
if (data) {return pane.which.set(data.which)}
|
||||||
output.innerHTML = "", pane.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
|
|
||||||
|
pane.Event(event, {}, {name: pane.Zone("show", river)})
|
||||||
|
output.innerHTML = "", pane.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true, null, function(msg) {
|
||||||
|
pane.which.get() == "" && pane.Select(0, msg.key[0])
|
||||||
|
})
|
||||||
},
|
},
|
||||||
Listen: {
|
Listen: {
|
||||||
river: function(value, old) {
|
river: function(value, old) {var pane = field.Pane
|
||||||
field.Pane.which.set(""), river = value, field.Pane.Show()
|
river && pane.Save(river, output, {which: pane.which.get()})
|
||||||
|
river = value, pane.which.set(""), pane.Show()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: {
|
Action: {
|
||||||
@ -659,7 +665,7 @@ var page = Page({check: true,
|
|||||||
}]}, {name: "list", view: ["list", "table"], list: [{text: ["3. 已选命令列表", "caption"]}]},
|
}]}, {name: "list", view: ["list", "table"], list: [{text: ["3. 已选命令列表", "caption"]}]},
|
||||||
]}])
|
]}])
|
||||||
|
|
||||||
var river = ""
|
var river = "", user = "", node = ""
|
||||||
return {
|
return {
|
||||||
Select: function(com, pod) {var pane = field.Pane
|
Select: function(com, pod) {var pane = field.Pane
|
||||||
var last = kit.AppendChild(ui.list, [{
|
var last = kit.AppendChild(ui.list, [{
|
||||||
@ -673,16 +679,22 @@ var page = Page({check: true,
|
|||||||
kit.AppendTable(device, list, ["key", "index", "name", "help"], function(value, key, com, i, tr, event) {
|
kit.AppendTable(device, list, ["key", "index", "name", "help"], function(value, key, com, i, tr, event) {
|
||||||
pane.Select(com, pod)
|
pane.Select(com, pod)
|
||||||
}, function(value, key, com, i, tr, event) {
|
}, function(value, key, com, i, tr, event) {
|
||||||
page.carte.Pane.Show(event, ["创建"], function(event, item) {
|
page.carte.Pane.Show(event, shy({}, ["创建"], function(event, item) {
|
||||||
pane.Create(com.key)
|
pane.Create(com.key)
|
||||||
})
|
}))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Append: function(msg) {var pane = field.Pane
|
Append: function(msg) {var pane = field.Pane
|
||||||
kit.AppendChilds(table, [{text: ["1. 选择用户节点 ->", "caption"]}])
|
kit.AppendChilds(table, [{text: ["1. 选择用户节点 ->", "caption"]}])
|
||||||
kit.AppendTable(table, msg.Table(), ["user", "node"], function(value, key, pod, i, tr, event) {
|
kit.AppendTable(table, msg.Table(), ["user", "node"], function(value, key, pod, i, tr, event) {
|
||||||
|
pane.Event(event, {}, {name: pane.Zone("show", river, pod.user, pod.node)})
|
||||||
kit.Selector(table, "tr.select", function(item) {item.className = "normal"})
|
kit.Selector(table, "tr.select", function(item) {item.className = "normal"})
|
||||||
tr.className = "select", pane.Run([river, pod.user, pod.node], function(msg) {
|
|
||||||
|
node && field.Pane.Save(river+"."+user+"."+node, device)
|
||||||
|
user = pod.user, node = pod.node, tr.className = "select"
|
||||||
|
if (field.Pane.Load(river+"."+user+"."+node, device)) {return}
|
||||||
|
|
||||||
|
pane.Run([river, pod.user, pod.node], function(msg) {
|
||||||
pane.Update(msg.Table(), pod)
|
pane.Update(msg.Table(), pod)
|
||||||
})
|
})
|
||||||
}), table.querySelector("td").click()
|
}), table.querySelector("td").click()
|
||||||
@ -693,6 +705,7 @@ var page = Page({check: true,
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
Show: function(name) {var pane = field.Pane
|
Show: function(name) {var pane = field.Pane
|
||||||
|
pane.Event(event, {}, {name: pane.Zone("show", river)})
|
||||||
pane.Dialog(), ui.name.focus(), ui.name.value = name||"nice", pane.Run([river], pane.Append)
|
pane.Dialog(), ui.name.focus(), ui.name.value = name||"nice", pane.Run([river], pane.Append)
|
||||||
},
|
},
|
||||||
Listen: {
|
Listen: {
|
||||||
|
@ -9,19 +9,20 @@ ctx = context = (function(kit) {var ctx = {__proto__: kit,
|
|||||||
for (var k in dataset) {
|
for (var k in dataset) {
|
||||||
option[k] = dataset[k].split(",")
|
option[k] = dataset[k].split(",")
|
||||||
}
|
}
|
||||||
msg.Order = ++arguments.callee.meta.order
|
|
||||||
|
var what = ++arguments.callee.meta.order
|
||||||
|
|
||||||
msg.option = []
|
msg.option = []
|
||||||
for (var k in option) {
|
for (var k in option) {
|
||||||
msg.option.push(k)
|
msg.option.push(k)
|
||||||
msg[k] = option[k]
|
msg[k] = option[k]
|
||||||
}
|
}
|
||||||
msg.detail = ["run", msg.Order].concat(option.group).concat(option.names).concat(option.cmds)
|
msg.detail = ["run", what].concat(option.group).concat(option.names).concat(option.cmds)
|
||||||
kit.Log(msg.detail.concat([msg]))
|
kit.Log(msg.detail.concat([msg]))
|
||||||
|
|
||||||
kit.History("run", -1, option)
|
kit.History("run", -1, option)
|
||||||
this.POST("", option, function(msg) {
|
this.POST("", option, function(msg) {
|
||||||
kit.Log("run", msg.Order, "result", msg.result? msg.result[0]: "", msg)
|
kit.Log("run", what, "result", msg.result? msg.result[0]: "", msg)
|
||||||
kit._call(cb, [msg])
|
kit._call(cb, [msg])
|
||||||
}, msg)
|
}, msg)
|
||||||
}),
|
}),
|
||||||
@ -55,7 +56,7 @@ ctx = context = (function(kit) {var ctx = {__proto__: kit,
|
|||||||
},
|
},
|
||||||
}, msg.event = event
|
}, msg.event = event
|
||||||
|
|
||||||
kit.Log("event", ++arguments.callee.meta.order, event.type, proto.name, msg)
|
kit.Log("event", ++arguments.callee.meta.order, event.type, proto.name.join("."), msg)
|
||||||
return msg
|
return msg
|
||||||
}),
|
}),
|
||||||
Share: shy("共享链接", function(objs, clear) {objs = objs || {}
|
Share: shy("共享链接", function(objs, clear) {objs = objs || {}
|
||||||
@ -167,7 +168,7 @@ ctx = context = (function(kit) {var ctx = {__proto__: kit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Event入口 -1.0
|
// Event入口 -1.0
|
||||||
msg = ctx.Event(event, msg, {name: document.title, Order: ++meta.order, Reply: function(msg) {
|
msg = ctx.Event(event, msg, {name: [document.title, "wss", msg.detail[0]], Order: ++meta.order, Reply: function(msg) {
|
||||||
kit.Log(["wss", msg.Order, "result"].concat(msg.result).concat([msg]))
|
kit.Log(["wss", msg.Order, "result"].concat(msg.result).concat([msg]))
|
||||||
delete(msg.event), s.send(JSON.stringify(msg))
|
delete(msg.event), s.send(JSON.stringify(msg))
|
||||||
}})
|
}})
|
||||||
|
@ -5,18 +5,13 @@ function Meta(zone, target, obj) {
|
|||||||
a.__proto__ = arguments[i], a = arguments[i]
|
a.__proto__ = arguments[i], a = arguments[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
var names = obj && obj.Event && obj.Event.meta && obj.Event.meta.name && obj.Event.meta.name.concat([zone]) || [zone]
|
|
||||||
|
|
||||||
// 构造对象
|
// 构造对象
|
||||||
var id = 1
|
var id = 1
|
||||||
var conf = {}, conf_cb = {}, old
|
var conf = {}, conf_cb = {}, old
|
||||||
var sync = {}
|
var sync = {}
|
||||||
var cache = {}
|
var cache = {}, datas = {}
|
||||||
var history = []
|
var history = []
|
||||||
var meta = {__proto__: obj, target: target,
|
var meta = {__proto__: obj, target: target,
|
||||||
Event: shy("事件入口", {name: names}, function(event, msg) {
|
|
||||||
return ctx.Event(event, msg||{}, arguments.callee.meta)
|
|
||||||
}),
|
|
||||||
ID: shy("单一序列", function() {return id++}),
|
ID: shy("单一序列", function() {return id++}),
|
||||||
Conf: shy("配置变量", function(key, value, cb) {
|
Conf: shy("配置变量", function(key, value, cb) {
|
||||||
if (kit.isNone(key)) {return conf}
|
if (kit.isNone(key)) {return conf}
|
||||||
@ -45,8 +40,8 @@ function Meta(zone, target, obj) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
Save: shy("保存视图", function(name, output) {if (name === "") {return cache = {}}
|
Save: shy("保存视图", function(name, output, data) {if (name === "") {return cache = {}}
|
||||||
kit.Log("view", "save", zone, name)
|
kit.Log("view", "save", meta.Zone(name).join("."))
|
||||||
var temp = document.createDocumentFragment()
|
var temp = document.createDocumentFragment()
|
||||||
while (output.childNodes.length>0) {
|
while (output.childNodes.length>0) {
|
||||||
var item = output.childNodes[0]
|
var item = output.childNodes[0]
|
||||||
@ -54,17 +49,18 @@ function Meta(zone, target, obj) {
|
|||||||
temp.appendChild(item)
|
temp.appendChild(item)
|
||||||
}
|
}
|
||||||
cache[name] = temp
|
cache[name] = temp
|
||||||
|
datas[name] = data || {}
|
||||||
return name
|
return name
|
||||||
}),
|
}),
|
||||||
Back: shy("恢复视图", function(name, output) {if (kit.isNone(cache[name])) {return}
|
Load: shy("恢复视图", function(name, output) {if (kit.isNone(cache[name])) {return}
|
||||||
kit.Log("view", "back", zone, name)
|
kit.Log("view", "load", meta.Zone(name).join("."))
|
||||||
while (cache[name].childNodes.length>0) {
|
while (cache[name].childNodes.length>0) {
|
||||||
var item = cache[name].childNodes[0]
|
var item = cache[name].childNodes[0]
|
||||||
item.parentNode.removeChild(item)
|
item.parentNode.removeChild(item)
|
||||||
output.appendChild(item)
|
output.appendChild(item)
|
||||||
}
|
}
|
||||||
delete(cache[name])
|
delete(cache[name])
|
||||||
return name
|
return datas[name]
|
||||||
}),
|
}),
|
||||||
View: shy("添加视图", function(output, type, line, key, cb) {
|
View: shy("添加视图", function(output, type, line, key, cb) {
|
||||||
var text = line, list = [], ui = {}
|
var text = line, list = [], ui = {}
|
||||||
@ -126,6 +122,10 @@ function Meta(zone, target, obj) {
|
|||||||
return kit.isNone(value)? (item = history.pop()) && (item.target.value = item.value):
|
return kit.isNone(value)? (item = history.pop()) && (item.target.value = item.value):
|
||||||
history.push({value: value, target: target})
|
history.push({value: value, target: target})
|
||||||
}),
|
}),
|
||||||
|
Event: shy("事件入口", {name: zone}, function(event, msg, proto) {
|
||||||
|
return ctx.Event(event, msg, proto||arguments.callee.meta)
|
||||||
|
}),
|
||||||
|
Zone: function(name) {return zone.concat(kit.List(arguments))},
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册事件
|
// 注册事件
|
||||||
@ -136,10 +136,10 @@ function Meta(zone, target, obj) {
|
|||||||
}
|
}
|
||||||
function Page(page) {
|
function Page(page) {
|
||||||
var script = {}, record = ""
|
var script = {}, record = ""
|
||||||
page = Meta(document.title, document.body, page, {__proto__: ctx,
|
page = Meta([document.title], document.body, page, {__proto__: ctx,
|
||||||
onload: function(event) {
|
onload: function(event) {
|
||||||
// Event入口 0
|
// Event入口 0
|
||||||
ctx.Event(event, {}, {name: document.title})
|
page.Event(event, {})
|
||||||
if (page.check && !ctx.Cookie("sessid")) {
|
if (page.check && !ctx.Cookie("sessid")) {
|
||||||
// 用户登录
|
// 用户登录
|
||||||
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
document.querySelectorAll("body>fieldset.Login").forEach(function(field) {
|
||||||
@ -150,7 +150,7 @@ function Page(page) {
|
|||||||
document.querySelectorAll("body>fieldset").forEach(function(field) {
|
document.querySelectorAll("body>fieldset").forEach(function(field) {
|
||||||
page.Pane(page, field)
|
page.Pane(page, field)
|
||||||
}), page.check? page.login.Pane.Run([], function(msg) {
|
}), page.check? page.login.Pane.Run([], function(msg) {
|
||||||
msg.result && msg.result[0]? (page.init(page), page.header.Pane.State("user", msg.nickname[0]))
|
msg.result && msg.result[0]? (page.init(page), page.who.set(msg.nickname[0]))
|
||||||
:page.login.Pane.Dialog(1, 1)
|
:page.login.Pane.Dialog(1, 1)
|
||||||
}): page.init(page)
|
}): page.init(page)
|
||||||
}
|
}
|
||||||
@ -441,19 +441,19 @@ function Page(page) {
|
|||||||
initDebug: function(page, field, option, output) {
|
initDebug: function(page, field, option, output) {
|
||||||
var list = kit.AppendChilds(output, "table")
|
var list = kit.AppendChilds(output, "table")
|
||||||
var caption = kit.AppendChilds(list, [{type: "caption"}]).last
|
var caption = kit.AppendChilds(list, [{type: "caption"}]).last
|
||||||
var head = kit.AppendChild(list, [{row: ["time", "type", "main", "arg", "args"], sub: "th"}]).last
|
var head = kit.AppendChild(list, [{row: ["time", "type", "order", "action", "target", "args"], sub: "th"}]).last
|
||||||
kit.OrderTable(list)
|
kit.OrderTable(list)
|
||||||
var data, types = {all: 0, event: 0, run: 0, key: 0}
|
var data, types = {all: 0, event: 0, run: 0, key: 0}
|
||||||
|
|
||||||
|
|
||||||
kit.Log.meta.call.push(function(time, type, main, arg) {var Choice = field.Pane && field.Pane.Choice || []
|
kit.Log.meta.call.push(function(time, type, order, action, target) {var Choice = field.Pane && field.Pane.Choice || []
|
||||||
if (kit.isNone(types[type])) {types[type] = 0, Choice.push(type)}
|
if (kit.isNone(types[type])) {types[type] = 0, Choice.push(type)}
|
||||||
types[type]++
|
types[type]++
|
||||||
types.all++
|
types.all++
|
||||||
|
|
||||||
data = kit.AppendChild(list, [{className: type, row: [time, type, main, arg||"", kit.List(arguments, function(item) {
|
data = kit.AppendChild(list, [{className: type, row: [time, type, order, action||"", target||"", kit.List(arguments, function(item) {
|
||||||
return typeof item == "object"? "{...}": item
|
return typeof item == "object"? "{...}": item
|
||||||
}).slice(4).join(" ")]}]).last
|
}).slice(5).join(" ")]}]).last
|
||||||
data.scrollIntoView()
|
data.scrollIntoView()
|
||||||
caption.innerHTML = kit.List(Choice.slice(1), function(item) {return item+": "+types[item]}).join(" ")
|
caption.innerHTML = kit.List(Choice.slice(1), function(item) {return item+": "+types[item]}).join(" ")
|
||||||
})
|
})
|
||||||
@ -494,8 +494,8 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
initLogin: function(page, field, option, output) {
|
initLogin: function(page, field, option, output) {
|
||||||
var ui = kit.AppendChilds(option, [
|
var ui = kit.AppendChilds(option, [
|
||||||
{label: "username"}, {input: ["username"]}, {type: "br"},
|
{label: "username"}, {input: ["username"], data: {autocomplete: "username"}}, {type: "br"},
|
||||||
{label: "password"}, {password: ["password"]}, {type: "br"},
|
{label: "password"}, {password: ["password"], data: {autocomplete: "current-password"}}, {type: "br"},
|
||||||
{button: ["login", function(event) {
|
{button: ["login", function(event) {
|
||||||
if (!ui.username.value) {ui.username.focus(); return}
|
if (!ui.username.value) {ui.username.focus(); return}
|
||||||
if (!ui.password.value) {ui.password.focus(); return}
|
if (!ui.password.value) {ui.password.focus(); return}
|
||||||
@ -520,6 +520,8 @@ function Page(page) {
|
|||||||
initHeader: function(page, field, option, output) {
|
initHeader: function(page, field, option, output) {
|
||||||
var state = {title: "github.com/shylinux/context"}, list = [], cb = function(event, item, value) {}
|
var state = {title: "github.com/shylinux/context"}, list = [], cb = function(event, item, value) {}
|
||||||
field.onclick = function(event) {page.pane && page.pane.scrollTo(0, 0)}
|
field.onclick = function(event) {page.pane && page.pane.scrollTo(0, 0)}
|
||||||
|
page.who.change(function(value, old) {field.Pane.State("user", value)})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Order: function(value, order, cbs) {
|
Order: function(value, order, cbs) {
|
||||||
state = value, list = order, cb = cbs || cb, field.Pane.Show()
|
state = value, list = order, cb = cbs || cb, field.Pane.Show()
|
||||||
@ -595,7 +597,7 @@ function Page(page) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Pane: Pane,
|
Pane: Pane,
|
||||||
}), page.which = page.Sync("layout")
|
}), page.which = page.Sync("layout"), page.who = page.Sync("username")
|
||||||
|
|
||||||
kit.Log("init", "page", page)
|
kit.Log("init", "page", page)
|
||||||
return window.onload = page.onload, page
|
return window.onload = page.onload, page
|
||||||
@ -607,18 +609,19 @@ function Pane(page, field) {
|
|||||||
|
|
||||||
var timer = ""
|
var timer = ""
|
||||||
var name = option.dataset.names
|
var name = option.dataset.names
|
||||||
var list = [], last = -1, member = {}
|
var member = {}
|
||||||
var pane = Meta(name, field, (page[field.dataset.init] || function() {
|
var pane = Meta(page.Zone(name), field, (page[field.dataset.init] || function() {
|
||||||
})(page, field, option, output) || {}, {
|
})(page, field, option, output) || {}, {
|
||||||
Append: function(type, line, key, which, cb) {type = type || line.type
|
Append: function(type, line, key, which, cb) {type = type || line.type
|
||||||
var index = list.length, ui = pane.View(output, type, line, key, function(event, cmds, cbs) {
|
var index = kit.Selector(output, "div.item").length
|
||||||
|
var ui = pane.View(output, type, line, key, function(event, cmds, cbs) {
|
||||||
(type != "plugin" && type != "field") && pane.Select(index, line[which])
|
(type != "plugin" && type != "field") && pane.Select(index, line[which])
|
||||||
page.script("record", [name, line[key[0]]])
|
page.script("record", [name, line[key[0]]])
|
||||||
kit._call(cb, [line, index, event, cmds, cbs])
|
kit._call(cb, [line, index, event, cmds, cbs])
|
||||||
})
|
})
|
||||||
|
|
||||||
list.push(ui.last), field.scrollBy(0, field.scrollHeight+100)
|
field.scrollBy(0, field.scrollHeight+100)
|
||||||
key && key.length > 0 && (member[line[which]] = member[line[key[0]]] = {index:index, key:line[which]});
|
key && key.length > 0 && (member[line[which]] = member[line[key[0]]] = {key:line[which]});
|
||||||
|
|
||||||
(type == "plugin" && line.name || type == "field") && page.Require(line.init? line.group+"/"+line.init: "", function(init) {
|
(type == "plugin" && line.name || type == "field") && page.Require(line.init? line.group+"/"+line.init: "", function(init) {
|
||||||
page.Require(line.view? line.group+"/"+line.view: "", function(view) {
|
page.Require(line.view? line.group+"/"+line.view: "", function(view) {
|
||||||
@ -644,13 +647,16 @@ function Pane(page, field) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
Select: function(index, key) {
|
Select: function(index, key) {
|
||||||
-1 < last && last < list.length && (kit.classList.del(list[last], "select"))
|
kit.Selector(output, "div.item.select", function(item) {kit.classList.del(item, "select")})
|
||||||
last = index, list[index] && (kit.classList.add(list[index], "select"))
|
kit.Selector(output, "div.item", function(item, i) {
|
||||||
|
if (i == index) {kit.classList.add(item, "select")}
|
||||||
|
})
|
||||||
|
|
||||||
// Event入口 1.0
|
// Event入口 1.0
|
||||||
ctx.Event(event, {}, {name: name+"."+key})
|
pane.Event(event, {}, {name: pane.Zone("select", key)})
|
||||||
key && pane.which.set(key)
|
key && pane.which.set(key)
|
||||||
},
|
},
|
||||||
clear: function() {output.innerHTML = "", list = [], last = -1},
|
clear: function() {output.innerHTML = ""},
|
||||||
|
|
||||||
Help: function(type, action) {
|
Help: function(type, action) {
|
||||||
var text = []
|
var text = []
|
||||||
@ -695,7 +701,10 @@ function Pane(page, field) {
|
|||||||
})})
|
})})
|
||||||
},
|
},
|
||||||
Ticker: function(time, cmds, cb) {timer && clearTimeout(timer)
|
Ticker: function(time, cmds, cb) {timer && clearTimeout(timer)
|
||||||
function loop() {!pane.Stop() && pane.Run(cmds, function(msg) {
|
function loop() {
|
||||||
|
window.event = document.createEvent("Event")
|
||||||
|
pane.Event(event, {}, {name: pane.Zone("ticker")})
|
||||||
|
!pane.Stop() && pane.Run(cmds, function(msg) {
|
||||||
cb(msg), timer = setTimeout(loop, time)
|
cb(msg), timer = setTimeout(loop, time)
|
||||||
})}
|
})}
|
||||||
time && (timer = setTimeout(loop, 10))
|
time && (timer = setTimeout(loop, 10))
|
||||||
@ -705,7 +714,10 @@ function Pane(page, field) {
|
|||||||
(cb||pane.ondaemon)(line, index, msg)
|
(cb||pane.ondaemon)(line, index, msg)
|
||||||
})})
|
})})
|
||||||
},
|
},
|
||||||
Run: function(cmds, cb) {ctx.Run(option.dataset, cmds, cb||pane.ondaemon)},
|
Run: function(cmds, cb) {
|
||||||
|
pane.Event(event, null, {name: pane.Zone(cmds[0])})
|
||||||
|
ctx.Run(option.dataset, cmds, cb||pane.ondaemon)
|
||||||
|
},
|
||||||
|
|
||||||
Show: function() {
|
Show: function() {
|
||||||
kit.ModifyView(field, {display: "block"})
|
kit.ModifyView(field, {display: "block"})
|
||||||
@ -746,7 +758,7 @@ function Pane(page, field) {
|
|||||||
delete(page.dialog)
|
delete(page.dialog)
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
which: page.Sync(name), Listen: {}, Action: {}, Button: [],
|
which: page.Sync(name), Listen: {}, Action: {}, Button: [], Choice: [],
|
||||||
Plugin: Plugin,
|
Plugin: Plugin,
|
||||||
|
|
||||||
onaction: shy("事件列表", {
|
onaction: shy("事件列表", {
|
||||||
@ -760,7 +772,7 @@ function Pane(page, field) {
|
|||||||
|
|
||||||
function call(value, event) {
|
function call(value, event) {
|
||||||
// Event入口 1.1
|
// Event入口 1.1
|
||||||
ctx.Event(event, {}, {name: name+"."+value})
|
pane.Event(event, {}, {name: pane.Zone("click", value)})
|
||||||
page.script("record", [name, value])
|
page.script("record", [name, value])
|
||||||
|
|
||||||
if (pane.Action && pane.Action.meta && typeof pane.Action.meta[value] == "function") {
|
if (pane.Action && pane.Action.meta && typeof pane.Action.meta[value] == "function") {
|
||||||
@ -791,7 +803,7 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
var feature = JSON.parse(meta.feature||'{}')
|
var feature = JSON.parse(meta.feature||'{}')
|
||||||
kit.classList.add(field, meta.group, name, feature.style)
|
kit.classList.add(field, meta.group, name, feature.style)
|
||||||
|
|
||||||
var plugin = Meta(meta.group+"."+name, field, inits && inits(field, option, output) || {}, {Inputs: {},
|
var plugin = Meta(pane.Zone(name), field, inits && inits(field, option, output) || {}, {Inputs: {},
|
||||||
Appends: function() {
|
Appends: function() {
|
||||||
var name = "args"+kit.Selector(option, "input.args.temp").length
|
var name = "args"+kit.Selector(option, "input.args.temp").length
|
||||||
plugin.Append({type: "text", name: name, className: "args temp"}).focus()
|
plugin.Append({type: "text", name: name, className: "args temp"}).focus()
|
||||||
@ -1000,7 +1012,7 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
},
|
},
|
||||||
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
||||||
type != meta.type && plugin.Save(meta.type, output), meta.type = type
|
type != meta.type && plugin.Save(meta.type, output), meta.type = type
|
||||||
!plugin.Back(type, output) && Output(plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
!plugin.Load(type, output) && Output(plugin, type || feature.display, msg || plugin.msg, cb, output, option)
|
||||||
}),
|
}),
|
||||||
onchoice: shy("菜单列表", {
|
onchoice: shy("菜单列表", {
|
||||||
"添加": "Clone",
|
"添加": "Clone",
|
||||||
@ -1026,7 +1038,7 @@ function Plugin(page, pane, field, inits, runs) {
|
|||||||
}
|
}
|
||||||
function Inputs(plugin, meta, item, target) {
|
function Inputs(plugin, meta, item, target) {
|
||||||
var plug = meta.plug, name = meta.name, type = item.type
|
var plug = meta.plug, name = meta.name, type = item.type
|
||||||
var input = Meta(plug+"."+name, target, item, {
|
var input = Meta(plugin.Zone(name), target, item, {
|
||||||
onimport: shy("导入数据", {}, [item.imports], function() {
|
onimport: shy("导入数据", {}, [item.imports], function() {
|
||||||
kit.List(arguments.callee.list, function(imports) {
|
kit.List(arguments.callee.list, function(imports) {
|
||||||
page.Sync(imports).change(function(value) {
|
page.Sync(imports).change(function(value) {
|
||||||
@ -1037,7 +1049,7 @@ function Inputs(plugin, meta, item, target) {
|
|||||||
}),
|
}),
|
||||||
onaction: shy("事件列表", {
|
onaction: shy("事件列表", {
|
||||||
onfocus: function(event) {plugin.Select(target)},
|
onfocus: function(event) {plugin.Select(target)},
|
||||||
onblur: function(event) {input.which.set(target.value)},
|
onblur: function(event) {type == "text" && input.which.set(target.value)},
|
||||||
onclick: function(event) {
|
onclick: function(event) {
|
||||||
// Event入口 2.0
|
// Event入口 2.0
|
||||||
type == "button" && input.Event(event) && kit.Value(input[item.cb], plugin[item.cb], function() {
|
type == "button" && input.Event(event) && kit.Value(input[item.cb], plugin[item.cb], function() {
|
||||||
@ -1046,7 +1058,7 @@ function Inputs(plugin, meta, item, target) {
|
|||||||
},
|
},
|
||||||
onchange: function(event) {
|
onchange: function(event) {
|
||||||
// Event入口 2.1
|
// Event入口 2.1
|
||||||
type == "select" && ctx.Event(event) && plugin.Check(item.action == "auto"? undefined: target)
|
type == "select" && input.Event(event) && plugin.Check(item.action == "auto"? undefined: target)
|
||||||
},
|
},
|
||||||
ondblclick: function(event) {
|
ondblclick: function(event) {
|
||||||
var txt = kit.History("txt", -1)
|
var txt = kit.History("txt", -1)
|
||||||
@ -1124,9 +1136,6 @@ function Inputs(plugin, meta, item, target) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
}, function(event, key, cb) {cb(event)}),
|
}, function(event, key, cb) {cb(event)}),
|
||||||
Event: shy("事件入口", {name: plug+"."+name}, function(event, msg) {
|
|
||||||
return ctx.Event(event, msg||{}, arguments.callee.meta)
|
|
||||||
}),
|
|
||||||
which: plugin.Sync(name),
|
which: plugin.Sync(name),
|
||||||
}, plugin)
|
}, plugin)
|
||||||
|
|
||||||
@ -1140,7 +1149,7 @@ function Inputs(plugin, meta, item, target) {
|
|||||||
}
|
}
|
||||||
function Output(plugin, type, msg, cb, target, option) {
|
function Output(plugin, type, msg, cb, target, option) {
|
||||||
var exports = plugin.target.Meta.exports
|
var exports = plugin.target.Meta.exports
|
||||||
var output = Meta(type, target, {
|
var output = Meta(plugin.Zone(type), target, {
|
||||||
_table: function() {plugin.onfigure("table")},
|
_table: function() {plugin.onfigure("table")},
|
||||||
_canvas: function() {plugin.onfigure("canvas")},
|
_canvas: function() {plugin.onfigure("canvas")},
|
||||||
onexport: shy("导出数据", {
|
onexport: shy("导出数据", {
|
||||||
@ -1202,6 +1211,7 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
}, function(type, msg, cb) {var meta = arguments.callee.meta
|
||||||
|
page.output = target
|
||||||
meta[type](msg, cb)
|
meta[type](msg, cb)
|
||||||
}),
|
}),
|
||||||
onchoice: shy("菜单列表", {
|
onchoice: shy("菜单列表", {
|
||||||
@ -1221,5 +1231,5 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
}, function(event, key, cb) {cb(event)}),
|
}, function(event, key, cb) {cb(event)}),
|
||||||
}, plugin)
|
}, plugin)
|
||||||
output.onimport(type, msg, cb)
|
output.onimport(type, msg, cb)
|
||||||
return output
|
return target.Output = output
|
||||||
}
|
}
|
||||||
|
@ -286,9 +286,8 @@ kit = toolkit = (function() {var kit = {__proto__: document,
|
|||||||
}
|
}
|
||||||
return kit.AppendChild(parent, kit.List(list, function(item, index) {
|
return kit.AppendChild(parent, kit.List(list, function(item, index) {
|
||||||
return item === ""? {view: ["space"]}:
|
return item === ""? {view: ["space"]}:
|
||||||
typeof item == "string"? {button: [item, function(event) {
|
typeof item == "string"? {button: [item, cb]}:
|
||||||
kit._call(cb, [item, event])
|
item.forEach? {select: [item, cb]}: item
|
||||||
}]}: item.forEach? {select: [item, cb]}: item
|
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
AppendTable: function(table, data, fields, cb, cbs) {if (!data || !fields) {return}
|
AppendTable: function(table, data, fields, cb, cbs) {if (!data || !fields) {return}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user