mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add oncarte.page.js
This commit is contained in:
parent
c2cdeef2b1
commit
d5aa37ab1a
@ -545,6 +545,10 @@ var page = Page({check: true,
|
|||||||
"", "添加", "删除", "加参", "减参",
|
"", "添加", "删除", "加参", "减参",
|
||||||
"", "执行", "下载", "清空", "返回",
|
"", "执行", "下载", "清空", "返回",
|
||||||
],
|
],
|
||||||
|
Choice: [
|
||||||
|
"刷新", "清屏", "并行", "串行",
|
||||||
|
"", "聊天", "办公", "工作",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initStorm: function(page, field, option, output) {
|
initStorm: function(page, field, option, output) {
|
||||||
@ -589,6 +593,7 @@ var page = Page({check: true,
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Button: ["创建", "共享"],
|
Button: ["创建", "共享"],
|
||||||
|
Choice: ["创建", "共享"],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initSteam: function(page, field, option, output) {
|
initSteam: function(page, field, option, output) {
|
||||||
@ -665,6 +670,10 @@ var page = Page({check: true,
|
|||||||
kit.AppendChilds(device, [{text: ["2. 选择模块命令 ->", "caption"]}])
|
kit.AppendChilds(device, [{text: ["2. 选择模块命令 ->", "caption"]}])
|
||||||
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) {
|
||||||
|
page.oncarte(event, ["创建"], function(event, item) {
|
||||||
|
pane.Create(com.key)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Append: function(msg) {var pane = field.Pane
|
Append: function(msg) {var pane = field.Pane
|
||||||
@ -677,7 +686,7 @@ var page = Page({check: true,
|
|||||||
}), table.querySelector("td").click()
|
}), table.querySelector("td").click()
|
||||||
},
|
},
|
||||||
Create: function(name, list) {
|
Create: function(name, list) {
|
||||||
field.Pane.Run([river, "spawn", name].concat(list), function(msg) {
|
field.Pane.Run([river, "spawn", name].concat(list||[]), function(msg) {
|
||||||
field.Pane.Show(), page.storm.Pane.Show(name)
|
field.Pane.Show(), page.storm.Pane.Show(name)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -301,12 +301,12 @@ ctx = context = {__proto__: kit,
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
kit.Log(["wss", order].concat(msg.detail).concat([msg]))
|
kit.Log(["wss", order].concat(msg.detail).concat([msg]))
|
||||||
typeof cb == "function" && cb(msg)
|
typeof cb == "function" && cb(msg)
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
msg.reply(kit.Log("err", e))
|
// msg.Reply(kit.Log("err", e))
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
s.onerror = function(event) {
|
s.onerror = function(event) {
|
||||||
kit.Log("wss", "error", event)
|
kit.Log("wss", "error", event)
|
||||||
|
@ -96,7 +96,7 @@ fieldset>div.output div.code span.green {
|
|||||||
color:green;
|
color:green;
|
||||||
}
|
}
|
||||||
fieldset>div.output table td {
|
fieldset>div.output table td {
|
||||||
word-break:break-word;
|
/* word-break:break-word; */
|
||||||
}
|
}
|
||||||
fieldset>div.output table td.when {
|
fieldset>div.output table td.when {
|
||||||
word-break:break-word;
|
word-break:break-word;
|
||||||
@ -129,6 +129,17 @@ fieldset>div.Help>div {
|
|||||||
overflow:auto;
|
overflow:auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset.carte {
|
||||||
|
border:solid 2px red;
|
||||||
|
background-color:#ffffff;
|
||||||
|
position:absolute;
|
||||||
|
display:none;
|
||||||
|
z-index:200;
|
||||||
|
}
|
||||||
|
fieldset.carte>div.output>div.line {
|
||||||
|
border:solid 1px gray;
|
||||||
|
margin-top:8px;
|
||||||
|
}
|
||||||
fieldset.toast {
|
fieldset.toast {
|
||||||
border:solid 2px red;
|
border:solid 2px red;
|
||||||
background-color:#ffffff;
|
background-color:#ffffff;
|
||||||
|
@ -128,6 +128,7 @@ function Meta(target, obj) {
|
|||||||
}
|
}
|
||||||
function Page(page) {
|
function Page(page) {
|
||||||
var script = {}, record = ""
|
var script = {}, record = ""
|
||||||
|
var carte = document.querySelector("fieldset.carte")
|
||||||
page = Meta(document.body, page, {__proto__: ctx,
|
page = Meta(document.body, page, {__proto__: ctx,
|
||||||
onload: function() {
|
onload: function() {
|
||||||
// Event入口 0
|
// Event入口 0
|
||||||
@ -180,6 +181,18 @@ function Page(page) {
|
|||||||
}, document.body.onmouseup = function(event) {
|
}, document.body.onmouseup = function(event) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
oncarte: function(event, cb) {
|
||||||
|
kit.Selector(carte, "div.output", function(output) {if (!cb.list || cb.list.length == 0) {return}
|
||||||
|
kit.AppendChilds(output, kit.List(cb.list, function(item) {
|
||||||
|
return item === ""? {view: ["line"]}: {text: [item, "div", "item"], click: function(event) {
|
||||||
|
kit._call(cb, [item, cb.meta, event]) && kit.ModifyView(carte, {display: "none"})
|
||||||
|
}}
|
||||||
|
}))
|
||||||
|
kit.ModifyView(carte, {display: "block", left: event.x, top: event.y})
|
||||||
|
event.stopPropagation()
|
||||||
|
event.preventDefault()
|
||||||
|
})
|
||||||
|
},
|
||||||
ontoast: function(text, title, duration) {
|
ontoast: function(text, title, duration) {
|
||||||
// {text, title, duration, inputs, buttons}
|
// {text, title, duration, inputs, buttons}
|
||||||
if (!text) {page.toast.style.display = "none"; return}
|
if (!text) {page.toast.style.display = "none"; return}
|
||||||
@ -690,16 +703,22 @@ function Pane(page, field) {
|
|||||||
for (var k in pane.Listen) {
|
for (var k in pane.Listen) {
|
||||||
page.Sync(k).change(pane.Listen[k])
|
page.Sync(k).change(pane.Listen[k])
|
||||||
}
|
}
|
||||||
|
function call(value, event) {
|
||||||
|
// Event入口 1.1
|
||||||
|
ctx.Event(event, {}, {name: name+"."+value})
|
||||||
|
page.script("record", [name, value])
|
||||||
|
typeof pane.Action == "function"? pane.Action(value, event): pane.Action[value](event, value)
|
||||||
|
}
|
||||||
pane.Button && pane.Button.length > 0 && (kit.InsertChild(field, output, "div", pane.Button.map(function(value) {
|
pane.Button && pane.Button.length > 0 && (kit.InsertChild(field, output, "div", pane.Button.map(function(value) {
|
||||||
function call(value, event) {
|
|
||||||
// Event入口 1.1
|
|
||||||
ctx.Event(event, {}, {name: name+"."+value})
|
|
||||||
page.script("record", [name, value])
|
|
||||||
typeof pane.Action == "function"? pane.Action(value, event): pane.Action[value](event, value)
|
|
||||||
}
|
|
||||||
return typeof value == "object"? {className: value[0], select: [value.slice(1), call]}:
|
return typeof value == "object"? {className: value[0], select: [value.slice(1), call]}:
|
||||||
value == ""? {view: ["space"]} :value == "br"? {type: "br"}: {button: [value, call]}
|
value == ""? {view: ["space"]} :value == "br"? {type: "br"}: {button: [value, call]}
|
||||||
})).className="action")
|
})).className="action")
|
||||||
|
field.oncontextmenu = function(event) {
|
||||||
|
page.oncarte(event, pane.Choice, function(event, value) {
|
||||||
|
call(value, event)
|
||||||
|
return true
|
||||||
|
}) && (event.stopPropagation(), event.preventDefault())
|
||||||
|
}
|
||||||
option.onsubmit = function(event) {
|
option.onsubmit = function(event) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
};
|
};
|
||||||
@ -727,9 +746,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
runs(event, cmds, cbs)
|
runs(event, cmds, cbs)
|
||||||
}
|
}
|
||||||
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
var plugin = Meta(field, (field.Script && field.Script.init || function() {
|
||||||
})(run, field, option, output)||{}, {
|
})(run, field, option, output)||{}, {Inputs: {},
|
||||||
ontoast: page.ontoast,
|
|
||||||
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()
|
||||||
@ -747,13 +764,13 @@ function Plugin(page, pane, field, runs) {
|
|||||||
},
|
},
|
||||||
}}]).last.focus()
|
}}]).last.focus()
|
||||||
},
|
},
|
||||||
Append: function(item, name, value) {
|
Append: shy("添加控件", function(item, name, value) {
|
||||||
kit.Item(plugin.onaction, function(k, cb) {
|
kit.Item(plugin.onaction, function(k, cb) {
|
||||||
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
||||||
cb(event, action, item.type, input.name, item)
|
cb(event, action, item.type, input.name, item)
|
||||||
}: cb)
|
}: cb)
|
||||||
});
|
});
|
||||||
item.value = plugin.onformat(item.init)(item.value)
|
item.value = plugin.onformat(item.init)(item.value)||""
|
||||||
|
|
||||||
!item.title && item.name && (item.title = item.name)
|
!item.title && item.name && (item.title = item.name)
|
||||||
!item.placeholder && item.title && (item.placeholder = item.title)
|
!item.placeholder && item.title && (item.placeholder = item.title)
|
||||||
@ -787,7 +804,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
|
var ui = kit.AppendChild(option, [{view: [item.view||""], list: [{type: "label", inner: item.label||""}, input]}])
|
||||||
var action = Meta(ui[input.name] || {}, item, plugin.onaction, plugin);
|
var action = Meta(ui[input.name] || {}, item, plugin);
|
||||||
|
|
||||||
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
|
(typeof item.imports == "object"? item.imports: typeof item.imports == "string"? [item.imports]: []).forEach(function(imports) {
|
||||||
page.Sync(imports).change(function(value) {
|
page.Sync(imports).change(function(value) {
|
||||||
@ -800,7 +817,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
item.which = plugin.Sync(input.name)
|
item.which = plugin.Sync(input.name)
|
||||||
plugin.Inputs[input.name] = ui[input.name]
|
plugin.Inputs[input.name] = ui[input.name]
|
||||||
return action.target
|
return action.target
|
||||||
},
|
}),
|
||||||
Remove: function() {
|
Remove: function() {
|
||||||
var list = option.querySelectorAll("input.temp")
|
var list = option.querySelectorAll("input.temp")
|
||||||
list.length > 0 && (option.removeChild(list[list.length-1].parentNode))
|
list.length > 0 && (option.removeChild(list[list.length-1].parentNode))
|
||||||
@ -828,12 +845,6 @@ function Plugin(page, pane, field, runs) {
|
|||||||
run(event, cmds, cbs)
|
run(event, cmds, cbs)
|
||||||
}).field.Plugin
|
}).field.Plugin
|
||||||
},
|
},
|
||||||
Last: function() {
|
|
||||||
var list = history.pop()
|
|
||||||
list? (list.target.value = list.value): inputs.map(function(item) {
|
|
||||||
option[item.name].value = item.value
|
|
||||||
}), plugin.Check()
|
|
||||||
},
|
|
||||||
|
|
||||||
getLocation: function(event) {
|
getLocation: function(event) {
|
||||||
var x = parseFloat(option.x.value)
|
var x = parseFloat(option.x.value)
|
||||||
@ -896,11 +907,11 @@ function Plugin(page, pane, field, runs) {
|
|||||||
return kit._call(plugin.Runs, [event])
|
return kit._call(plugin.Runs, [event])
|
||||||
},
|
},
|
||||||
|
|
||||||
Delay: function(time, event, text) {
|
Option: function(key, value) {
|
||||||
page.ontoast(text, "", -1)
|
if (value != undefined) {
|
||||||
return setTimeout(function() {
|
option[key] && (option[key].value = value)
|
||||||
plugin.Runs(event), page.ontoast("")
|
}
|
||||||
}, time)
|
return option[key]? option[key].value: ""
|
||||||
},
|
},
|
||||||
Check: function(target, cb) {
|
Check: function(target, cb) {
|
||||||
plugin.Select(true), kit.Selector(option, ".args", function(item, index, list) {
|
plugin.Select(true), kit.Selector(option, ".args", function(item, index, list) {
|
||||||
@ -909,6 +920,18 @@ function Plugin(page, pane, field, runs) {
|
|||||||
return item
|
return item
|
||||||
}).length == 0 && plugin.Runs(window.event, cb)
|
}).length == 0 && plugin.Runs(window.event, cb)
|
||||||
},
|
},
|
||||||
|
Delay: function(time, event, text) {
|
||||||
|
page.ontoast(text, "", -1)
|
||||||
|
return setTimeout(function() {
|
||||||
|
plugin.Runs(event), page.ontoast("")
|
||||||
|
}, time)
|
||||||
|
},
|
||||||
|
Last: function() {
|
||||||
|
var list = history.pop()
|
||||||
|
list? (list.target.value = list.value): inputs.map(function(item) {
|
||||||
|
option[item.name].value = item.value
|
||||||
|
}), plugin.Check()
|
||||||
|
},
|
||||||
Runs: function(event, cb) {
|
Runs: function(event, cb) {
|
||||||
plugin.Run(event, kit.Selector(option, ".args", function(item, index) {return item.value}), cb)
|
plugin.Run(event, kit.Selector(option, ".args", function(item, index) {return item.value}), cb)
|
||||||
},
|
},
|
||||||
@ -924,14 +947,13 @@ function Plugin(page, pane, field, runs) {
|
|||||||
show = false, page.ontoast("")
|
show = false, page.ontoast("")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
output.innerHTML = ""
|
output.innerHTML = ""
|
||||||
},
|
},
|
||||||
display: function(arg, cb) {
|
display: function(arg, cb) {
|
||||||
deal = arg, plugin.ondaemon[deal||"table"](plugin.msg, cb)
|
plugin.ondaemon[(deal = arg)||"table"](plugin.msg, cb), plugin.show_after(plugin.msg)
|
||||||
plugin.show_after(plugin.msg)
|
|
||||||
},
|
},
|
||||||
|
show_after: function(msg) {},
|
||||||
Download: function() {
|
Download: function() {
|
||||||
var text = kit.Selector(output, "tr", function(tr) {
|
var text = kit.Selector(output, "tr", function(tr) {
|
||||||
return kit.Selector(tr, "td,th", function(td) {
|
return kit.Selector(tr, "td,th", function(td) {
|
||||||
@ -945,13 +967,6 @@ function Plugin(page, pane, field, runs) {
|
|||||||
item.click()
|
item.click()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
show_after: function(msg) {},
|
|
||||||
Option: function(key, value) {
|
|
||||||
if (value != undefined) {
|
|
||||||
option[key] && (option[key].value = value)
|
|
||||||
}
|
|
||||||
return option[key]? option[key].value: ""
|
|
||||||
},
|
|
||||||
upload: function(event) {
|
upload: function(event) {
|
||||||
ctx.Upload({river: meta.river, table: plugin.Option("table")}, option.upload.files[0], function(event, msg) {
|
ctx.Upload({river: meta.river, table: plugin.Option("table")}, option.upload.files[0], function(event, msg) {
|
||||||
kit.OrderTable(kit.AppendTable(kit.AppendChilds(output, "table"), ctx.Table(msg), msg.append))
|
kit.OrderTable(kit.AppendTable(kit.AppendChilds(output, "table"), ctx.Table(msg), msg.append))
|
||||||
@ -960,6 +975,17 @@ function Plugin(page, pane, field, runs) {
|
|||||||
page.ontoast(), page.ontoast("上传进度 "+parseInt(event.loaded*100/event.total)+"%")
|
page.ontoast(), page.ontoast("上传进度 "+parseInt(event.loaded*100/event.total)+"%")
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
exports: JSON.parse(meta.exports||'["",""]'),
|
||||||
|
ontoast: page.ontoast,
|
||||||
|
onreveal: shy("数据菜单", {
|
||||||
|
"下载": "Download",
|
||||||
|
"清空": "clear",
|
||||||
|
"返回": "Last",
|
||||||
|
}, ["下载", "清空", "返回"], function(value, meta, event) {
|
||||||
|
kit._call(plugin, plugin[meta[value]])
|
||||||
|
return true
|
||||||
|
}),
|
||||||
onformat: Wrap(function(which) {
|
onformat: Wrap(function(which) {
|
||||||
var meta = arguments.callee
|
var meta = arguments.callee
|
||||||
return meta[which]||meta["none"]
|
return meta[which]||meta["none"]
|
||||||
@ -967,30 +993,6 @@ function Plugin(page, pane, field, runs) {
|
|||||||
none: function(value) {return value},
|
none: function(value) {return value},
|
||||||
date: function(value) {return kit.format_date(new Date())},
|
date: function(value) {return kit.format_date(new Date())},
|
||||||
}),
|
}),
|
||||||
ondaemon: {
|
|
||||||
inner: function(msg, cb) {
|
|
||||||
output.style.maxWidth = pane.target.clientWidth-20+"px"
|
|
||||||
output.style.maxHeight = pane.target.clientHeight-60+"px"
|
|
||||||
output.innerHTML = "", msg.append? kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
|
|
||||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
|
||||||
}): (output.innerHTML = msg.result.join(""))
|
|
||||||
typeof cb == "function" && cb(msg)
|
|
||||||
},
|
|
||||||
table: function(msg, cb) {
|
|
||||||
output.innerHTML = ""
|
|
||||||
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
|
|
||||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
|
||||||
});
|
|
||||||
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
|
|
||||||
typeof cb == "function" && cb(msg)
|
|
||||||
},
|
|
||||||
editor: function(msg, cb) {
|
|
||||||
(output.innerHTML = "", Editor(run, plugin, option, output, output.clientWidth-40, 400, 10, msg))
|
|
||||||
},
|
|
||||||
canvas: function(msg, cb) {
|
|
||||||
typeof cb == "function" && !cb(msg) || (output.innerHTML = "", Canvas(plugin, option, output, pane.target.clientWidth-45, pane.target.clientHeight-175, 10, msg))
|
|
||||||
},
|
|
||||||
},
|
|
||||||
onexport: {
|
onexport: {
|
||||||
"": function(value, name, line) {
|
"": function(value, name, line) {
|
||||||
return value
|
return value
|
||||||
@ -1020,6 +1022,30 @@ function Plugin(page, pane, field, runs) {
|
|||||||
return option.tip.value + value
|
return option.tip.value + value
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ondaemon: {
|
||||||
|
inner: function(msg, cb) {
|
||||||
|
output.style.maxWidth = pane.target.clientWidth-20+"px"
|
||||||
|
output.style.maxHeight = pane.target.clientHeight-60+"px"
|
||||||
|
output.innerHTML = "", msg.append? kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
|
||||||
|
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
||||||
|
}): (output.innerHTML = msg.result.join(""))
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
},
|
||||||
|
table: function(msg, cb) {
|
||||||
|
output.innerHTML = ""
|
||||||
|
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1]||"", function(event, value, name, line) {
|
||||||
|
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
||||||
|
});
|
||||||
|
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
},
|
||||||
|
editor: function(msg, cb) {
|
||||||
|
(output.innerHTML = "", Editor(run, plugin, option, output, output.clientWidth-40, 400, 10, msg))
|
||||||
|
},
|
||||||
|
canvas: function(msg, cb) {
|
||||||
|
typeof cb == "function" && !cb(msg) || (output.innerHTML = "", Canvas(plugin, option, output, pane.target.clientWidth-45, pane.target.clientHeight-175, 10, msg))
|
||||||
|
},
|
||||||
|
},
|
||||||
onaction: {
|
onaction: {
|
||||||
onfocus: function(event, action, type, name, item) {
|
onfocus: function(event, action, type, name, item) {
|
||||||
plugin.Select(true)
|
plugin.Select(true)
|
||||||
@ -1027,27 +1053,27 @@ function Plugin(page, pane, field, runs) {
|
|||||||
},
|
},
|
||||||
onblur: function(event, action, type, name, item) {
|
onblur: function(event, action, type, name, item) {
|
||||||
item.which.set(action.target.value)
|
item.which.set(action.target.value)
|
||||||
// page.input = undefined
|
|
||||||
},
|
},
|
||||||
onclick: function(event, action, type, name, item) {
|
onclick: function(event, action, type, name, item) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "button":
|
case "button":
|
||||||
// Event入口 2.0
|
// Event入口 2.0
|
||||||
ctx.Event(event, {}, {name: meta.name+"."+name})
|
ctx.Event(event, {}, {name: meta.name+"."+name})
|
||||||
|
kit.Value(action[item.cb], plugin[item.cb], function() {
|
||||||
action[item.cb]? action[item.cb](event, item, option, field):
|
plugin.Check()
|
||||||
plugin[item.cb]? plugin[item.cb](event, item, option, field): plugin.Check()
|
})(event, item, option, field)
|
||||||
break
|
break
|
||||||
case "text":
|
case "text":
|
||||||
if (event.ctrlKey) {
|
event.ctrlKey && (action.target.value = kit.History.get("txt", -1).data.trim())
|
||||||
action.value = kit.History.get("txt", -1).data.trim()
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ondblclick: function(event, action, type, name, item) {
|
ondblclick: function(event, action, type, name, item) {
|
||||||
type == "text" && (action.target.value = kit.History.get("txt", -1).data.trim())
|
type == "text" && (action.target.value = kit.History.get("txt", -1).data.trim())
|
||||||
},
|
},
|
||||||
|
oncontextmenu: function(event, action, type, name, item) {
|
||||||
|
type == "text" && event.stopPropagation()
|
||||||
|
},
|
||||||
onchange: function(event, action, type, name, item) {
|
onchange: function(event, action, type, name, item) {
|
||||||
type == "select" && ctx.Event(event, {}, {name: meta.name+"."+name}) && plugin.Check(item.action == "auto"? undefined: action)
|
type == "select" && ctx.Event(event, {}, {name: meta.name+"."+name}) && plugin.Check(item.action == "auto"? undefined: action)
|
||||||
},
|
},
|
||||||
@ -1123,8 +1149,22 @@ function Plugin(page, pane, field, runs) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
exports: JSON.parse(meta.exports||'["",""]'),
|
onchoice: shy("插件菜单", {
|
||||||
|
"添加": "Clone",
|
||||||
|
"删除": "Delete",
|
||||||
|
"加参": "Appends",
|
||||||
|
"减参": "Remove",
|
||||||
|
}, ["添加", "删除", "加参", "减参"], function(value, meta, event) {
|
||||||
|
kit._call(plugin, plugin[meta[value]])
|
||||||
|
return true
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
field.oncontextmenu = function(event) {
|
||||||
|
page.oncarte(event, plugin.onchoice)
|
||||||
|
}
|
||||||
|
output.oncontextmenu = function(event) {
|
||||||
|
page.oncarte(event, plugin.onreveal)
|
||||||
|
}
|
||||||
|
|
||||||
plugin.which = plugin.Sync("input")
|
plugin.which = plugin.Sync("input")
|
||||||
page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||||
|
@ -4,6 +4,23 @@ Wrap = function(cb, obj) {
|
|||||||
}
|
}
|
||||||
return cb
|
return cb
|
||||||
}
|
}
|
||||||
|
shy = function(help, meta, list, cb) {
|
||||||
|
var index = -1, value = "", type = "string", args = arguments
|
||||||
|
function next(check) {
|
||||||
|
if (++index >= args.length) {return false}
|
||||||
|
if (check && check != typeof args[index]) {index--; return false}
|
||||||
|
return value = args[index], type = typeof value, value
|
||||||
|
}
|
||||||
|
|
||||||
|
var cb = arguments[arguments.length-1] || function() {}
|
||||||
|
cb.help = next("string") || "还没有写"
|
||||||
|
cb.meta = next("object") || {}
|
||||||
|
cb.list = next("object") || {}
|
||||||
|
cb.runs = function() {
|
||||||
|
}
|
||||||
|
return cb
|
||||||
|
}
|
||||||
|
|
||||||
kit = toolkit = {__proto__: document,
|
kit = toolkit = {__proto__: document,
|
||||||
meta: function(cb, obj) {
|
meta: function(cb, obj) {
|
||||||
for (var k in obj) {
|
for (var k in obj) {
|
||||||
@ -397,7 +414,7 @@ kit = toolkit = {__proto__: document,
|
|||||||
})
|
})
|
||||||
return kit.AppendChild(parent, result)
|
return kit.AppendChild(parent, result)
|
||||||
},
|
},
|
||||||
AppendTable: function(table, data, fields, cb) {
|
AppendTable: function(table, data, fields, cb, cbs) {
|
||||||
if (!data || !fields) {
|
if (!data || !fields) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -411,16 +428,18 @@ kit = toolkit = {__proto__: document,
|
|||||||
tr.Meta = row
|
tr.Meta = row
|
||||||
fields.forEach(function(key, j) {
|
fields.forEach(function(key, j) {
|
||||||
var td = kit.AppendChild(tr, "td", kit.Color(row[key]))
|
var td = kit.AppendChild(tr, "td", kit.Color(row[key]))
|
||||||
|
if (key == "when") {td.className = "when"}
|
||||||
if (row[key].startsWith("http")) {
|
if (row[key].startsWith("http")) {
|
||||||
td.innerHTML = "<a href='"+row[key]+"' target='_blank'>"+row[key]+"</a>"
|
td.innerHTML = "<a href='"+row[key]+"' target='_blank'>"+row[key]+"</a>"
|
||||||
}
|
}
|
||||||
if (key == "when") {td.className = "when"}
|
cb && (td.onclick = function(event) {
|
||||||
|
kit._call(cb, [row[key], key, row, i, tr, event])
|
||||||
if (typeof cb == "function") {
|
})
|
||||||
td.onclick = function(event) {
|
cbs && (td.oncontextmenu = function(event) {
|
||||||
cb(row[key], key, row, i, tr, event)
|
kit._call(cbs, [row[key], key, row, i, tr, event])
|
||||||
}
|
event.stopPropagation()
|
||||||
}
|
event.preventDefault()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return table
|
return table
|
||||||
@ -639,7 +658,8 @@ kit = toolkit = {__proto__: document,
|
|||||||
Item: function(obj, cb) {
|
Item: function(obj, cb) {
|
||||||
var list = []
|
var list = []
|
||||||
for (var k in obj) {
|
for (var k in obj) {
|
||||||
list.push(typeof cb == "function"? cb(k, obj[k]): k)
|
var v = typeof cb == "function"? cb(k, obj[k]): k
|
||||||
|
v != undefined && list.push(v)
|
||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
},
|
},
|
||||||
@ -664,8 +684,17 @@ kit = toolkit = {__proto__: document,
|
|||||||
}, kit.Value(interval, 150))
|
}, kit.Value(interval, 150))
|
||||||
},
|
},
|
||||||
// 数据类型转换
|
// 数据类型转换
|
||||||
Value: function(obj, value) {
|
Value: function() {
|
||||||
return obj === undefined || obj === null || obj === "" ? value: obj
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
switch (arguments[i]) {
|
||||||
|
case undefined:
|
||||||
|
case null:
|
||||||
|
case "":
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return arguments[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isSpace: function(c) {
|
isSpace: function(c) {
|
||||||
return c == " " || c == "Enter"
|
return c == " " || c == "Enter"
|
||||||
@ -773,21 +802,22 @@ kit = toolkit = {__proto__: document,
|
|||||||
obj.style.width = width+"px"
|
obj.style.width = width+"px"
|
||||||
obj.style.height = height+"px"
|
obj.style.height = height+"px"
|
||||||
},
|
},
|
||||||
_call: function(cb, arg) {
|
type: function(obj, type) {
|
||||||
var res
|
if (type == undefined) {return typeof obj}
|
||||||
if (typeof cb != "function") {return}
|
return typeof obj == type? obj: null
|
||||||
|
},
|
||||||
|
_call: function() {// obj, cb, arg
|
||||||
|
var index = 0, obj, cb, arg;
|
||||||
|
(obj = kit.type(arguments[index], "object")) && index++
|
||||||
|
(cb = kit.type(arguments[index], "function")) && index++
|
||||||
|
(arg = kit.type(arguments[index], "object")) && index++
|
||||||
|
|
||||||
switch (arg.length) {
|
arg = arg || []
|
||||||
case 0: res = cb(); break
|
while (index < arguments.length) {
|
||||||
case 1: res = cb(arg[0]); break
|
arg.push(arguments[index++])
|
||||||
case 2: res = cb(arg[0], arg[1]); break
|
|
||||||
case 3: res = cb(arg[0], arg[1], arg[2]); break
|
|
||||||
case 4: res = cb(arg[0], arg[1], arg[2], arg[3]); break
|
|
||||||
case 5: res = cb(arg[0], arg[1], arg[2], arg[3], arg[4]); break
|
|
||||||
case 6: res = cb(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); break
|
|
||||||
case 7: res = cb(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]); break
|
|
||||||
}
|
}
|
||||||
return res || true
|
cb = cb || function(){}
|
||||||
|
return cb.apply(obj||window, arg||[])
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<fieldset class="carte"><legend></legend>
|
||||||
|
<form class="option" data-names="carte"></form>
|
||||||
|
<div class="output"></div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="toast"><legend></legend>
|
<fieldset class="toast"><legend></legend>
|
||||||
<form class="option" data-names="toast"></form>
|
<form class="option" data-names="toast"></form>
|
||||||
<div class="output"></div>
|
<div class="output"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user