mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add Jshy
This commit is contained in:
parent
9b6e049191
commit
f6f22b1bc2
@ -72,8 +72,12 @@ Page({
|
|||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
|
case " ":
|
||||||
|
page.footer.Pane.Select()
|
||||||
|
break
|
||||||
case "Escape":
|
case "Escape":
|
||||||
page.dialog && page.dialog.Pane.Show()
|
page.dialog && page.dialog.Pane.Show()
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@ -157,8 +161,8 @@ Page({
|
|||||||
field.Pane.Show()
|
field.Pane.Show()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Show: function() {
|
Show: function() {var pane = field.Pane
|
||||||
this.Dialog() && (this.Clear("good"), this.Run([], this.Append))
|
pane.Dialog() && (pane.Clear("good"), pane.Run([], pane.Append))
|
||||||
},
|
},
|
||||||
Action: {
|
Action: {
|
||||||
"取消": function(event) {
|
"取消": function(event) {
|
||||||
@ -180,8 +184,8 @@ Page({
|
|||||||
},
|
},
|
||||||
initRiver: function(page, field, option, output) {
|
initRiver: function(page, field, option, output) {
|
||||||
return {
|
return {
|
||||||
Show: function() {
|
Show: function() {var pane = field.Pane
|
||||||
this.Update([], "text", ["nick", "count"], "key", ctx.Search("river")||true)
|
output.innerHTML = "", pane.Update([], "text", ["nick", "count"], "key", ctx.Search("river")||true)
|
||||||
},
|
},
|
||||||
Action: {
|
Action: {
|
||||||
"创建": function(event) {
|
"创建": function(event) {
|
||||||
@ -196,7 +200,7 @@ Page({
|
|||||||
output.DisplayUser = true
|
output.DisplayUser = true
|
||||||
output.DisplayTime = true
|
output.DisplayTime = true
|
||||||
return {
|
return {
|
||||||
Send: function(type, text, cb) {var pane = this
|
Send: function(type, text, cb) {var pane = field.Pane
|
||||||
pane.Run([river, "flow", type, text], function(msg) {
|
pane.Run([river, "flow", type, text], function(msg) {
|
||||||
pane.Show(), typeof cb == "function" && cb(msg)
|
pane.Show(), typeof cb == "function" && cb(msg)
|
||||||
})
|
})
|
||||||
@ -204,7 +208,7 @@ Page({
|
|||||||
Stop: function() {
|
Stop: function() {
|
||||||
return field.style.display == "none"
|
return field.style.display == "none"
|
||||||
},
|
},
|
||||||
Show: function(i) {var pane = this
|
Show: function(i) {var pane = field.Pane
|
||||||
field.Pane.Back(river, output)
|
field.Pane.Back(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]
|
||||||
@ -250,6 +254,20 @@ Page({
|
|||||||
var river = "", storm = 0, input = "", share = ""
|
var river = "", storm = 0, input = "", share = ""
|
||||||
output.DisplayRaw = true
|
output.DisplayRaw = true
|
||||||
return {
|
return {
|
||||||
|
Tutor: function() {var pane = field.Pane
|
||||||
|
var event = window.event
|
||||||
|
function loop(list, index) {
|
||||||
|
if (index >= list.length) {return}
|
||||||
|
kit.Log(index, list[index])
|
||||||
|
pane.Core(event, {}, ["_cmd", list[index]])
|
||||||
|
setTimeout(function() {loop(list, index+1)}, 1000)
|
||||||
|
}
|
||||||
|
loop([
|
||||||
|
"聊天", "help", "最高", "最大", "聊天",
|
||||||
|
"工作", "串行", "清空", "并行", "help storm", "help storm list", "help action", "help action list",
|
||||||
|
"聊天", "help target", "help target list",
|
||||||
|
], 0)
|
||||||
|
},
|
||||||
Core: function(event, line, args, cbs) {
|
Core: function(event, line, args, cbs) {
|
||||||
var plugin = event.Plugin || {}, engine = {
|
var plugin = event.Plugin || {}, engine = {
|
||||||
share: function(args) {
|
share: function(args) {
|
||||||
@ -258,6 +276,42 @@ Page({
|
|||||||
]}))
|
]}))
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
|
echo: function(one, two) {
|
||||||
|
kit.Log(one, two)
|
||||||
|
},
|
||||||
|
_split: function(str) {return str.trim().split(" ")},
|
||||||
|
help: function() {
|
||||||
|
var args = kit.List(arguments)
|
||||||
|
if (args.length > 1 && page[args[0]] && page[args[0]].Pane[args[1]]) {
|
||||||
|
return kit._call(page[args[0]].Pane[args[1]].Plugin.Help, args.slice(2))
|
||||||
|
}
|
||||||
|
if (args.length > 0 && page[args[0]]) {
|
||||||
|
return kit._call(page[args[0]].Pane.Help, args.slice(1))
|
||||||
|
}
|
||||||
|
return kit._call(page.Help, args)
|
||||||
|
},
|
||||||
|
_cmd: function(arg) {
|
||||||
|
var args = engine._split(arg[1]);
|
||||||
|
if (typeof engine[args[0]] == "function") {
|
||||||
|
return kit._call(engine[args[0]], args.slice(1))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page.plugin && page.plugin.Plugin.Jshy(event, args)) {return true}
|
||||||
|
if (page.dialog && page.dialog.Pane.Jshy(event, args)) {return true}
|
||||||
|
if (page.pane && page.pane.Pane.Jshy(event, args)) {return true}
|
||||||
|
if (page && page.Jshy(event, args)) {return true}
|
||||||
|
|
||||||
|
if (page.plugin) {
|
||||||
|
if (args.length > 1) {
|
||||||
|
return kit._call(page.plugin.Plugin.Run, [window.event].concat(args.slice(1)))
|
||||||
|
} else {
|
||||||
|
return kit._call(page.plugin.Plugin.Runs, [window.event])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kit.Log("not find", arg[1])
|
||||||
|
return true
|
||||||
|
},
|
||||||
_msg: function(msg) {
|
_msg: function(msg) {
|
||||||
if (msg) {
|
if (msg) {
|
||||||
var text = plugin? plugin.Reveal(msg): ""
|
var text = plugin? plugin.Reveal(msg): ""
|
||||||
@ -276,16 +330,16 @@ Page({
|
|||||||
if (args.length > 0 && engine[args[0]] && engine[args[0]](args)) {return}
|
if (args.length > 0 && engine[args[0]] && engine[args[0]](args)) {return}
|
||||||
event.shiftKey? engine._msg(): engine._run()
|
event.shiftKey? engine._msg(): engine._run()
|
||||||
},
|
},
|
||||||
Show: function() {var pane = this
|
Show: function() {var pane = field.Pane
|
||||||
if (field.Pane.Back(river+storm, output)) {return}
|
if (field.Pane.Back(river+storm, output)) {return}
|
||||||
|
|
||||||
this.Clear(), this.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)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Layout: function(name) {
|
Layout: function(name) {var pane = field.Pane
|
||||||
var layout = field.querySelector("select.layout")
|
var layout = field.querySelector("select.layout")
|
||||||
name && this.Action[layout.value = name](window.event, layout.value)
|
name && pane.Action[layout.value = name](window.event, layout.value)
|
||||||
return layout.value
|
return layout.value
|
||||||
},
|
},
|
||||||
Listen: {
|
Listen: {
|
||||||
@ -385,9 +439,9 @@ Page({
|
|||||||
var prev = output.querySelector("div.item.select").previousSibling
|
var prev = output.querySelector("div.item.select").previousSibling
|
||||||
prev? prev.click(): output.lastChild.click()
|
prev? prev.click(): output.lastChild.click()
|
||||||
},
|
},
|
||||||
Show: function(which) {
|
Show: function(which) {var pane = field.Pane
|
||||||
this.which.get("") == which && page.action.Pane.Show()
|
pane.which.get("") == which && page.action.Pane.Show()
|
||||||
output.innerHTML = "", this.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
|
output.innerHTML = "", pane.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
|
||||||
},
|
},
|
||||||
Listen: {
|
Listen: {
|
||||||
river: function(value, old) {
|
river: function(value, old) {
|
||||||
@ -518,5 +572,7 @@ Page({
|
|||||||
page.onaction[item] && page.onaction[item](event, item, value)
|
page.onaction[item] && page.onaction[item](event, item, value)
|
||||||
})
|
})
|
||||||
page.river.Pane.Show()
|
page.river.Pane.Show()
|
||||||
|
page.pane = page.action
|
||||||
|
page.plugin = kit.Selector(page.action, "fieldset")[0]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -6,6 +6,7 @@ html, body {
|
|||||||
margin:0px;
|
margin:0px;
|
||||||
}
|
}
|
||||||
fieldset {
|
fieldset {
|
||||||
|
position:relative;
|
||||||
background-color:#d8d8d8;
|
background-color:#d8d8d8;
|
||||||
padding:0px;
|
padding:0px;
|
||||||
min-width:10px;
|
min-width:10px;
|
||||||
@ -16,6 +17,20 @@ legend {
|
|||||||
margin-left:10px;
|
margin-left:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset>div.Help {
|
||||||
|
position:absolute;
|
||||||
|
left:0px;
|
||||||
|
top:0px;
|
||||||
|
width:calc(100% - 4px);
|
||||||
|
height:calc(100% - 4px);
|
||||||
|
}
|
||||||
|
fieldset>div.Help>div{
|
||||||
|
border:solid 2px red;
|
||||||
|
background-color:cyan;
|
||||||
|
color:blue;
|
||||||
|
opacity:0.7;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
fieldset>form.option div {
|
fieldset>form.option div {
|
||||||
margin-right:6px;
|
margin-right:6px;
|
||||||
float:left;
|
float:left;
|
||||||
@ -164,6 +179,13 @@ fieldset.Footer {
|
|||||||
fieldset.Footer>div.output div.title {
|
fieldset.Footer>div.output div.title {
|
||||||
float:left;
|
float:left;
|
||||||
}
|
}
|
||||||
|
fieldset.Footer>div.output div.magic {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
fieldset.Footer>div.output div.magic>input {
|
||||||
|
background-color:black;
|
||||||
|
color:lightgreen;;
|
||||||
|
}
|
||||||
fieldset.Footer>div.output div.state {
|
fieldset.Footer>div.output div.state {
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
|
@ -317,6 +317,9 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
onscroll: function(event, target, action) {
|
onscroll: function(event, target, action) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
|
case " ":
|
||||||
|
page.footer.Pane.Select()
|
||||||
|
break
|
||||||
case "h":
|
case "h":
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
target.scrollBy(-conf.scroll_x*10, 0)
|
target.scrollBy(-conf.scroll_x*10, 0)
|
||||||
@ -360,6 +363,26 @@ function Page(page) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Help: function(pane, type, action) {
|
||||||
|
if (pane == undefined) {
|
||||||
|
kit.Selector(document.body, "body>fieldset", function(field) {
|
||||||
|
field.Pane.Help()
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
page[pane].Pane.Help(type, action)
|
||||||
|
},
|
||||||
|
Jshy: function(event, args) {
|
||||||
|
if (page[args[0]] && page[args[0]].type == "fieldset") {
|
||||||
|
if (args.length > 1) {
|
||||||
|
return page[args[0]].Pane.Jshy(event, args.slice(1))
|
||||||
|
} else {
|
||||||
|
return page[args[0]].Pane.Show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return typeof page[args[0]] == "function" && kit._call(page[args[0]], args.slice(1))
|
||||||
|
},
|
||||||
|
|
||||||
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"]}, {type: "br"},
|
||||||
@ -376,7 +399,7 @@ function Page(page) {
|
|||||||
])
|
])
|
||||||
return {
|
return {
|
||||||
Login: function(username, password, cb) {
|
Login: function(username, password, cb) {
|
||||||
this.Run([username, password], function(msg) {cb(msg.result && msg.result[0] || "")})
|
field.Pane.Run([username, password], function(msg) {cb(msg.result && msg.result[0] || "")})
|
||||||
},
|
},
|
||||||
Exit: function() {ctx.Cookie("sessid", ""), kit.reload()},
|
Exit: function() {ctx.Cookie("sessid", ""), kit.reload()},
|
||||||
}
|
}
|
||||||
@ -386,10 +409,10 @@ function Page(page) {
|
|||||||
field.onclick = function(event) {page.pane && page.pane.scrollTo(0,0)}
|
field.onclick = function(event) {page.pane && page.pane.scrollTo(0,0)}
|
||||||
return {
|
return {
|
||||||
Order: function(value, order, cbs) {
|
Order: function(value, order, cbs) {
|
||||||
state = value, list = order, cb = cbs || cb, this.Show()
|
state = value, list = order, cb = cbs || cb, field.Pane.Show()
|
||||||
},
|
},
|
||||||
State: function(name, value) {
|
State: function(name, value) {
|
||||||
value != undefined && (state[name] = value, this.Show())
|
value != undefined && (state[name] = value, field.Pane.Show())
|
||||||
return name == undefined? state: state[name]
|
return name == undefined? state: state[name]
|
||||||
},
|
},
|
||||||
Show: function() {
|
Show: function() {
|
||||||
@ -406,22 +429,55 @@ function Page(page) {
|
|||||||
},
|
},
|
||||||
initFooter: function(page, field, option, output) {
|
initFooter: 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) {page.pane.scrollTo(0,page.pane.scrollHeight)}
|
field.onclick = function(event) {page.pane && page.pane.scrollTo(0,page.pane.scrollHeight)}
|
||||||
|
var ui, w = 0
|
||||||
return {
|
return {
|
||||||
|
Select: function() {
|
||||||
|
ui.magic.focus()
|
||||||
|
},
|
||||||
Order: function(value, order, cbs) {
|
Order: function(value, order, cbs) {
|
||||||
state = value, list = order, cb = cbs || cb, this.Show()
|
state = value, list = order, cb = cbs || cb, field.Pane.Show()
|
||||||
},
|
},
|
||||||
State: function(name, value) {
|
State: function(name, value) {
|
||||||
value != undefined && (state[name] = value, this.Show())
|
value != undefined && (state[name] = value, field.Pane.Show())
|
||||||
return name == undefined? state: state[name]
|
return name == undefined? state: state[name]
|
||||||
},
|
},
|
||||||
|
Size: function(width, height) {
|
||||||
|
kit.size(field, width, height)
|
||||||
|
ui && (w = width - ui.first.clientWidth - ui.last.clientWidth - 20) && kit.size(ui.magic, w, height-6)
|
||||||
|
},
|
||||||
Show: function() {
|
Show: function() {
|
||||||
output.innerHTML = "", kit.AppendChild(output, [
|
output.innerHTML = "", ui = kit.AppendChild(output, [
|
||||||
{"view": ["title", "div", "<a href='mailto:shylinux@163.com'>shylinux@163.com</>"]},
|
{"view": ["title", "div", "<a href='mailto:shylinux@163.com'>shylinux@163.com</>"]},
|
||||||
|
{"view": ["magic"], style: {"margin-top": "-4px"}, list: [{input: ["magic", function(event) {
|
||||||
|
if (event.type != "keydown") {return}
|
||||||
|
|
||||||
|
switch (event.key) {
|
||||||
|
case " ":
|
||||||
|
return
|
||||||
|
case "Enter":
|
||||||
|
page.action.Pane.Core(event, {}, ["_cmd", event.target.value]), event.target.value = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
page.oninput(event, function(event) {
|
||||||
|
switch (event.key) {
|
||||||
|
case "j":
|
||||||
|
page.action.Pane.Core(event, {}, ["_cmd", event.target.value]), event.target.value = ""
|
||||||
|
break
|
||||||
|
case "Enter":
|
||||||
|
kit.Log(event.target.value)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return true
|
||||||
|
|
||||||
|
}], style: {width: w, "margin-top": "-2px", "font-size": "16px"}}]},
|
||||||
{"view": ["state"], list: list.map(function(item) {return {text: [item+":"+state[item], "div"], click: function(item) {
|
{"view": ["state"], list: list.map(function(item) {return {text: [item+":"+state[item], "div"], click: function(item) {
|
||||||
cb(event, item, state[item])
|
cb(event, item, state[item])
|
||||||
}}})},
|
}}})},
|
||||||
])
|
])
|
||||||
|
field.Pane.Size(field.clientWidth, field.clientHeight)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -468,6 +524,46 @@ function Pane(page, field) {
|
|||||||
output.innerHTML = "", list = [], last = -1
|
output.innerHTML = "", list = [], last = -1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Help: function(type, action) {
|
||||||
|
if (kit.Selector(field, "div.Help", function(help) {
|
||||||
|
field.removeChild(help)
|
||||||
|
return help
|
||||||
|
}).length>0 || action == "hide") {return}
|
||||||
|
|
||||||
|
var text = [], delay = 30000
|
||||||
|
switch (type) {
|
||||||
|
case "name":
|
||||||
|
case undefined:
|
||||||
|
text = [name]
|
||||||
|
break
|
||||||
|
case "list":
|
||||||
|
var list = []
|
||||||
|
for (var k in pane) {list.push(k)}
|
||||||
|
list.sort(), text = text.concat(list.map(function(item) {return "func: "+item+"\n"}))
|
||||||
|
|
||||||
|
var list = []
|
||||||
|
for (var k in pane.Action) {list.push(k)}
|
||||||
|
list.sort(), text = text.concat(list.map(function(item) {return "action: "+item+"\n"}))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
kit.AppendChild(field, [{view: ["Help"], list: [{text: [text.join(""), "div"]}]}])
|
||||||
|
setTimeout(function() {pane.Help("", "hide")}, delay)
|
||||||
|
},
|
||||||
|
Jshy: function(event, args) {
|
||||||
|
if (pane[args[0]] && pane[args[0]].type == "fieldset") {
|
||||||
|
if (args.length > 1) {
|
||||||
|
return kit._call(pane[args[0]].Plugin.Run, [event].concat(args.slice(1)))
|
||||||
|
} else {
|
||||||
|
return kit._call(pane[args[0]].Plugin.Runs, [event])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof pane.Action[args[0]] == "function") {
|
||||||
|
return kit._call(pane.Action[args[0]], [event, args[0]])
|
||||||
|
}
|
||||||
|
return typeof pane[args[0]] == "function" && kit._call(pane[args[0]], args.slice(1))
|
||||||
|
},
|
||||||
|
|
||||||
Tickers: function(time, cmds, cb) {
|
Tickers: function(time, cmds, cb) {
|
||||||
pane.Ticker(time, cmds, function(msg) {
|
pane.Ticker(time, cmds, function(msg) {
|
||||||
ctx.Table(msg, function(line, index) {
|
ctx.Table(msg, function(line, index) {
|
||||||
@ -487,12 +583,12 @@ function Pane(page, field) {
|
|||||||
Runs: function(cmds, cb) {
|
Runs: function(cmds, cb) {
|
||||||
pane.Run(cmds, function(msg) {
|
pane.Run(cmds, function(msg) {
|
||||||
ctx.Table(msg, function(line, index) {
|
ctx.Table(msg, function(line, index) {
|
||||||
(cb||this.ondaemon)(line, index, msg)
|
(cb||pane.ondaemon)(line, index, msg)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Run: function(cmds, cb) {
|
Run: function(cmds, cb) {
|
||||||
ctx.Run(page, option.dataset, cmds, cb||this.ondaemon)
|
ctx.Run(page, option.dataset, cmds, cb||pane.ondaemon)
|
||||||
},
|
},
|
||||||
|
|
||||||
Size: function(width, height) {
|
Size: function(width, height) {
|
||||||
@ -599,7 +695,33 @@ function Plugin(page, pane, field, run) {
|
|||||||
return JSON.stringify(field.Meta)
|
return JSON.stringify(field.Meta)
|
||||||
},
|
},
|
||||||
Clone: function() {
|
Clone: function() {
|
||||||
return pane.Append("field", {text: plugin.Format()}, [], run).field.Plugin
|
return pane.Append("field", {text: plugin.Format()}, [], "", function(line, index, event, cmds, cbs) {
|
||||||
|
run(event, cmds, cbs)
|
||||||
|
}).field.Plugin
|
||||||
|
},
|
||||||
|
|
||||||
|
Help: function(type, action) {
|
||||||
|
if (kit.Selector(field, "div.Help", function(help) {
|
||||||
|
field.removeChild(help)
|
||||||
|
return help
|
||||||
|
}).length>0 || action == "hide") {return}
|
||||||
|
|
||||||
|
var text = [], delay = 30000
|
||||||
|
switch (type) {
|
||||||
|
case "name":
|
||||||
|
case undefined:
|
||||||
|
text = [meta.name]
|
||||||
|
break
|
||||||
|
case "help":
|
||||||
|
text = [meta.help]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
kit.AppendChild(field, [{view: ["Help"], list: [{text: [text.join(""), "div"]}]}])
|
||||||
|
setTimeout(function() {plugin.Help("", "hide")}, delay)
|
||||||
|
},
|
||||||
|
Jshy: function(event, args) {
|
||||||
|
return typeof plugin[args[0]] == "function" && kit._call(plugin[args[0]], args.slice(1))
|
||||||
},
|
},
|
||||||
|
|
||||||
Delay: function(time, event, text) {
|
Delay: function(time, event, text) {
|
||||||
@ -610,11 +732,12 @@ function Plugin(page, pane, field, run) {
|
|||||||
},
|
},
|
||||||
Check: function(target, cb) {
|
Check: function(target, cb) {
|
||||||
option.querySelectorAll(".args").forEach(function(item, index, list) {
|
option.querySelectorAll(".args").forEach(function(item, index, list) {
|
||||||
item == target && (index == list.length-1? plugin.Runs(event, cb): page.plugin == field && list[index+1].focus())
|
target == undefined && index == list.length-1 && plugin.Runs(window.event, cb)
|
||||||
|
item == target && (index == list.length-1? plugin.Runs(window.event, cb): page.plugin == field && list[index+1].focus())
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Runs: function(event, cb) {
|
Runs: function(event, cb) {
|
||||||
this.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)
|
||||||
},
|
},
|
||||||
Run: function(event, args, cb) {
|
Run: function(event, args, cb) {
|
||||||
var show = true
|
var show = true
|
||||||
@ -655,11 +778,12 @@ function Plugin(page, pane, field, run) {
|
|||||||
return value.split("/")[0]
|
return value.split("/")[0]
|
||||||
},
|
},
|
||||||
you: function(value, name, line) {
|
you: function(value, name, line) {
|
||||||
window.event.Plugin = plugin
|
var event = window.event
|
||||||
|
event.Plugin = plugin
|
||||||
line.you && name == "status" && (line.status == "start"? function() {
|
line.you && name == "status" && (line.status == "start"? function() {
|
||||||
plugin.Delay(3000, window.event, line.you+" stop...") && field.Run(window.event, [line.you, "stop"])
|
plugin.Delay(3000, event, line.you+" stop...") && field.Run(event, [line.you, "stop"])
|
||||||
}(): field.Run(window.event, [line.you], function(msg) {
|
}(): field.Run(event, [line.you], function(msg) {
|
||||||
plugin.Delay(3000, window.event, line.you+" start...")
|
plugin.Delay(3000, event, line.you+" start...")
|
||||||
}))
|
}))
|
||||||
return name == "status" || line.status == "stop" ? undefined: line.you
|
return name == "status" || line.status == "stop" ? undefined: line.you
|
||||||
},
|
},
|
||||||
@ -756,11 +880,12 @@ function Plugin(page, pane, field, run) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
var meta = field.Meta
|
var meta = field.Meta
|
||||||
|
var name = meta.name
|
||||||
var args = meta.args || []
|
var args = meta.args || []
|
||||||
var display = JSON.parse(meta.display||'{}')
|
var display = JSON.parse(meta.display||'{}')
|
||||||
var exports = JSON.parse(meta.exports||'["",""]')
|
var exports = JSON.parse(meta.exports||'["",""]')
|
||||||
JSON.parse(meta.inputs || "[]").map(plugin.Append)
|
JSON.parse(meta.inputs || "[]").map(plugin.Append)
|
||||||
return page[field.id] = pane[field.id] = field, field.Plugin = plugin
|
return page[field.id] = pane[field.id] = pane[name] = field, field.Plugin = plugin
|
||||||
}
|
}
|
||||||
function Editor(plugin, option, output, width, height, space, msg) {
|
function Editor(plugin, option, output, width, height, space, msg) {
|
||||||
exports = ["dir", "path", "dir"]
|
exports = ["dir", "path", "dir"]
|
||||||
|
@ -571,6 +571,9 @@ kit = toolkit = {
|
|||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
distance: function(x0, y0, x1, y1) {
|
||||||
|
return Math.sqrt(Math.pow(x1-x0, 2)+Math.pow(y1-y0, 2))
|
||||||
|
},
|
||||||
number: function(d, n) {
|
number: function(d, n) {
|
||||||
var result = []
|
var result = []
|
||||||
while (d>0) {
|
while (d>0) {
|
||||||
@ -585,17 +588,6 @@ kit = toolkit = {
|
|||||||
result.reverse()
|
result.reverse()
|
||||||
return result.join("")
|
return result.join("")
|
||||||
},
|
},
|
||||||
time: function(t, fmt) {
|
|
||||||
var now = t? new Date(t): new Date()
|
|
||||||
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
|
||||||
fmt = fmt.replace("%y", now.getFullYear())
|
|
||||||
fmt = fmt.replace("%m", kit.number(now.getMonth()+1, 2))
|
|
||||||
fmt = fmt.replace("%d", kit.number(now.getDate(), 2))
|
|
||||||
fmt = fmt.replace("%H", kit.number(now.getHours(), 2))
|
|
||||||
fmt = fmt.replace("%M", kit.number(now.getMinutes(), 2))
|
|
||||||
fmt = fmt.replace("%S", kit.number(now.getSeconds(), 2))
|
|
||||||
return fmt
|
|
||||||
},
|
|
||||||
right: function(arg) {
|
right: function(arg) {
|
||||||
if (arg == "true") {
|
if (arg == "true") {
|
||||||
return true
|
return true
|
||||||
@ -608,6 +600,17 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
time: function(t, fmt) {
|
||||||
|
var now = t? new Date(t): new Date()
|
||||||
|
fmt = fmt || "%y-%m-%d %H:%M:%S"
|
||||||
|
fmt = fmt.replace("%y", now.getFullYear())
|
||||||
|
fmt = fmt.replace("%m", kit.number(now.getMonth()+1, 2))
|
||||||
|
fmt = fmt.replace("%d", kit.number(now.getDate(), 2))
|
||||||
|
fmt = fmt.replace("%H", kit.number(now.getHours(), 2))
|
||||||
|
fmt = fmt.replace("%M", kit.number(now.getMinutes(), 2))
|
||||||
|
fmt = fmt.replace("%S", kit.number(now.getSeconds(), 2))
|
||||||
|
return fmt
|
||||||
|
},
|
||||||
format_date: function(arg) {
|
format_date: function(arg) {
|
||||||
var date = arg.getDate()
|
var date = arg.getDate()
|
||||||
if (date < 10) {
|
if (date < 10) {
|
||||||
@ -631,6 +634,24 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
return arg.getFullYear()+"-"+month+"-"+date+" "+hour+":"+minute+":"+second
|
return arg.getFullYear()+"-"+month+"-"+date+" "+hour+":"+minute+":"+second
|
||||||
},
|
},
|
||||||
|
size: function(obj, width, height) {
|
||||||
|
obj.style.width = width+"px"
|
||||||
|
obj.style.height = height+"px"
|
||||||
|
},
|
||||||
|
_call: function(cb, arg) {
|
||||||
|
switch (arg.length) {
|
||||||
|
case 0: cb(); break
|
||||||
|
case 1: cb(arg[0]); break
|
||||||
|
case 2: cb(arg[0], arg[1]); break
|
||||||
|
case 3: cb(arg[0], arg[1], arg[2]); break
|
||||||
|
case 4: cb(arg[0], arg[1], arg[2], arg[3]); break
|
||||||
|
case 5: cb(arg[0], arg[1], arg[2], arg[3], arg[4]); break
|
||||||
|
case 6: cb(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); break
|
||||||
|
case 7: cb(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]); break
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
OrderForm: function(page, field, option, append, result) {
|
OrderForm: function(page, field, option, append, result) {
|
||||||
if (!option) {return}
|
if (!option) {return}
|
||||||
option.ondaemon = option.ondaemon || function(msg) {
|
option.ondaemon = option.ondaemon || function(msg) {
|
||||||
@ -697,8 +718,5 @@ kit = toolkit = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
distance: function(x0, y0, x1, y1) {
|
|
||||||
return Math.sqrt(Math.pow(x1-x0, 2)+Math.pow(y1-y0, 2))
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user