mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt frame.js
This commit is contained in:
parent
e3c602f4e1
commit
7a247ed56b
487
frame.js
487
frame.js
@ -2,50 +2,123 @@
|
|||||||
// FMS: a fieldset manager system
|
// FMS: a fieldset manager system
|
||||||
|
|
||||||
Volcanos("onengine", { _init: function(can, meta, list, cb, target) {
|
Volcanos("onengine", { _init: function(can, meta, list, cb, target) {
|
||||||
can.run = function(event, cmds, cb) {
|
|
||||||
return (can.onengine[cmds[0]]||can.onengine[meta.main.engine])(event, can, can.request(event), can, cmds, cb)
|
|
||||||
}
|
|
||||||
can.core.Next(meta.panes, function(item, next) {
|
can.core.Next(meta.panes, function(item, next) {
|
||||||
can.onappend._init(can, item, meta.libs.concat(item.list), function(pane) {
|
can.onappend._init(can, item, meta.libs.concat(item.list), function(pane) { pane.Conf(item)
|
||||||
pane.Conf(item), pane.run = function(event, cmds, cb) {
|
pane.run = function(event, cmds, cb) {
|
||||||
return (can.onengine[cmds[0]]||can.onengine[meta.main.engine])(event, can, pane.request(event), pane, cmds, cb)
|
return (can.onengine[cmds[0]]||can.onengine[meta.main.engine])(event, can, pane.request(event), pane, cmds, cb)
|
||||||
}, can[item.name] = pane, next()
|
}, can[item.name] = pane, next()
|
||||||
}, can._target)
|
}, target)
|
||||||
}, function() { can.onlayout._init(can, meta, list, function() {
|
}, function() {
|
||||||
can.require(meta.main.list, function(can) {
|
can.onlayout._init(can, meta, list, function() {
|
||||||
function getAction() {}
|
can.require(meta.main.list, function(can) {
|
||||||
function getStorm(storm) { can.core.Item(storm, function(key, value) {
|
can.onkeypop._init(can)
|
||||||
value._link? can.require([value._link], function(can) {
|
can.onengine._topic(can)
|
||||||
}, function(can, name, sub) {
|
can.onengine._daemon(can, can.user.title())
|
||||||
getAction(value.action = sub.action)
|
var pane = can[meta.main.name], msg = can.request({})
|
||||||
return true
|
pane.onaction && pane.onaction._init(pane, msg, msg.option||[], cb, target)
|
||||||
}): getAction(value.action)
|
})
|
||||||
}) }
|
}, target)
|
||||||
function getRiver(river) { can.core.Item(river, function(key, value) {
|
})
|
||||||
value._link? can.require([value._link], function(can) {
|
},
|
||||||
}, function(can, name, sub) {
|
_merge: function(can, sub) {
|
||||||
getStorm(value.storm = sub.storm)
|
can.core.Item(sub, function(key, value) {
|
||||||
return true
|
if (sub.hasOwnProperty(key)) { can.onengine[key] = value }
|
||||||
}): getStorm(value.storm)
|
})
|
||||||
}) }
|
return true
|
||||||
can.onengine && getRiver(can.onengine.river)
|
|
||||||
|
|
||||||
// 应用入口
|
|
||||||
can.onappend.daemon(can, can.user.title())
|
|
||||||
can.user.title(can.user.Search(can, "title"))
|
|
||||||
var pane = can[meta.main.name], msg = can.request({})
|
|
||||||
pane.onaction && pane.onaction._init(pane, msg, msg.option||[], cb, target)
|
|
||||||
can.page.Modify(can, document.body, {className: can.user.Search(can, "topic")||(can.user.Search(can, "pod")? "black": "white")})
|
|
||||||
})
|
|
||||||
can.onkeypop._init(can)
|
|
||||||
}, target) })
|
|
||||||
},
|
},
|
||||||
_merge: function(can, sub) { can.core.Item(sub, function(key, value) {
|
|
||||||
if (sub.hasOwnProperty(key)) { can.onengine[key] = value }
|
|
||||||
}); return true },
|
|
||||||
_topic: function(can) {
|
_topic: function(can) {
|
||||||
|
can.user.title(can.user.Search(can, "title"))
|
||||||
|
can.page.Modify(can, can._target, {className: can.user.Search(can, "topic")||(can.user.Search(can, "pod")? "black": "white")})
|
||||||
|
},
|
||||||
|
_daemon: function(can, name) {
|
||||||
|
can.misc.WSS(can, "", {name: name, type: "chrome"}, function(event, msg) {
|
||||||
|
if (msg.Option("_handle")) { return can.user.toast(can, msg.result.join("")) }
|
||||||
|
can.user.toast(can, msg.detail.join(" "))
|
||||||
|
|
||||||
|
switch (msg.detail[0]) {
|
||||||
|
case "pwd":
|
||||||
|
msg.Echo("hello world")
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
can.run(event, ["search"].concat(msg.detail), function(msg) {
|
||||||
|
msg.Reply(msg)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
msg.Reply(msg)
|
||||||
|
}, function() { can.user.toast(can, "wss connect", "iceberg") })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
search: function(event, can, msg, pane, cmds, cb) { var chain = cmds[1]
|
||||||
|
var sub, mod = can, key, fun = can; can.core.List(chain.split("."), function(value, index, array) {
|
||||||
|
fun && (sub = mod, mod = fun, key = value, fun = mod[value])
|
||||||
|
}); if (!sub || !mod || !fun) { console.info("not found", chain); return }
|
||||||
|
return typeof fun == "function" && fun(sub, msg, cmds.slice(2), cb, sub._target)
|
||||||
|
},
|
||||||
|
remote: function(event, can, msg, pane, cmds, cb) {
|
||||||
|
if (can.onengine.engine(event, can, msg, pane, cmds, cb)) { return }
|
||||||
|
if (location.protocol == "file:") { typeof cb == "function" && cb(msg); return }
|
||||||
|
can.misc.Run(event, can, {names: pane._name}, cmds, cb)
|
||||||
|
},
|
||||||
|
engine: function(event, can, msg, pane, cmds, cb) { if (!can.onengine) { return false }
|
||||||
|
switch (pane._name) {
|
||||||
|
case "River":
|
||||||
|
if (cmds.length == 0) {
|
||||||
|
can.core.Item(can.onengine.river, function(key, value) {
|
||||||
|
msg.Push("key", key)
|
||||||
|
msg.Push("name", value.name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (cmds.length != 1 && cmds[1] != "storm") {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case "Storm":
|
||||||
|
var river = can.onengine.river[cmds[0]]; if (!river) { break }
|
||||||
|
can.core.Item(river.storm, function(key, value) {
|
||||||
|
msg.Push("key", key)
|
||||||
|
msg.Push("name", value.name)
|
||||||
|
msg.Push("count", (value.index||value.action).length)
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
return true
|
||||||
|
case "Action":
|
||||||
|
var river = can.onengine.river[cmds[0]||"main"]
|
||||||
|
var storm = river && river.storm[cmds[1]]
|
||||||
|
var action = storm && storm.action && storm.action[cmds[2]]
|
||||||
|
if (!storm) { break } if (cmds.length == 2) {
|
||||||
|
if (storm.index) {
|
||||||
|
can.misc.Run(event, can, {names: pane._name}, [river.name, storm.name, "order"].concat(storm.index), cb)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (location.pathname == "/share") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
can.core.List(storm.action, function(value) {
|
||||||
|
msg.Push("name", value.name||"")
|
||||||
|
msg.Push("help", value.help||"")
|
||||||
|
msg.Push("pod", value.pod||"")
|
||||||
|
msg.Push("group", value.group||"")
|
||||||
|
msg.Push("index", value.index||"")
|
||||||
|
msg.Push("args", value.args||"[]")
|
||||||
|
msg.Push("action", value.action||value.index||"")
|
||||||
|
msg.Push("inputs", JSON.stringify(value.inputs||[]))
|
||||||
|
msg.Push("feature", JSON.stringify(value.feature||{}))
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
} else if (action && action.engine) {
|
||||||
|
action.engine(event, can, msg, pane, cmds, cb)
|
||||||
|
} else if (action) {
|
||||||
|
msg.Option("group", action.group)
|
||||||
|
msg.Option("index", action.index)
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
river: {
|
river: {
|
||||||
"serivce": {name: "运营群", storm: {
|
"serivce": {name: "运营群", storm: {
|
||||||
"wx": {name: "wx", action: [
|
"wx": {name: "wx", action: [
|
||||||
@ -63,11 +136,11 @@ Volcanos("onengine", { _init: function(can, meta, list, cb, target) {
|
|||||||
}},
|
}},
|
||||||
"product": {name: "产品群", storm: {
|
"product": {name: "产品群", storm: {
|
||||||
"office": {name: "office", index: [
|
"office": {name: "office", index: [
|
||||||
|
"web.wiki.feel",
|
||||||
"web.wiki.draw.draw",
|
"web.wiki.draw.draw",
|
||||||
"web.team.plan",
|
"web.team.plan",
|
||||||
"web.wiki.word",
|
"web.wiki.word",
|
||||||
"web.wiki.data",
|
"web.wiki.data",
|
||||||
"web.wiki.feel",
|
|
||||||
]},
|
]},
|
||||||
"english": {name: "english", action: [
|
"english": {name: "english", action: [
|
||||||
{name: "english", help: "英汉", index: "web.wiki.alpha.find", args: ["hi"]},
|
{name: "english", help: "英汉", index: "web.wiki.alpha.find", args: ["hi"]},
|
||||||
@ -148,77 +221,6 @@ Volcanos("onengine", { _init: function(can, meta, list, cb, target) {
|
|||||||
]},
|
]},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
search: function(event, can, msg, pane, cmds, cb) { var chain = cmds[1]
|
|
||||||
var sub, mod = can, key, fun = can; can.core.List(chain.split("."), function(value, index, array) {
|
|
||||||
fun && (sub = mod, mod = fun, key = value, fun = mod[value])
|
|
||||||
}); if (!sub || !mod || !fun) { console.info("not found", chain); return }
|
|
||||||
|
|
||||||
return typeof fun == "function" && fun(sub, msg, cmds.slice(2), cb, sub._target)
|
|
||||||
},
|
|
||||||
engine: function(event, can, msg, pane, cmds, cb) { if (!can.onengine) { return false }
|
|
||||||
switch (pane._name) {
|
|
||||||
case "River":
|
|
||||||
if (cmds.length == 0) {
|
|
||||||
can.core.Item(can.onengine.river, function(key, value) {
|
|
||||||
msg.Push("key", key)
|
|
||||||
msg.Push("name", value.name)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (cmds.length != 1 && cmds[1] != "storm") {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case "Storm":
|
|
||||||
var river = can.onengine.river[cmds[0]]; if (!river) { break }
|
|
||||||
can.core.Item(river.storm, function(key, value) {
|
|
||||||
msg.Push("key", key)
|
|
||||||
msg.Push("name", value.name)
|
|
||||||
msg.Push("count", (value.index||value.action).length)
|
|
||||||
})
|
|
||||||
typeof cb == "function" && cb(msg)
|
|
||||||
return true
|
|
||||||
case "Action":
|
|
||||||
var river = can.onengine.river[cmds[0]||"main"]
|
|
||||||
var storm = river && river.storm[cmds[1]]
|
|
||||||
var action = storm && storm.action && storm.action[cmds[2]]
|
|
||||||
if (!storm) { break } if (cmds.length == 2) {
|
|
||||||
if (storm.index) {
|
|
||||||
can.misc.Run(event, can, {names: pane._name}, [river.name, storm.name, "order"].concat(storm.index), cb)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (location.pathname == "/share") {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
can.core.List(storm.action, function(value) {
|
|
||||||
msg.Push("name", value.name||"")
|
|
||||||
msg.Push("help", value.help||"")
|
|
||||||
msg.Push("pod", value.pod||"")
|
|
||||||
msg.Push("group", value.group||"")
|
|
||||||
msg.Push("index", value.index||"")
|
|
||||||
msg.Push("args", value.args||"[]")
|
|
||||||
msg.Push("action", value.action||value.index||"")
|
|
||||||
msg.Push("inputs", JSON.stringify(value.inputs||[]))
|
|
||||||
msg.Push("feature", JSON.stringify(value.feature||{}))
|
|
||||||
})
|
|
||||||
typeof cb == "function" && cb(msg)
|
|
||||||
} else if (action && action.engine) {
|
|
||||||
action.engine(event, can, msg, pane, cmds, cb)
|
|
||||||
} else if (action) {
|
|
||||||
msg.Option("group", action.group)
|
|
||||||
msg.Option("index", action.index)
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
remote: function(event, can, msg, pane, cmds, cb) {
|
|
||||||
if (can.onengine.engine(event, can, msg, pane, cmds, cb)) { return }
|
|
||||||
if (location.protocol == "file:") { typeof cb == "function" && cb(msg); return }
|
|
||||||
can.misc.Run(event, can, {names: pane._name}, cmds, cb)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { meta.name = meta.name.split(" ")[0]
|
Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { meta.name = meta.name.split(" ")[0]
|
||||||
field = field || can.onappend.field(can, target, meta.type||"plugin", meta).first
|
field = field || can.onappend.field(can, target, meta.type||"plugin", meta).first
|
||||||
@ -232,6 +234,26 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
var sub = Volcanos(meta.name, { _help: meta.name, _follow: can._follow+"."+meta.name,
|
var sub = Volcanos(meta.name, { _help: meta.name, _follow: can._follow+"."+meta.name,
|
||||||
_legend: legend, _option: option, _action: action, _output: output, _status: status,
|
_legend: legend, _option: option, _action: action, _output: output, _status: status,
|
||||||
_target: field, _inputs: {}, _outputs: [], _history: [],
|
_target: field, _inputs: {}, _outputs: [], _history: [],
|
||||||
|
Pack: function(cmds) {
|
||||||
|
cmds = cmds && cmds.length > 0? cmds: sub.page.Select(sub, sub._option, "textarea.args,input.args,select.args", function(item) {
|
||||||
|
return item.name && item.value || ""
|
||||||
|
}); for (var i = cmds.length-1; i >= 0; i--) {
|
||||||
|
if (!cmds[i]) { cmds.pop() } else { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
var last = sub._history[sub._history.length-1]; !sub.core.Eq(last, cmds) && cmds[0] != "action" && sub._history.push(cmds)
|
||||||
|
return cmds
|
||||||
|
},
|
||||||
|
Clone: function() {
|
||||||
|
meta.args = sub.page.Select(sub, sub._option, "textarea.args,input.args,select.args", function(item) {
|
||||||
|
return item.value || ""
|
||||||
|
})
|
||||||
|
sub.onappend._init(sub, meta, list, function(sub) {
|
||||||
|
cb(sub), sub.Timer(10, function() {
|
||||||
|
for (var k in sub._inputs) { sub._inputs[k]._target.focus(); break }
|
||||||
|
})
|
||||||
|
}, target)
|
||||||
|
},
|
||||||
Option: function(key, value) {
|
Option: function(key, value) {
|
||||||
if (typeof key == "object") { return sub.core.Item(key, sub.Option), key }
|
if (typeof key == "object") { return sub.core.Item(key, sub.Option), key }
|
||||||
if (key == undefined) { value = {}
|
if (key == undefined) { value = {}
|
||||||
@ -258,144 +280,66 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
})
|
})
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
}, [Volcanos.meta.volcano].concat(list), function(sub) {
|
}, [Volcanos.meta.volcano].concat(list), function(sub) { cb(sub)
|
||||||
meta.feature = can.base.Obj(meta.feature, {})
|
meta.feature = sub.base.Obj(meta.feature, {})
|
||||||
can.page.ClassList.add(can, field, meta.feature.style||"")
|
sub.page.ClassList.add(sub, field, meta.feature.style||"")
|
||||||
|
|
||||||
sub.onaction && can.onappend._action(sub, sub._action, sub.onaction.list)
|
|
||||||
|
|
||||||
meta.detail = meta.feature["detail"] || {}
|
meta.detail = meta.feature["detail"] || {}
|
||||||
|
|
||||||
sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field)
|
sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field)
|
||||||
sub.onappend._status(sub, status)
|
|
||||||
// sub.Conf("height", meta.height || sub.Conf("height"))
|
|
||||||
// sub.Conf("width", meta.width || sub.Conf("width"))
|
|
||||||
|
|
||||||
|
meta.inputs && sub.onappend._option(sub, meta, list, cb)
|
||||||
// 添加控件
|
sub.onaction && sub.onappend._action(sub, sub._action, sub.onaction.list)
|
||||||
var index = -1
|
sub.onexport && sub.onappend._status(sub, sub._status, sub.onexport.list)
|
||||||
function add(item, next) { item._input == "text" && index++
|
})
|
||||||
return sub._inputs[item.name] = Volcanos(item.name, { _help: item.name, _follow: can._follow+"."+meta.name+"."+item.name,
|
return sub
|
||||||
_target: can.onappend.input(sub, option, item.type, item, args[index]),
|
},
|
||||||
_option: option, _action: action, _output: output,
|
_option: function(can, meta, list, cb) { var index = -1, args = can.base.Obj(meta.args, [])
|
||||||
CloneInput: function() { add(item, function() {}, index)._target.focus() },
|
function add(item, next) { item._input == "text" && index++
|
||||||
CloneField: function() {
|
return can._inputs[item.name] = Volcanos(item.name, { _help: item.name, _follow: can._follow+"."+item.name,
|
||||||
meta.args = can.page.Select(can, option, "textarea.args,input.args,select.args", function(item) {
|
_target: can.onappend.input(can, can._option, item.type, item, args[index]),
|
||||||
return item.value || ""
|
_option: can._option, _action: can._action, _output: can._output,
|
||||||
})
|
CloneInput: function() { add(item, function() {})._target.focus() },
|
||||||
can.onappend._init(can, meta, list, function(sub) {
|
CloneField: function() { can.Clone() },
|
||||||
cb(sub), sub.Timer(10, function() {
|
}, Volcanos.meta.libs.concat([item.display||"/plugin/input.js", "/frame.js"]), function(input) { input.sup = can
|
||||||
for (var k in sub._inputs) { sub._inputs[k]._target.focus(); break }
|
input.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||||
})
|
switch (item.name) {
|
||||||
}, target) },
|
|
||||||
}, Volcanos.meta.libs.concat([item.display||"/plugin/input.js", "/frame.js"]), function(input) { input.sup = sub
|
|
||||||
input.onimport._init(input, input.Conf(item), item.list||[], function() {}, input._target)
|
|
||||||
|
|
||||||
if (location.protocol == "chrome-extension:") {
|
|
||||||
var p = sub.user.Cookie(can, item.name)
|
|
||||||
item.type != "button" && p != undefined && (input._target.value = p)
|
|
||||||
}
|
|
||||||
|
|
||||||
input.run = function(event, cmds, cb, silent) { var msg = sub.request(event)
|
|
||||||
sub.core.Item(sub.Conf("option"), msg.Option)
|
|
||||||
|
|
||||||
// 控件回调
|
|
||||||
switch (item.name) {
|
|
||||||
case "打开":
|
case "打开":
|
||||||
case "查看":
|
case "查看":
|
||||||
break
|
break
|
||||||
case "返回":
|
case "返回":
|
||||||
// 历史命令
|
can._history.pop(); var his = can._history.pop(); if (his) {
|
||||||
sub._history.pop(); var his = sub._history.pop(); if (his) {
|
|
||||||
can.page.Select(can, option, "input.args", function(item, index) {
|
can.page.Select(can, option, "input.args", function(item, index) {
|
||||||
item.value = his[index] || ""
|
item.value = his[index] || ""
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case "清空":
|
case "清空":
|
||||||
sub._output.innerHTML = ""
|
can._output.innerHTML = ""
|
||||||
return typeof cb == "function" && cb(can.request(event))
|
return typeof cb == "function" && cb(can.request(event))
|
||||||
default:
|
default:
|
||||||
cmds && cmds[0] == "action" || msg.Option("_action", item.name||item.value)
|
cmds && cmds[0] == "action" || msg.Option("_action", item.name||item.value)
|
||||||
}
|
|
||||||
|
|
||||||
// 解析参数
|
|
||||||
cmds = cmds && cmds.length > 0? cmds: can.page.Select(can, option, "textarea.args,input.args,select.args", function(item) {
|
|
||||||
return item.name && item.value || ""
|
|
||||||
}); for (var i = cmds.length-1; i >= 0; i--) {
|
|
||||||
if (!cmds[i]) { cmds.pop() } else { break }
|
|
||||||
}
|
|
||||||
|
|
||||||
var last = sub._history[sub._history.length-1]; !can.core.Eq(last, cmds) && cmds[0] != "action" && sub._history.push(cmds)
|
|
||||||
return run(event, cmds, cb, silent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
can.core.Item(input.onaction, function(key, value) {
|
can.core.Item(can.Conf("option"), msg.Option)
|
||||||
input._target && key.indexOf("on") == 0 && (input._target[key] = input._target[key] || function(event) {
|
return can.onappend._output(can, meta, event, can.Pack(cmds), cb, silent)
|
||||||
value(event, input)
|
}
|
||||||
})
|
|
||||||
}), next()
|
|
||||||
|
|
||||||
// 自动执行
|
input.onimport && input.onimport._init(input, input.Conf(item), item.list||[], function() {}, input._target)
|
||||||
item.type == "button" && item.action == "auto" && input._target.click()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
var args = can.base.Obj(meta.args, []); can.core.Next(can.base.Obj(meta.inputs, []), add)
|
can.core.Item(input.onaction, function(key, value) {
|
||||||
var count = 0; function run(event, cmds, cb, silent) { return sub.run(event, cmds||[], function(msg) {
|
input._target && key.indexOf("on") == 0 && (input._target[key] = input._target[key] || function(event) {
|
||||||
sub.Status("ncmd", sub._history.length+"/"+count++)
|
value(event, input)
|
||||||
typeof cb == "function" && cb(msg)
|
})
|
||||||
if (silent) { return }
|
}), next()
|
||||||
|
|
||||||
// 添加组件
|
// 自动执行
|
||||||
var display = (msg.Option("_plugin")||msg.Option("_display")||meta.feature.plugin||meta.feature.display||"table.js")
|
item.type == "button" && item.action == "auto" && input._target.click()
|
||||||
display.indexOf("/") == 0 || (display = "/plugin/"+display)
|
|
||||||
|
|
||||||
var table = Volcanos(display, { _help: display, _follow: can._follow+"."+meta.name+"."+display,
|
|
||||||
_target: output, Option: sub.Option, Action: sub.Action, Status: sub.Status,
|
|
||||||
_option: option, _action: action, _output: output,
|
|
||||||
_fields: field,
|
|
||||||
}, Volcanos.meta.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf()), table._msg = msg
|
|
||||||
table.run = function(event, cmds, cb, silent) {
|
|
||||||
cmds = cmds? cmds: sub.page.Select(sub, option, "textarea.args,input.args,select.args", function(item) {
|
|
||||||
return item.name && item.value || ""
|
|
||||||
}); for (var i = cmds.length-1; i >= 0; i--) {
|
|
||||||
if (!cmds[i]) { cmds.pop() } else { break }
|
|
||||||
}
|
|
||||||
|
|
||||||
var last = sub._history[sub._history.length-1]; !can.core.Eq(last, cmds) && cmds[0] != "action" && sub._history.push(cmds)
|
|
||||||
return run(event, cmds, cb, silent)
|
|
||||||
}
|
|
||||||
|
|
||||||
table.onimport && table.onimport._init && table.onimport._init(table, msg, msg.result||[], function() {
|
|
||||||
// 交互控件
|
|
||||||
can.onappend._action(table, action, meta._action)
|
|
||||||
can.onappend._detail(table, msg, msg["_detail"] || sub.Conf("detail"), output)
|
|
||||||
can.onappend._status(table, status)
|
|
||||||
sub.Status("ncmd", sub._history.length+"/"+count)
|
|
||||||
}, output)
|
|
||||||
}); sub._outputs.push(table)
|
|
||||||
}, silent) }
|
|
||||||
}); cb(sub)
|
|
||||||
return sub
|
|
||||||
},
|
|
||||||
_legend: function(can, legend) {
|
|
||||||
legend && (legend.onclick = function(event) { var msg = can.request(event)
|
|
||||||
can.core.List(["share", "pod"], function(key) { var value = can.user.Search(can, key)
|
|
||||||
value != undefined && msg.Option(key, can.user.Search(can, key))
|
|
||||||
})
|
})
|
||||||
can.core.List(["River", "Storm", "Action"], function(item) {
|
}
|
||||||
can.run(event, ["search", item+".onexport.key"])
|
can.core.Next(can.base.Obj(meta.inputs, []), add)
|
||||||
})
|
|
||||||
var args = {}; can.core.List(msg.option, function(key) { args[key] = msg.Option(key) })
|
|
||||||
// can.core.Item(can.Option(), function(key, value) { args[key] = value })
|
|
||||||
//
|
|
||||||
|
|
||||||
location.protocol == "chrome:" && can.user.locals(can, args)
|
|
||||||
location.href = can.user.Share(can, args, true)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
_action: function(can, action, list) { // [string [class item...] {}]
|
_action: function(can, action, list) { // [string [class item...] {}]
|
||||||
action && (action.innerHTML = ""), can.onaction && can.core.List(list||can.onaction.list, function(item) {
|
action.innerHTML = "", can.core.List(list, function(item) {
|
||||||
item === ""? /*空白*/ can.page.Append(can, action, [{view: "item space"}]):
|
item === ""? /*空白*/ can.page.Append(can, action, [{view: "item space"}]):
|
||||||
typeof item == "string"? /*按键*/ can.onappend.input(can, action, "input", {type: "button", value: item, onclick: function(event) {
|
typeof item == "string"? /*按键*/ can.onappend.input(can, action, "input", {type: "button", value: item, onclick: function(event) {
|
||||||
var cb = can.onaction[item] || can.onaction["_engine"] || can.onkeymap && can.onkeymap._remote
|
var cb = can.onaction[item] || can.onaction["_engine"] || can.onkeymap && can.onkeymap._remote
|
||||||
@ -411,24 +355,50 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
}}] }]): typeof item == "object" && /*其它*/ can.page.Append(can, action, [item])
|
}}] }]): typeof item == "object" && /*其它*/ can.page.Append(can, action, [item])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
_output: function(can, meta, event, cmds, cb, silent) {
|
||||||
|
return can.run(event, cmds||[], function(msg) {
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
if (silent) { return }
|
||||||
|
|
||||||
|
var display = (msg.Option("_plugin")||msg.Option("_display")||meta.feature.plugin||meta.feature.display||"table.js")
|
||||||
|
display.indexOf("/") == 0 || (display = "/plugin/"+display)
|
||||||
|
|
||||||
|
var table = Volcanos(display, { _help: display, _follow: can._follow+"."+display,
|
||||||
|
_target: can._output, _option: can._option, _action: can._action, _output: can._output, _status: can._status,
|
||||||
|
_fields: can._target, Option: can.Option, Action: can.Action, Status: can.Status,
|
||||||
|
}, Volcanos.meta.libs.concat([display, "/frame.js"]), function(table) { table.Conf(can.Conf()), table._msg = msg
|
||||||
|
table.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||||
|
can.core.Item(can.Conf("option"), msg.Option)
|
||||||
|
return can.onappend._output(can, meta, event, can.Pack(cmds), cb, silent)
|
||||||
|
}
|
||||||
|
|
||||||
|
table.onimport && table.onimport._init && table.onimport._init(table, msg, msg.result||[], function() {
|
||||||
|
can.onappend._detail(table, msg, msg["_detail"] || can.Conf("detail"), can._output)
|
||||||
|
table.onaction && table.onappend._action(table, table._action, meta._action||table.onaction.list)
|
||||||
|
table.onexport && table.onappend._status(table, table._status, table.onexport.list)
|
||||||
|
}, can._output)
|
||||||
|
}); can._outputs.push(table)
|
||||||
|
}, silent)
|
||||||
|
},
|
||||||
_detail: function(can, msg, list, target) {
|
_detail: function(can, msg, list, target) {
|
||||||
can.ondetail && can.ondetail.list && can.ondetail.list.length > 0 && (target.oncontextmenu = function(event) {
|
can.ondetail && list.length > 0 && (target.oncontextmenu = function(event) {
|
||||||
can.user.carte(can, can.ondetail||{}, list, function(ev, item, meta) {
|
can.user.carte(can, can.ondetail||{}, list, function(ev, item, meta) {
|
||||||
(can.ondetail[item] || can.onaction[item] || can.onkeymap && can.onkeymap._remote)(event, can, item)
|
(can.ondetail[item] || can.onaction[item])(event, can, item)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_status: function(can, status) {
|
_status: function(can, status, list) {
|
||||||
status.innerHTML = "", can.onexport && can.core.List(can.onexport.list, function(item) {
|
status.innerHTML = "", can.core.List(list, function(item) {
|
||||||
can.page.Append(can, status, [{view: "item "+item, title: item, list: [{text: [item+": ", "label"]}, {text: ["", "span"]}]}])
|
can.page.Append(can, status, [{view: "item "+item, title: item, list: [{text: [item+": ", "label"]}, {text: ["", "span"]}]}])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
item: function(can, target, type, item, cb, cbs) {
|
item: function(can, target, type, item, cb, cbs) {
|
||||||
var ui = can.page.Append(can, target, [{view: [type, "div", item.nick||item.name],
|
var ui = can.page.Append(can, target, [{view: [type, "div", item.nick||item.name],
|
||||||
oncontextmenu: function(event) { cbs(event, ui.item) }, click: function(event) {
|
oncontextmenu: function(event) { cbs(event, ui.item) }, click: function(event) {
|
||||||
can.page.Select(can, target, "div."+type, function(item) {
|
can.page.Select(can, target, "div."+type, function(item) {
|
||||||
can.page.ClassList.del(can, item, "select")
|
can.page.ClassList.del(can, item, "select")
|
||||||
}); can.page.ClassList.add(can, ui.item, "select")
|
}), can.page.ClassList.add(can, ui.item, "select")
|
||||||
cb(event, ui.item)
|
cb(event, ui.item)
|
||||||
},
|
},
|
||||||
}])
|
}])
|
||||||
@ -542,7 +512,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
return run(event, event.target.value, value)
|
return run(event, event.target.value, value)
|
||||||
}
|
}
|
||||||
can.page.Select(can, can._option, "input.args", function(input) { if (input.name == key) { var data = input.dataset || {}
|
can.page.Select(can, can._option, "input.args", function(input) { if (input.name == key) { var data = input.dataset || {}
|
||||||
input.value = value; typeof cb == "function" && cb(event, value); if (data.action == "auto") {
|
input.value = value, typeof cb == "function" && cb(event, value); if (data.action == "auto") {
|
||||||
var sub = can.request(event)
|
var sub = can.request(event)
|
||||||
can.core.Item(can.Option(), sub.Option)
|
can.core.Item(can.Option(), sub.Option)
|
||||||
sub.Option("_action", msg.Option("_action"))
|
sub.Option("_action", msg.Option("_action"))
|
||||||
@ -552,14 +522,14 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
}
|
}
|
||||||
} })
|
} })
|
||||||
}, ondblclick: function(event) {
|
}, ondblclick: function(event) {
|
||||||
can.onappend.modify(can, event.target, function(event, value, old) {
|
can.onmotion.modify(can, event.target, function(event, value, old) {
|
||||||
run(event, "编辑", value)
|
run(event, "编辑", value)
|
||||||
})
|
})
|
||||||
}, oncontextmenu: function(event) {
|
}, oncontextmenu: function(event) {
|
||||||
can.user.carte(can, can.ondetail||{}, msg["_detail"] || can.Conf("detail") || can.ondetail.list, function(event, item, meta) {
|
can.user.carte(can, can.ondetail||{}, msg["_detail"] || can.Conf("detail") || can.ondetail.list, function(event, item, meta) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case "编辑":
|
case "编辑":
|
||||||
can.onappend.modify(can, event.target, function(event, value, old) {
|
can.onmotion.modify(can, event.target, function(event, value, old) {
|
||||||
run(event, "编辑", value)
|
run(event, "编辑", value)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
@ -574,39 +544,6 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
|
|||||||
board: function(can, target, type, msg) {
|
board: function(can, target, type, msg) {
|
||||||
msg.result && can.page.AppendBoard(can, target, can.page.Display(msg.Result()))
|
msg.result && can.page.AppendBoard(can, target, can.page.Display(msg.Result()))
|
||||||
},
|
},
|
||||||
|
|
||||||
modify: function(can, target, cb) { var back = target.innerHTML
|
|
||||||
var ui = can.page.Appends(can, target, [{type: "input", value: back, onkeydown: function(event) {
|
|
||||||
switch (event.key) {
|
|
||||||
case "Enter":
|
|
||||||
target.innerHTML = event.target.value
|
|
||||||
if (event.target.value != back) {
|
|
||||||
cb(event, event.target.value, back)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "Escape":
|
|
||||||
td.innerHTML = back
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}, onkeyup: function(event) {
|
|
||||||
|
|
||||||
}}]); ui.input.focus(), ui.input.setSelectionRange(0, -1)
|
|
||||||
},
|
|
||||||
daemon: function(can, name) {
|
|
||||||
can.misc.WSS(can, "", {name: name, type: "chrome"}, function(event, msg) {
|
|
||||||
if (msg.Option("_handle")) {return can.user.toast(can, msg.result.join(""))}
|
|
||||||
|
|
||||||
can.user.toast(can, msg.detail.join(" ")); switch (msg.detail[0]) {
|
|
||||||
case "pwd": msg.Echo("hello world"); break
|
|
||||||
default:
|
|
||||||
can.run(event, ["search"].concat(msg.detail), function(msg) {
|
|
||||||
msg.Reply(msg)
|
|
||||||
}); return
|
|
||||||
|
|
||||||
msg.Reply(msg)
|
|
||||||
}
|
|
||||||
}, function() {can.user.toast(can, "wss connect", "iceberg")})
|
|
||||||
},
|
|
||||||
}, [], function(can) {})
|
}, [], function(can) {})
|
||||||
Volcanos("onlayout", { _init: function(can, meta, list, cb, target) {
|
Volcanos("onlayout", { _init: function(can, meta, list, cb, target) {
|
||||||
if (can.user.Search(can, "share")) { return typeof cb == "function" && cb() }
|
if (can.user.Search(can, "share")) { return typeof cb == "function" && cb() }
|
||||||
@ -678,7 +615,24 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can) {
|
|||||||
action: null,
|
action: null,
|
||||||
})
|
})
|
||||||
Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can) {
|
Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can) {
|
||||||
},
|
},
|
||||||
|
modify: function(can, target, cb) { var back = target.innerHTML
|
||||||
|
var ui = can.page.Appends(can, target, [{type: "input", value: back, onkeydown: function(event) {
|
||||||
|
switch (event.key) {
|
||||||
|
case "Enter":
|
||||||
|
target.innerHTML = event.target.value
|
||||||
|
if (event.target.value != back) {
|
||||||
|
cb(event, event.target.value, back)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "Escape":
|
||||||
|
td.innerHTML = back
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}, onkeyup: function(event) {
|
||||||
|
|
||||||
|
}}]); ui.input.focus(), ui.input.setSelectionRange(0, -1)
|
||||||
|
},
|
||||||
show: function(can, target, time, cb) { time = time || {value: 100, length: 30}
|
show: function(can, target, time, cb) { time = time || {value: 100, length: 30}
|
||||||
can.page.Modify(can, target, {style: {opacity: 0}})
|
can.page.Modify(can, target, {style: {opacity: 0}})
|
||||||
can.Timer(time, function(event, value, index) {
|
can.Timer(time, function(event, value, index) {
|
||||||
@ -694,3 +648,4 @@ Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can) {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ fieldset>div.status>div.item {
|
|||||||
padding:4px;
|
padding:4px;
|
||||||
}
|
}
|
||||||
fieldset>div.status>div.item>label {
|
fieldset>div.status>div.item>label {
|
||||||
font-size:14px;
|
font-size:10px;
|
||||||
color:gray;
|
color:gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
index.js
1
index.js
@ -14,6 +14,7 @@ Volcanos({name: "chat", volcano: "/frame.js", iceberg: "/chat/", intshell: "plug
|
|||||||
"/plugin/local/team/plan.js",
|
"/plugin/local/team/plan.js",
|
||||||
"/plugin/local/wiki/draw.js",
|
"/plugin/local/wiki/draw.js",
|
||||||
"/plugin/local/wiki/word.js",
|
"/plugin/local/wiki/word.js",
|
||||||
|
"/plugin/local/code/vimer.js",
|
||||||
"/plugin/local/code/inner.js",
|
"/plugin/local/code/inner.js",
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
37
lib/core.js
37
lib/core.js
@ -1,4 +1,19 @@
|
|||||||
var core = Volcanos("core", {help: "核心模块",
|
var core = Volcanos("core", {help: "核心模块",
|
||||||
|
Item: shy("迭代器", function(obj, cb) {var list = [];
|
||||||
|
for (var k in obj) {
|
||||||
|
var res = typeof cb == "function"? cb(k, obj[k]): k
|
||||||
|
res && list.push(res)
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}),
|
||||||
|
Items: shy("迭代器", function(obj, cb) {var list = [];
|
||||||
|
for (var key in obj) {
|
||||||
|
list = list.concat(this.List(obj[key], function(value, index, array) {
|
||||||
|
return typeof cb == "function" && cb(value, index, key, obj)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}),
|
||||||
List: shy("迭代器", function(obj, cb, interval, cbs) {
|
List: shy("迭代器", function(obj, cb, interval, cbs) {
|
||||||
if (typeof obj == "number") {
|
if (typeof obj == "number") {
|
||||||
var begin = 0, end = obj, step = 1;
|
var begin = 0, end = obj, step = 1;
|
||||||
@ -31,20 +46,6 @@ var core = Volcanos("core", {help: "核心模块",
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}),
|
}),
|
||||||
Item: shy("迭代器", function(obj, cb) {var list = [];
|
|
||||||
for (var k in obj) {var res;
|
|
||||||
list.push(typeof cb == "function" && (res = cb(k, obj[k])) != undefined? res: k)
|
|
||||||
}
|
|
||||||
return list
|
|
||||||
}),
|
|
||||||
Items: shy("迭代器", function(obj, cb) {var list = [];
|
|
||||||
for (var key in obj) {
|
|
||||||
list = list.concat(this.List(obj[key], function(value, index, array) {
|
|
||||||
return typeof cb == "function" && cb(value, index, key, obj)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
return list
|
|
||||||
}),
|
|
||||||
Next: shy("迭代器", function(obj, cb, cbs) {obj = typeof obj == "string"? [obj]: (obj || [])
|
Next: shy("迭代器", function(obj, cb, cbs) {obj = typeof obj == "string"? [obj]: (obj || [])
|
||||||
function next(list, cb, index) {
|
function next(list, cb, index) {
|
||||||
list && list.length > 0? typeof cb == "function" && cb(list[0], function() {
|
list && list.length > 0? typeof cb == "function" && cb(list[0], function() {
|
||||||
@ -53,13 +54,6 @@ var core = Volcanos("core", {help: "核心模块",
|
|||||||
}
|
}
|
||||||
next(obj, cb, 0)
|
next(obj, cb, 0)
|
||||||
}),
|
}),
|
||||||
Trim: shy("迭代器", function(obj) {
|
|
||||||
for (var i = obj.length; i >= 0; i--) {
|
|
||||||
if (obj[i]) {break}
|
|
||||||
obj = obj.slice(0, i)
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
}),
|
|
||||||
|
|
||||||
Split: shy("分词器", function(str) { if (!str || !str.length) {return []}
|
Split: shy("分词器", function(str) { if (!str || !str.length) {return []}
|
||||||
var opt = {simple: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
|
var opt = {simple: false}, arg = []; for (var i = 1; i < arguments.length; i++) {
|
||||||
@ -124,7 +118,6 @@ var core = Volcanos("core", {help: "核心模块",
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Eq: function(obj, other) { var self = arguments.callee
|
Eq: function(obj, other) { var self = arguments.callee
|
||||||
// undefined null
|
// undefined null
|
||||||
// string number boolen
|
// string number boolen
|
||||||
|
40
lib/page.js
40
lib/page.js
@ -189,11 +189,6 @@ var page = Volcanos("page", {help: "网页模块",
|
|||||||
return hide
|
return hide
|
||||||
},
|
},
|
||||||
|
|
||||||
CopySub: shy("复制节点", function(can, target, source) {
|
|
||||||
while (source.children.length > 0) {
|
|
||||||
target.appendChild(source.children[0])
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
AppendItem: shy("添加插件", function(can, target, list, click, cb, cbs) {
|
AppendItem: shy("添加插件", function(can, target, list, click, cb, cbs) {
|
||||||
can.core.List(list, function(line, index) {
|
can.core.List(list, function(line, index) {
|
||||||
var item = can.page.Append(can, target, [{view: ["item k"+line.key], list: [{text: [line.nick||line.name||line.key]}], click: function(event) {
|
var item = can.page.Append(can, target, [{view: ["item k"+line.key], list: [{text: [line.nick||line.name||line.key]}], click: function(event) {
|
||||||
@ -374,30 +369,6 @@ var page = Volcanos("page", {help: "网页模块",
|
|||||||
text = text.replace(/\\n/g, "<br>")
|
text = text.replace(/\\n/g, "<br>")
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
CopyText: function(can, text) {
|
|
||||||
if (text) {
|
|
||||||
var input = can.page.Append(can, document.body, [{type: "textarea", inner: text}]).last;
|
|
||||||
input.focus(), input.setSelectionRange(0, text.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
text = window.getSelection().toString();
|
|
||||||
if (text == "") {return ""}
|
|
||||||
|
|
||||||
// kit.History("txt", -1) && kit.History("txt", -1).data == text || kit.History("txt", -1, text) &&
|
|
||||||
document.execCommand("copy");
|
|
||||||
input && document.body.removeChild(input);
|
|
||||||
return text;
|
|
||||||
},
|
|
||||||
Download: function(can, name, value) {
|
|
||||||
var timer = can.user.toast(can, {title: "下载中...", width: 200,
|
|
||||||
text:'<a href="'+URL.createObjectURL(new Blob([value]))+'" target="_blank" download="'+name+'">'+name+'</a>',
|
|
||||||
})
|
|
||||||
can.page.Select(can, timer.toast.content, "a", function(item) {
|
|
||||||
item.click()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
Upload: function(can, file, cb, cbs) {
|
|
||||||
},
|
|
||||||
Format: function(type) {
|
Format: function(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "a":
|
case "a":
|
||||||
@ -406,7 +377,6 @@ var page = Volcanos("page", {help: "网页模块",
|
|||||||
return "<img src='"+arguments[1]+"'>"
|
return "<img src='"+arguments[1]+"'>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
DelText: function(target, start, count) {
|
DelText: function(target, start, count) {
|
||||||
target.value = target.value.substring(0, start)+target.value.substring(start+(count||target.value.length), target.value.length)
|
target.value = target.value.substring(0, start)+target.value.substring(start+(count||target.value.length), target.value.length)
|
||||||
target.setSelectionRange(start, start)
|
target.setSelectionRange(start, start)
|
||||||
@ -624,15 +594,6 @@ var page = Volcanos("page", {help: "网页模块",
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
offset: function(target) {
|
|
||||||
var offsetTop = 0, offsetLeft = 0
|
|
||||||
for (var p = target; p != null; p = p.parentNode) {
|
|
||||||
offsetTop += (p.offsetTop||0)
|
|
||||||
offsetLeft += (p.offsetLeft||0)
|
|
||||||
}
|
|
||||||
return {Top: offsetTop, Left: offsetLeft}
|
|
||||||
},
|
|
||||||
|
|
||||||
EnableDrop: function(can, parent, search, target) {
|
EnableDrop: function(can, parent, search, target) {
|
||||||
return can.page.Modify(can, target, { draggable: true,
|
return can.page.Modify(can, target, { draggable: true,
|
||||||
ondragstart: function(event) { var target = event.target; can.drop = function(event, tab) {
|
ondragstart: function(event) { var target = event.target; can.drop = function(event, tab) {
|
||||||
@ -649,7 +610,6 @@ var page = Volcanos("page", {help: "网页模块",
|
|||||||
ondrop: function(event) { event.preventDefault()
|
ondrop: function(event) { event.preventDefault()
|
||||||
can.drop(event, event.target)
|
can.drop(event, event.target)
|
||||||
},
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -166,7 +166,8 @@ var user = Volcanos("user", {help: "用户模块",
|
|||||||
obj._path && (path = obj._path, delete(obj._path))
|
obj._path && (path = obj._path, delete(obj._path))
|
||||||
!clear && can.core.Item(can.user.Search(), function(key, value) {obj[key] || (obj[key] = value)});
|
!clear && can.core.Item(can.user.Search(), function(key, value) {obj[key] || (obj[key] = value)});
|
||||||
return can.core.List([location.origin+path, can.core.Item(obj, function(key, value) {
|
return can.core.List([location.origin+path, can.core.Item(obj, function(key, value) {
|
||||||
return can.core.List(value, function(value) {return key+"="+encodeURIComponent(value)}).join("&");
|
if (!value) { return }
|
||||||
|
return can.core.List(value, function(value) {return key+"="+encodeURIComponent(value)}).join("&")
|
||||||
}).join("&")], function(item) { return item? item: undefined }).join("?")
|
}).join("&")], function(item) { return item? item: undefined }).join("?")
|
||||||
}),
|
}),
|
||||||
Search: shy("请求参数", function(can, key, value) {var args = {}
|
Search: shy("请求参数", function(can, key, value) {var args = {}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
||||||
|
typeof cb == "function" && cb()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
@ -14,6 +15,12 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
value.name && can.onappend._init(can, value, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
value.name && can.onappend._init(can, value, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||||
|
sub._legend.onclick = function(event) {
|
||||||
|
var opt = {pod: can.user.Search(can, "pod"), river: river, storm: storm, active: value.name}
|
||||||
|
can.core.Item(sub.Option(), function(key, value) { opt[key] = value })
|
||||||
|
location.href = can.user.Share(can, opt, true)
|
||||||
|
|
||||||
|
}
|
||||||
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||||
can.Conf("active", sub.Option())
|
can.Conf("active", sub.Option())
|
||||||
can.Conf("action", value.name)
|
can.Conf("action", value.name)
|
||||||
@ -52,8 +59,6 @@ Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg,
|
|||||||
|
|
||||||
msg.Clear("option"), can.run(msg._event, [river, storm], function(sup) { can._output.innerHTML = ""
|
msg.Clear("option"), can.run(msg._event, [river, storm], function(sup) { can._output.innerHTML = ""
|
||||||
can.core.Next(sup.Table(), function(value, next) {
|
can.core.Next(sup.Table(), function(value, next) {
|
||||||
// value.inputs = can.base.Obj(value.inputs||"[]", [])
|
|
||||||
// value.args = typeof value.args == "string"? value.args.split(","): value.args
|
|
||||||
value.inputs = can.base.Obj(value.inputs||"[]", [])
|
value.inputs = can.base.Obj(value.inputs||"[]", [])
|
||||||
value.height = can._target.offsetHeight
|
value.height = can._target.offsetHeight
|
||||||
value.width = can._target.offsetWidth
|
value.width = can._target.offsetWidth
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
||||||
return
|
|
||||||
document.body.onkeydown = function(event) { if (event.target != document.body) { return }
|
|
||||||
switch (event.key) {
|
|
||||||
case "n":
|
|
||||||
can.run(event, ["search", "River.onaction.create"])
|
|
||||||
break
|
|
||||||
case "m":
|
|
||||||
can.run(event, ["search", "Storm.onaction.create"])
|
|
||||||
break
|
|
||||||
case " ":
|
|
||||||
can.search.focus()
|
|
||||||
can.search.setSelectionRange(0, -1)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
return
|
|
||||||
}
|
|
||||||
event.stopPropagation()
|
|
||||||
event.preventDefault()
|
|
||||||
}
|
|
||||||
document.body.onkeyup = function(event) {
|
|
||||||
console.log(event)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
demo: function(can, msg, cmd, cb) {
|
|
||||||
msg.Echo("hello demo world")
|
|
||||||
cb(msg)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta, list, cb, target) {
|
||||||
|
typeof cb == "function" && cb()
|
||||||
can.sublist = {}
|
can.sublist = {}
|
||||||
},
|
},
|
||||||
storm: function(event, can, river) {
|
storm: function(event, can, river) {
|
||||||
@ -17,8 +18,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, meta,
|
|||||||
|
|
||||||
can.page.Select(can, can._output, "div.subitem.select", function(item) {
|
can.page.Select(can, can._output, "div.subitem.select", function(item) {
|
||||||
can.page.ClassList.del(can, item, "select")
|
can.page.ClassList.del(can, item, "select")
|
||||||
})
|
}), can.page.ClassList.add(can, event.target, "select")
|
||||||
can.page.ClassList.add(can, event.target, "select")
|
|
||||||
}, oncontextmenu: function(event) {
|
}, oncontextmenu: function(event) {
|
||||||
can.user.carte(can, {}, ["添加工具", "保存", "删除"], function(ev, item, meta) {
|
can.user.carte(can, {}, ["添加工具", "保存", "删除"], function(ev, item, meta) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
@ -85,6 +85,7 @@ Volcanos("ondetail", {help: "菜单交互", list: ["添加应用", "添加设备
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
"添加应用": function(event, can, river, button) {
|
"添加应用": function(event, can, river, button) {
|
||||||
can.user.input(event, can, [
|
can.user.input(event, can, [
|
||||||
["类型", "public", "protected", "private"],
|
["类型", "public", "protected", "private"],
|
||||||
|
@ -27,6 +27,11 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
|
|||||||
]}, {view: "tags"}, ]},
|
]}, {view: "tags"}, ]},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
if (can.Conf("content")) {
|
||||||
|
msg = can.request({})
|
||||||
|
msg.result = [can.Conf("content")]
|
||||||
|
}
|
||||||
|
|
||||||
can.tabview = {}, can.history = []
|
can.tabview = {}, can.history = []
|
||||||
can.tabview[can.Option("path")+can.Option("file")] = msg
|
can.tabview[can.Option("path")+can.Option("file")] = msg
|
||||||
msg.Option({path: can.Option("path"), file: can.Option("file"), line: can.Option("line")||1})
|
msg.Option({path: can.Option("path"), file: can.Option("file"), line: can.Option("line")||1})
|
||||||
@ -95,7 +100,7 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"],
|
|||||||
|
|
||||||
can.Status("文件名", can.file), can.Status("解析器", can.parse)
|
can.Status("文件名", can.file), can.Status("解析器", can.parse)
|
||||||
can.Status("当前行", can.onexport.position(can, 0))
|
can.Status("当前行", can.onexport.position(can, 0))
|
||||||
can.Status("输入法", "normal")
|
can.Status("模式", "normal")
|
||||||
}
|
}
|
||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
@ -163,6 +168,20 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
|||||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||||
},
|
},
|
||||||
"运行": function(event, can) {
|
"运行": function(event, can) {
|
||||||
|
if (can.ui.editor) {
|
||||||
|
var msg = can.request(event); msg.Option("content", can.onexport.content(can))
|
||||||
|
can.run(event, ["action", "save", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||||
|
can.user.toast(can, "保存成功")
|
||||||
|
can.run({}, ["action", "engine", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||||
|
(msg.Result() || msg.append && msg.append.length > 0) && can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "block"}})
|
||||||
|
can.onappend.table(can, can.ui.display, "table", msg)
|
||||||
|
can.onappend.board(can, can.ui.display, "board", msg)
|
||||||
|
can.user.toast(can, "运行成功")
|
||||||
|
}, true)
|
||||||
|
}, true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "none"}})
|
can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "none"}})
|
||||||
can.run(event, ["action", "engine", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
can.run(event, ["action", "engine", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||||
(msg.Result() || msg.append && msg.append.length > 0) && can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "block"}})
|
(msg.Result() || msg.append && msg.append.length > 0) && can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "block"}})
|
||||||
@ -175,6 +194,7 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
|||||||
var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 120
|
var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 120
|
||||||
can.page.Modify(can, can.ui.content, {style: {"max-width": hide? width+"px": ""}})
|
can.page.Modify(can, can.ui.content, {style: {"max-width": hide? width+"px": ""}})
|
||||||
hide && can.onimport.project(can, can.Option("path"))
|
hide && can.onimport.project(can, can.Option("path"))
|
||||||
|
can.onaction.selectLine(can, can.current)
|
||||||
},
|
},
|
||||||
"搜索": function(event, can) { var hide = can.ui.search.style.display == "none"
|
"搜索": function(event, can) { var hide = can.ui.search.style.display == "none"
|
||||||
can.page.Modify(can, can.ui.search, {style: {display: hide? "": "none"}})
|
can.page.Modify(can, can.ui.search, {style: {display: hide? "": "none"}})
|
||||||
@ -186,8 +206,11 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
|||||||
can.onaction.selectLine(can, index)
|
can.onaction.selectLine(can, index)
|
||||||
}}])
|
}}])
|
||||||
var line = can.page.Append(can, can.ui.content, [{view: ["item", "pre", ""], onclick: function(event) {
|
var line = can.page.Append(can, can.ui.content, [{view: ["item", "pre", ""], onclick: function(event) {
|
||||||
|
can.onkeymap && can.onkeymap._init(can, "insert")
|
||||||
can.onaction.selectLine(can, line)
|
can.onaction.selectLine(can, line)
|
||||||
can.ui.editor && can.ui.editor.focus()
|
can.ui.editor && can.ui.editor.focus()
|
||||||
|
can.editor && can.editor.setSelectionRange(event.offsetX/10, event.offsetX/10)
|
||||||
|
|
||||||
}, ondblclick: function(event) {
|
}, ondblclick: function(event) {
|
||||||
var s = document.getSelection()
|
var s = document.getSelection()
|
||||||
var str = s.baseNode.data
|
var str = s.baseNode.data
|
||||||
@ -232,7 +255,7 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
|||||||
|
|
||||||
can.ui.editor && can.page.Modify(can, can.ui.editor, {className: "editor "+can.mode, value: can.current.innerText, style: {
|
can.ui.editor && can.page.Modify(can, can.ui.editor, {className: "editor "+can.mode, value: can.current.innerText, style: {
|
||||||
height: target.offsetHeight, width: target.offsetWidth,
|
height: target.offsetHeight, width: target.offsetWidth,
|
||||||
left: target.offsetLeft, top: target.offsetTop,
|
left: target.offsetLeft, top: target.offsetTop - target.parentNode.parentNode.scrollTop,
|
||||||
display: "block",
|
display: "block",
|
||||||
}})
|
}})
|
||||||
|
|
||||||
@ -263,7 +286,7 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
|||||||
}, true)
|
}, true)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["输入法", "文件名", "解析器", "当前行", "标签数"],
|
Volcanos("onexport", {help: "导出数据", list: ["模式", "按键", "文件名", "解析器", "当前行", "标签数"],
|
||||||
position: function(can, index, total) { total = total || can.max
|
position: function(can, index, total) { total = total || can.max
|
||||||
return parseInt((index+1)*100/total)+"%"+" = "+(parseInt(index)+1)+"/"+parseInt(total)
|
return parseInt((index+1)*100/total)+"%"+" = "+(parseInt(index)+1)+"/"+parseInt(total)
|
||||||
},
|
},
|
||||||
|
@ -10,9 +10,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
}, onblur: function(event) {
|
}, onblur: function(event) {
|
||||||
can.onaction.modifyLine(can, can.current, can.editor.value)
|
can.onaction.modifyLine(can, can.current, can.editor.value)
|
||||||
}, onclick: function(event) {
|
}, onclick: function(event) {
|
||||||
|
can.onkeymap._insert(can)
|
||||||
}, ondblclick: function(event) {
|
|
||||||
can.onkeymap._mode(can, "insert")
|
|
||||||
}},
|
}},
|
||||||
{view: ["command", "input"], onkeydown: function(event) {
|
{view: ["command", "input"], onkeydown: function(event) {
|
||||||
can.onkeymap.parse(event, can, "command")
|
can.onkeymap.parse(event, can, "command")
|
||||||
@ -20,7 +18,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
])
|
])
|
||||||
can.ui.editor = ui.editor
|
can.ui.editor = ui.editor
|
||||||
can.ui.command = ui.command
|
can.ui.command = ui.command
|
||||||
can.onkeymap._init(can, "normal")
|
can.onkeymap._init(can, "insert")
|
||||||
typeof cb == "function" && cb()
|
typeof cb == "function" && cb()
|
||||||
}, target)
|
}, target)
|
||||||
})
|
})
|
||||||
@ -38,7 +36,7 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
}), can.onkeymap[item]._engine = engine
|
}), can.onkeymap[item]._engine = engine
|
||||||
}), can.onkeymap._mode(can, mode||"normal")
|
}), can.onkeymap._mode(can, mode||"normal")
|
||||||
},
|
},
|
||||||
_mode: function(can, value) { can.Status("输入法", can.mode = value)
|
_mode: function(can, value) { can.Status("模式", can.mode = value)
|
||||||
can.page.Modify(can, can.ui.editor, {className: "editor "+can.mode, style: {display: "none"}})
|
can.page.Modify(can, can.ui.editor, {className: "editor "+can.mode, style: {display: "none"}})
|
||||||
can.page.Modify(can, can.ui.command, {className: "command "+can.mode, style: {display: "none"}})
|
can.page.Modify(can, can.ui.command, {className: "command "+can.mode, style: {display: "none"}})
|
||||||
return value
|
return value
|
||||||
@ -74,14 +72,16 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
parse: function(event, can, mode) {
|
parse: function(event, can, mode) {
|
||||||
event.key.length == 1 && can.history.push(event.key); if (can.mode != mode) {
|
event.key.length == 1 && can.history.push(event.key); if (can.mode != mode) {
|
||||||
event.stopPropagation(), event.preventDefault()
|
event.stopPropagation(), event.preventDefault()
|
||||||
}; can.mode != "command" && can.Status("输入值", can.history.join())
|
}; can.mode != "command" && can.Status("按键", can.history.join(""))
|
||||||
|
|
||||||
for (var pre = 0; pre < can.history.length; pre++) {
|
for (var pre = 0; pre < can.history.length; pre++) {
|
||||||
if ("0" <= can.history[pre] && can.history[pre] <= "9") { continue } break
|
if ("0" <= can.history[pre] && can.history[pre] <= "9") { continue } break
|
||||||
}; can.count = parseInt(can.history.slice(0, pre).join(""))||1
|
}; can.count = parseInt(can.history.slice(0, pre).join(""))||1
|
||||||
|
|
||||||
function repeat(cb, count) {
|
function repeat(cb, count) {
|
||||||
for (var i = 1; i <= count; i++) { if (cb(event, can, count)) { break } }; can.history = []
|
for (var i = 1; i <= count; i++) { if (cb(event, can, count)) { break } }
|
||||||
|
can.history.length > 0 && (can.lastcmd = can.history), can.history = []
|
||||||
|
can.Status("按键", can.history.join(""))
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = can.onsyntax[can.parse]
|
var p = can.onsyntax[can.parse]
|
||||||
@ -97,7 +97,7 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
Escape: function(event, can) { can.onkeymap._normal(can)
|
Escape: function(event, can) { can.onkeymap._normal(can)
|
||||||
can.current.click()
|
can.onaction.selectLine(can, can.current)
|
||||||
},
|
},
|
||||||
Enter: function(event, can) { var line = can.ui.command.value; var ls = can.core.Split(line, " ", ",", {simple: true})
|
Enter: function(event, can) { var line = can.ui.command.value; var ls = can.core.Split(line, " ", ",", {simple: true})
|
||||||
var cb = can.onkeymap._engine[ls[0]]; typeof cb == "function"? cb(event, can, line, ls):
|
var cb = can.onkeymap._engine[ls[0]]; typeof cb == "function"? cb(event, can, line, ls):
|
||||||
@ -110,16 +110,22 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
},
|
},
|
||||||
normal: {
|
normal: {
|
||||||
":": function(event, can) { can.onkeymap._command(can) },
|
":": function(event, can) { can.onkeymap._command(can) },
|
||||||
|
".": function(event, can) {
|
||||||
|
can.history = can.lastcmd
|
||||||
|
can.onkeymap.parse({key: ""}, can, "normal")
|
||||||
|
},
|
||||||
|
|
||||||
h: function(event, can) {
|
h: function(event, can) {
|
||||||
can.editor.setSelectionRange(can.editor.selectionStart-1, can.editor.selectionStart-1)
|
can.editor.setSelectionnRange(can.editor.selectionStart-1, can.editor.selectionStart-1)
|
||||||
},
|
},
|
||||||
l: function(event, can) {
|
l: function(event, can) {
|
||||||
can.editor.setSelectionRange(can.editor.selectionStart+1, can.editor.selectionStart+1)
|
can.editor.setSelectionRange(can.editor.selectionStart+1, can.editor.selectionStart+1)
|
||||||
},
|
},
|
||||||
j: function(event, can) { can.onaction.selectLine(can, can.current.nextSibling)
|
j: function(event, can) {
|
||||||
|
can.onaction.selectLine(can, can.current.nextSibling)
|
||||||
var pos = can.current.offsetTop-can._target.scrollTop; if (pos > 22*15) {
|
var pos = can.current.offsetTop-can._target.scrollTop; if (pos > 22*15) {
|
||||||
can._target.scrollBy(0, 22)
|
can._target.scrollBy(0, 22)
|
||||||
|
can.onaction.selectLine(can, can.current)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
k: function(event, can) { can.onaction.selectLine(can, can.current.previousSibling)
|
k: function(event, can) { can.onaction.selectLine(can, can.current.previousSibling)
|
||||||
@ -129,17 +135,19 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
},
|
},
|
||||||
|
|
||||||
gg: function(event, can, count) { count = count || 1
|
gg: function(event, can, count) { count = count || 1
|
||||||
can.onaction.selectLine(can, count - 1)
|
can.onaction.selectLine(can, count)
|
||||||
can.current.scrollIntoView()
|
can.current.scrollIntoView()
|
||||||
can._target.scrollBy(0, -22*5)
|
can._target.scrollBy(0, -22*5)
|
||||||
|
can.onaction.selectLine(can, count)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
G: function(event, can, count) { count = count || can.max
|
G: function(event, can, count) { count = count > 1? count: can.max
|
||||||
can.onaction.selectLine(can, count - 1)
|
can.onaction.selectLine(can, count)
|
||||||
can.current.scrollIntoView()
|
can.current.scrollIntoView()
|
||||||
if (count - can.max < -5) {
|
if (count - can.max < -5) {
|
||||||
can._target.scrollBy(0, -22*5)
|
can._target.scrollBy(0, -22*5)
|
||||||
}
|
}
|
||||||
|
can.onaction.selectLine(can, count)
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
zt: function(event, can, count) { count = count || 2
|
zt: function(event, can, count) { count = count || 2
|
||||||
@ -168,23 +176,25 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
can.editor.setSelectionRange(-1, -1)
|
can.editor.setSelectionRange(-1, -1)
|
||||||
},
|
},
|
||||||
o: function(event, can) { can.onkeymap._insert(can)
|
o: function(event, can) { can.onkeymap._insert(can)
|
||||||
can.onkeymap.insertLine(can, can.current).click()
|
can.onaction.selectLine(can, can.onkeymap.insertLine(can, can.current))
|
||||||
},
|
},
|
||||||
O: function(event, can) { can.onkeymap._insert(can)
|
O: function(event, can) { can.onkeymap._insert(can)
|
||||||
can.onkeymap.insertLine(can, can.current, "", true).click()
|
can.onaction.selectLine(can, can.onkeymap.insertLine(can, can.current, "", true))
|
||||||
},
|
},
|
||||||
|
|
||||||
yy: function(event, can) { can.last = can.current.innerText },
|
yy: function(event, can) { can.last = can.current.innerText },
|
||||||
dd: function(event, can) { can.last = can.current.innerText
|
dd: function(event, can) { can.last = can.current.innerText
|
||||||
var next = can.current.nextSibling || can.current.previousSibling
|
var next = can.current.nextSibling || can.current.previousSibling
|
||||||
can.onkeymap.deleteLine(can, can.current)
|
can.onkeymap.deleteLine(can, can.current)
|
||||||
next.click()
|
can.onaction.selectLine(can, next)
|
||||||
},
|
},
|
||||||
p: function(event, can) {
|
p: function(event, can) {
|
||||||
can.onkeymap.insertLine(can, can.current, can.last).click()
|
can.onkeymap.insertLine(can, can.current, can.last)
|
||||||
|
can.onaction.selectLine(can, can.current.nextSibling)
|
||||||
},
|
},
|
||||||
P: function(event, can) {
|
P: function(event, can) {
|
||||||
can.onkeymap.insertLine(can, can.current, can.last, true).click()
|
can.onkeymap.insertLine(can, can.current, can.last, true)
|
||||||
|
can.onaction.selectLine(can, can.current.previousSibling)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
insert: {
|
insert: {
|
||||||
@ -193,12 +203,14 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
event.stopPropagation(), event.preventDefault()
|
event.stopPropagation(), event.preventDefault()
|
||||||
},
|
},
|
||||||
Enter: function(event, can) {
|
Enter: function(event, can) {
|
||||||
can.onkeymap.insert.Escape(event, can)
|
var before = can.editor.value.slice(0, event.target.selectionEnd)
|
||||||
can.onkeymap.insertLine(can, can.current, "", event.shiftKey).click()
|
var left = can.editor.value.slice(event.target.selectionEnd)
|
||||||
can.onkeymap._insert(can)
|
left && can.onaction.modifyLine(can, can.current, before)
|
||||||
|
can.onaction.selectLine(can, can.onkeymap.insertLine(can, can.current, left))
|
||||||
|
can.editor && can.editor.setSelectionRange(0, 0)
|
||||||
},
|
},
|
||||||
Backspace: function(event, can) { if (can.editor.selectionStart > 0) { return }
|
Backspace: function(event, can) { if (can.editor.selectionStart > 0) { return }
|
||||||
can.onkeymap.mergeLine(can, can.current.previousSibling).click()
|
can.onkeymap.mergeLine(can, can.current.previousSibling)
|
||||||
event.stopPropagation(), event.preventDefault()
|
event.stopPropagation(), event.preventDefault()
|
||||||
},
|
},
|
||||||
ArrowDown: function(event, can) {
|
ArrowDown: function(event, can) {
|
||||||
@ -214,7 +226,7 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
},
|
},
|
||||||
|
|
||||||
insertLine: function(can, target, value, before) { var line = can.onaction.appendLine(can, value)
|
insertLine: function(can, target, value, before) { var line = can.onaction.appendLine(can, value)
|
||||||
can.ui.content.insertBefore(line, before && target || target.nextSibling)
|
can.ui.content.insertBefore(line, before || target && target.nextSibling)
|
||||||
return line
|
return line
|
||||||
},
|
},
|
||||||
deleteLine: function(can, target) { can.page.Remove(can, target)
|
deleteLine: function(can, target) { can.page.Remove(can, target)
|
||||||
@ -222,8 +234,11 @@ Volcanos("onkeymap", {help: "键盘交互", list: ["command", "normal", "insert"
|
|||||||
can.page.Remove(can, ls[ls.length-1]), can.max--
|
can.page.Remove(can, ls[ls.length-1]), can.max--
|
||||||
},
|
},
|
||||||
mergeLine: function(can, target) { if (!target) {return}
|
mergeLine: function(can, target) { if (!target) {return}
|
||||||
can.onaction.modifyLine(can, target, target.innerHTML + target.nextSibling.innerHTML)
|
var before = target.innerText
|
||||||
|
can.onaction.modifyLine(can, target, before + target.nextSibling.innerText)
|
||||||
can.onkeymap.deleteLine(can, target.nextSibling)
|
can.onkeymap.deleteLine(can, target.nextSibling)
|
||||||
|
can.onaction.selectLine(can, target)
|
||||||
|
can.ui.editor.setSelectionRange(before.length, before.length)
|
||||||
return target
|
return target
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -108,7 +108,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ondblclick: function(event) {
|
ondblclick: function(event) {
|
||||||
can.onappend.modify(can, event.target, function(ev, value, old) {
|
can.onmotion.modify(can, event.target, function(ev, value, old) {
|
||||||
can.onaction.modifyTask(event, can, task, key, value)
|
can.onaction.modifyTask(event, can, task, key, value)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -116,7 +116,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
can.user.carte(can, can.ondetail, ["编辑"].concat(can.ondetail.list), function(event, item, meta) {
|
can.user.carte(can, can.ondetail, ["编辑"].concat(can.ondetail.list), function(event, item, meta) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case "编辑":
|
case "编辑":
|
||||||
can.onappend.modify(can, target, function(ev, value, old) {
|
can.onmotion.modify(can, target, function(ev, value, old) {
|
||||||
can.onaction.modifyTask(event, can, task, key, value)
|
can.onaction.modifyTask(event, can, task, key, value)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
can.page.Modify(can, can._action, {style: {display: "none"}})
|
can.page.Modify(can, can._action, {style: {display: "none"}})
|
||||||
typeof cb == "function" && cb()
|
typeof cb == "function" && cb()
|
||||||
can.list = msg.Table()||[]
|
|
||||||
|
|
||||||
can.begin = 0
|
can.begin = 0
|
||||||
can.Action("倍速", 1)
|
can.Action("倍速", can.rate = 1)
|
||||||
can.Action("数量", can.limit = parseInt(msg.Option("limit"))||3)
|
can.Action("数量", can.limit = parseInt(msg.Option("limit"))||3)
|
||||||
can.Action("高度", can.height = parseInt(msg.Option("height"))||200)
|
can.Action("高度", can.height = parseInt(msg.Option("height"))||200)
|
||||||
can.Option("path") != "最近/" && can.onimport.page(can, can.list, can.begin, can.limit)
|
can.Option("path") != "最近/" && can.onimport.page(can, can._msg.Table(), can.begin, can.limit)
|
||||||
},
|
},
|
||||||
page: function(can, list, begin, limit) { can._target.innerHTML = ""
|
page: function(can, list, begin, limit) { can._target.innerHTML = ""
|
||||||
for (var i = begin; i < begin+limit; i++) { list[i] && can.onimport.file(can, list[i].path) }
|
for (var i = begin; i < begin+limit; i++) { list[i] && can.onimport.file(can, list[i].path) }
|
||||||
can.Status("begin", begin), can.Status("limit", limit), can.Status("total", can.list.length)
|
can.Status("begin", begin), can.Status("limit", limit), can.Status("total", can._msg.Table().length)
|
||||||
},
|
},
|
||||||
file: function(can, path) { can.Status("文件", path)
|
file: function(can, path) { can.Status("文件", path)
|
||||||
var p = location.href.startsWith("http")? "": "http://localhost:9020"
|
var p = location.href.startsWith("http")? "": "http://localhost:9020"
|
||||||
@ -75,19 +74,19 @@ Volcanos("onaction", {help: "组件菜单", list: [
|
|||||||
can.page.Modify(can, can._action, {style: {display: can._action.style.display=="none"? "block": "none"}})
|
can.page.Modify(can, can._action, {style: {display: can._action.style.display=="none"? "block": "none"}})
|
||||||
},
|
},
|
||||||
"上一页": function(event, can, key, value) {
|
"上一页": function(event, can, key, value) {
|
||||||
can.begin > 0 && (can.begin -= can.limit, can.onimport.page(can, can.list, can.begin, can.limit))
|
can.begin > 0 && (can.begin -= can.limit, can.onimport.page(can, can._msg.Table(), can.begin, can.limit))
|
||||||
},
|
},
|
||||||
"下一页": function(event, can, key, value) {
|
"下一页": function(event, can, key, value) {
|
||||||
can.begin + can.limit < can.list.length && (can.begin += can.limit, can.onimport.page(can, can.list, can.begin, can.limit))
|
can.begin + can.limit < can._msg.Table().length && (can.begin += can.limit, can.onimport.page(can, can._msg.Table(), can.begin, can.limit))
|
||||||
},
|
},
|
||||||
"数量": function(event, can, key, value) {
|
"数量": function(event, can, key, value) {
|
||||||
can.limit = parseInt(value), can.onimport.page(can, can.list, can.begin, can.limit)
|
can.limit = parseInt(value), can.onimport.page(can, can._msg.Table(), can.begin, can.limit)
|
||||||
},
|
},
|
||||||
"高度": function(event, can, key, value) {
|
"高度": function(event, can, key, value) {
|
||||||
can.height = parseInt(value), can.onimport.page(can, can.list, can.begin, can.limit)
|
can.height = parseInt(value), can.onimport.page(can, can._msg.Table(), can.begin, can.limit)
|
||||||
},
|
},
|
||||||
"倍速": function(event, can, key, value) {
|
"倍速": function(event, can, key, value) {
|
||||||
can.rate = parseInt(value), can.onimport.page(can, can.list, can.begin, can.limit)
|
can.rate = parseInt(value), can.onimport.page(can, can._msg.Table(), can.begin, can.limit)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: ["begin", "limit", "total", "position", "文件"],
|
Volcanos("onexport", {help: "导出数据", list: ["begin", "limit", "total", "position", "文件"],
|
||||||
|
@ -11,6 +11,11 @@ fieldset h3.story {
|
|||||||
fieldset p.story {
|
fieldset p.story {
|
||||||
white-space:pre;
|
white-space:pre;
|
||||||
}
|
}
|
||||||
|
fieldset p.story.shell {
|
||||||
|
padding:4px;
|
||||||
|
border-left:solid 4px blue;
|
||||||
|
background-color:#c2daef;
|
||||||
|
}
|
||||||
fieldset br.story {
|
fieldset br.story {
|
||||||
clear:both;
|
clear:both;
|
||||||
}
|
}
|
||||||
|
@ -113,11 +113,15 @@ Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "横向",
|
|||||||
{type: "text", name: "file", value: tree.file},
|
{type: "text", name: "file", value: tree.file},
|
||||||
{type: "text", name: "line", value: tree.line},
|
{type: "text", name: "line", value: tree.line},
|
||||||
{type: "button", name: "查看", value: "auto"},
|
{type: "button", name: "查看", value: "auto"},
|
||||||
|
{type: "button", name: "关闭"},
|
||||||
], index: "web.code.inner", feature: {
|
], index: "web.code.inner", feature: {
|
||||||
display: "/plugin/local/code/inner.js", style: "editor", width: 800, height: 600,
|
display: "/plugin/local/code/inner.js", style: "editor", width: 800, height: 600,
|
||||||
action: ["关闭"],
|
|
||||||
}}, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
}}, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||||
sub.run = function(event, cmds, cb, silent) {
|
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||||
|
if (msg.Option("_action") == "关闭") {
|
||||||
|
can.page.Remove(can, tree.inner._target)
|
||||||
|
return
|
||||||
|
}
|
||||||
can.run(event, ["inner"].concat(cmds), cb, true)
|
can.run(event, ["inner"].concat(cmds), cb, true)
|
||||||
}
|
}
|
||||||
}, document.body)
|
}, document.body)
|
||||||
|
97
proto.js
97
proto.js
@ -2,41 +2,41 @@ function shy(help, meta, list, cb) {
|
|||||||
var index = -1, value = "", type = "string", args = arguments; function next(check) {
|
var index = -1, value = "", type = "string", args = arguments; function next(check) {
|
||||||
if (++index >= args.length) {return false}
|
if (++index >= args.length) {return false}
|
||||||
if (check && check != typeof args[index]) {index--; return false}
|
if (check && check != typeof args[index]) {index--; return false}
|
||||||
return value = args[index], type = typeof value, value;
|
return value = args[index], type = typeof value, value
|
||||||
}
|
}
|
||||||
|
|
||||||
var cb = arguments[arguments.length-1] || function() {};
|
var cb = arguments[arguments.length-1] || function() {}
|
||||||
cb.help = next("string") || cb.name;
|
cb.help = next("string") || cb.name
|
||||||
cb.meta = next("object") || {};
|
cb.meta = next("object") || {}
|
||||||
cb.list = next("object") || [];
|
cb.list = next("object") || []
|
||||||
return cb;
|
return cb
|
||||||
}
|
}
|
||||||
var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
||||||
volcano: false, config: true,
|
volcano: false, config: true,
|
||||||
require: true, cache: false, frame: false,
|
require: true, cache: false, frame: false,
|
||||||
request: true, search: true,
|
request: true, search: true,
|
||||||
}, libs: []}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
|
}, libs: []}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list
|
||||||
if (typeof name == "object") { var Config = name;
|
if (typeof name == "object") { var Config = name
|
||||||
meta.volcano = Config.volcano, meta.libs = Config.libs;
|
meta.volcano = Config.volcano, meta.libs = Config.libs
|
||||||
var Preload = Config.libs; Config.panes.forEach(function(pane) {
|
var Preload = Config.libs; Config.panes.forEach(function(pane) {
|
||||||
pane.list = pane.list || ["/pane/"+pane.name+".css", "/pane/"+pane.name+".js"]
|
pane.list = pane.list || ["/pane/"+pane.name+".css", "/pane/"+pane.name+".js"]
|
||||||
Preload = Preload.concat(pane.list)
|
Preload = Preload.concat(pane.list)
|
||||||
}); Preload = Preload.concat(Config.plugin)
|
}); Preload = Preload.concat(Config.plugin)
|
||||||
|
|
||||||
name = Config.name, can = { _target: document.body, _follow: Config.name,
|
name = Config.name, can = { _follow: Config.name,
|
||||||
_head: document.head, _body: document.body,
|
|
||||||
_width: window.innerWidth, _height: window.innerHeight,
|
_width: window.innerWidth, _height: window.innerHeight,
|
||||||
|
_target: document.body, _head: document.head, _body: document.body,
|
||||||
}, libs = Preload.concat(Config.volcano), cb = function(can) {
|
}, libs = Preload.concat(Config.volcano), cb = function(can) {
|
||||||
can.onengine._init(can, can.Conf(Config), [], function(msg) {
|
can.onengine._init(can, can.Conf(Config), [], function(msg) {
|
||||||
}, can._target)
|
}, can._target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var conf = {}, conf_cb = {}, cache = {};
|
var conf = {}, conf_cb = {}, cache = {}
|
||||||
can = can || {}, list.push(can) && (can.__proto__ = {_name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) {
|
can = can || {}, list.push(can) && (can.__proto__ = {_name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) {
|
||||||
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
|
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
|
||||||
if (list[meta.index] == can) { continue }
|
if (list[meta.index] == can) { continue }
|
||||||
cache.push(list[meta.index]);
|
cache.push(list[meta.index])
|
||||||
// 加载缓存
|
// 加载缓存
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,22 +46,22 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
can[cache[i]._name] = cache[i]
|
can[cache[i]._name] = cache[i]
|
||||||
// 加载索引
|
// 加载索引
|
||||||
}
|
}
|
||||||
meta.cache[name] = cache;
|
meta.cache[name] = cache
|
||||||
},
|
},
|
||||||
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
||||||
typeof cb == "function" && setTimeout(function() {cb(can)}, 10);
|
typeof cb == "function" && setTimeout(function() {cb(can)}, 10)
|
||||||
return // 加载完成
|
return // 加载完成
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.debug["require"] && console.debug(can._root, can._name, "require", libs[0]); if (meta.cache[libs[0]]) {
|
meta.debug["require"] && console.debug(can._root, can._name, "require", libs[0]); if (meta.cache[libs[0]]) {
|
||||||
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each)
|
||||||
return // 缓存加载
|
return // 缓存加载
|
||||||
}
|
}
|
||||||
|
|
||||||
var target = libs[0].endsWith(".css")? (can._head||document.head): (can._body||document.body);
|
var target = libs[0].endsWith(".css")? (can._head||document.head): (can._body||document.body)
|
||||||
var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0];
|
var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0]
|
||||||
|
|
||||||
if (source.endsWith(".js")) { var script = document.createElement("script");
|
if (source.endsWith(".js")) { var script = document.createElement("script")
|
||||||
if (can.user && source.indexOf("publish") == 0) {
|
if (can.user && source.indexOf("publish") == 0) {
|
||||||
source += "?pod="+(can.user.Search(can, "pod")||"")
|
source += "?pod="+(can.user.Search(can, "pod")||"")
|
||||||
libs[0] = source
|
libs[0] = source
|
||||||
@ -71,23 +71,23 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
libs[0] = source
|
libs[0] = source
|
||||||
}
|
}
|
||||||
script.src = source, script.onload = function() {
|
script.src = source, script.onload = function() {
|
||||||
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each)
|
||||||
} // 加载脚本
|
} // 加载脚本
|
||||||
target.appendChild(script);
|
target.appendChild(script)
|
||||||
|
|
||||||
} else if (source.endsWith(".css")) { var style = document.createElement("link");
|
} else if (source.endsWith(".css")) { var style = document.createElement("link")
|
||||||
style.rel = "stylesheet", style.type = "text/css";
|
style.rel = "stylesheet", style.type = "text/css"
|
||||||
style.href = source; style.onload = function() {
|
style.href = source; style.onload = function() {
|
||||||
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each)
|
||||||
} // 加载样式
|
} // 加载样式
|
||||||
target.appendChild(style);
|
target.appendChild(style)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
request: function(event, msg, proto) { event = event || {};
|
request: function(event, msg, proto) { event = event || {}
|
||||||
if (!msg && event._msg) { return event._msg }
|
if (!msg && event._msg) { return event._msg }
|
||||||
var ls = (can._name||can._help).split("/")
|
var ls = (can._name||can._help).split("/")
|
||||||
event._pane = ls[ls.length-1]
|
event._pane = ls[ls.length-1]
|
||||||
event._msg = msg = msg || {}, msg._event = event, msg._can = can;
|
event._msg = msg = msg || {}, msg._event = event, msg._can = can
|
||||||
msg.__proto__ = proto || { _name: meta.order++, _create_time: new Date(),
|
msg.__proto__ = proto || { _name: meta.order++, _create_time: new Date(),
|
||||||
Option: function(key, val) {
|
Option: function(key, val) {
|
||||||
if (typeof key == "object") { can.core.Item(key, msg.Option) }
|
if (typeof key == "object") { can.core.Item(key, msg.Option) }
|
||||||
@ -109,9 +109,9 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
Table: shy("遍历数据", function(cb) { if (!msg.append || !msg.append.length || !msg[msg.append[0]]) { return }
|
Table: shy("遍历数据", function(cb) { if (!msg.append || !msg.append.length || !msg[msg.append[0]]) { return }
|
||||||
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
var max = "", len = 0; can.core.List(msg.append, function(key, index) {
|
||||||
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
if (msg[key] && msg[key].length > len) { max = key, len = msg[key].length }
|
||||||
});
|
})
|
||||||
|
|
||||||
return can.core.List(msg[max], function(value, index, array) { var one = {}, res;
|
return can.core.List(msg[max], function(value, index, array) { var one = {}, res
|
||||||
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"").trim() })
|
can.core.List(msg.append, function(key) { one[key] = (msg[key]&&msg[key][index]||"").trim() })
|
||||||
return typeof cb == "function" && (res = cb(one, index, array)) && res != undefined && res || one
|
return typeof cb == "function" && (res = cb(one, index, array)) && res != undefined && res || one
|
||||||
})
|
})
|
||||||
@ -153,7 +153,7 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
Echo: shy("输出响应", function(res) {msg.result = msg.result || []
|
Echo: shy("输出响应", function(res) {msg.result = msg.result || []
|
||||||
msg._hand = true
|
msg._hand = true
|
||||||
for (var i = 0; i < arguments.length; i++) {msg.result.push(arguments[i])}
|
for (var i = 0; i < arguments.length; i++) {msg.result.push(arguments[i])}
|
||||||
return msg;
|
return msg
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
return msg
|
return msg
|
||||||
@ -161,7 +161,7 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
|
|
||||||
Conf: shy("配置器", function(key, value, cb) { if (key == undefined) { return conf }
|
Conf: shy("配置器", function(key, value, cb) { if (key == undefined) { return conf }
|
||||||
if (typeof key == "object") { conf = key; return conf }
|
if (typeof key == "object") { conf = key; return conf }
|
||||||
typeof cb == "function" && (conf_cb[key] = cb);
|
typeof cb == "function" && (conf_cb[key] = cb)
|
||||||
if (value != undefined) {var old = conf[key], res; meta.debug["config"] && console.debug(can._root, can._name, "config", key, value, old)
|
if (value != undefined) {var old = conf[key], res; meta.debug["config"] && console.debug(can._root, can._name, "config", key, value, old)
|
||||||
conf[key] = conf_cb[key] && (res = conf_cb[key](value, old, key)) != undefined && res || value
|
conf[key] = conf_cb[key] && (res = conf_cb[key](value, old, key)) != undefined && res || value
|
||||||
}
|
}
|
||||||
@ -170,43 +170,42 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
Cache: shy("缓存器", function(name, output, data) {
|
Cache: shy("缓存器", function(name, output, data) {
|
||||||
if (data) { if (output.children.length == 0) { return }
|
if (data) { if (output.children.length == 0) { return }
|
||||||
// 写缓存
|
// 写缓存
|
||||||
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]
|
||||||
item.parentNode.removeChild(item);
|
item.parentNode.removeChild(item)
|
||||||
temp.appendChild(item);
|
temp.appendChild(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
cache[name] = {node: temp, data: data}
|
cache[name] = {node: temp, data: data}
|
||||||
console.log(can._root, can._name, "save", name, cache[name]);
|
console.log(can._root, can._name, "save", name, cache[name])
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
output.innerHTML = ""
|
output.innerHTML = ""
|
||||||
var list = cache[name]; if (!list) {return}
|
var list = cache[name]; if (!list) {return}
|
||||||
console.log(can._root, can._name, "load", name, cache[name]);
|
console.log(can._root, can._name, "load", name, cache[name])
|
||||||
|
|
||||||
// 读缓存
|
// 读缓存
|
||||||
while (list.node.childNodes.length>0) {
|
while (list.node.childNodes.length>0) {
|
||||||
var item = list.node.childNodes[0];
|
var item = list.node.childNodes[0]
|
||||||
item.parentNode.removeChild(item);
|
item.parentNode.removeChild(item)
|
||||||
output.appendChild(item);
|
output.appendChild(item)
|
||||||
}
|
}
|
||||||
delete(cache[name]);
|
delete(cache[name])
|
||||||
return list.data;
|
return list.data
|
||||||
}),
|
}),
|
||||||
Timer: shy("定时器, value, [1,2,3,4], {value, length}", function(interval, cb, cbs) { interval = typeof interval == "object"? interval || []: [interval];
|
Timer: shy("定时器, value, [1,2,3,4], {value, length}", function(interval, cb, cbs) { interval = typeof interval == "object"? interval || []: [interval]
|
||||||
var timer = {stop: false};
|
var timer = {stop: false}
|
||||||
function loop(event, i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(event, interval)}
|
function loop(event, i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(event, interval)}
|
||||||
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
|
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
|
||||||
typeof cbs == "function" && cbs(event, interval):
|
typeof cbs == "function" && cbs(event, interval):
|
||||||
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1]);
|
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1])
|
||||||
}
|
}
|
||||||
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0]);
|
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0])
|
||||||
return timer;
|
return timer
|
||||||
}),
|
}),
|
||||||
});
|
})
|
||||||
|
|
||||||
return can.require(libs, cb), can
|
return can.require(libs, cb), can
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user