mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt action.js
This commit is contained in:
parent
aa7aa6cfd4
commit
b3740c74ee
31
frame.js
31
frame.js
@ -15,6 +15,9 @@ Volcanos(chat.ONENGINE, {help: "搜索引擎", list: [], _init: function(can, me
|
|||||||
return (can.onengine[cmds[0]]||can.onengine._remote)(event, can, msg, panel, cmds, cb)
|
return (can.onengine[cmds[0]]||can.onengine._remote)(event, can, msg, panel, cmds, cb)
|
||||||
}, can[item.name] = panel, panel._root = can, panel._trans = panel.onaction && panel.onaction._trans||{}
|
}, can[item.name] = panel, panel._root = can, panel._trans = panel.onaction && panel.onaction._trans||{}
|
||||||
|
|
||||||
|
can.core.Item(panel.onplugin, function(key, cmd) {
|
||||||
|
panel.onplugin.hasOwnProperty(key) && can.base.isFunc(cmd) && can.onengine.plugin(can, key, cmd)
|
||||||
|
})
|
||||||
can.core.ItemCB(panel.onaction, function(key, cb) {
|
can.core.ItemCB(panel.onaction, function(key, cb) {
|
||||||
can.onengine.listen(can, key, function(msg) { can.core.CallFunc(cb, {can: panel, msg: msg}) })
|
can.onengine.listen(can, key, function(msg) { can.core.CallFunc(cb, {can: panel, msg: msg}) })
|
||||||
}), can.core.CallFunc([panel.onaction, chat._INIT], {can: panel, cb: next, target: panel._target})
|
}), can.core.CallFunc([panel.onaction, chat._INIT], {can: panel, cb: next, target: panel._target})
|
||||||
@ -48,19 +51,6 @@ Volcanos(chat.ONENGINE, {help: "搜索引擎", list: [], _init: function(can, me
|
|||||||
button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2),
|
button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2),
|
||||||
}, mod)
|
}, mod)
|
||||||
},
|
},
|
||||||
_engine: function(event, can, msg, panel, cmds, cb) {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
_plugin: function(event, can, msg, panel, cmds, cb) {
|
|
||||||
if (cmds[0] == ctx.ACTION && cmds[1] == ice.RUN && can.onengine.plugin.meta[cmds[2]]) {
|
|
||||||
return can.core.CallFunc(can.onengine.plugin.meta[cmds[2]], {msg: msg, cmds: cmds.slice(3), cb: cb}), true
|
|
||||||
}
|
|
||||||
var p = can.onengine.plugin.meta[cmds[0]], n = 1; if (p) {
|
|
||||||
if (p.meta && p.meta[cmds[1]] && cmds[0] == ctx.ACTION) { n = 3 } else if (p.meta && p.meta[cmds[0]]) { n = 2 }
|
|
||||||
return can.core.CallFunc(p, {can: can, msg: msg, cmds: cmds.slice(n), cb: cb}), true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
_remote: function(event, can, msg, panel, cmds, cb) {
|
_remote: function(event, can, msg, panel, cmds, cb) {
|
||||||
msg.option = can.core.List(msg.option, function(item) {
|
msg.option = can.core.List(msg.option, function(item) {
|
||||||
return {_toast: true, _handle: true}[item] && delete(msg[item])? undefined: item
|
return {_toast: true, _handle: true}[item] && delete(msg[item])? undefined: item
|
||||||
@ -85,6 +75,19 @@ Volcanos(chat.ONENGINE, {help: "搜索引擎", list: [], _init: function(can, me
|
|||||||
toast && toast.close(), toast = true, delete(msg._toast)
|
toast && toast.close(), toast = true, delete(msg._toast)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
_engine: function(event, can, msg, panel, cmds, cb) {
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
_plugin: function(event, can, msg, panel, cmds, cb) {
|
||||||
|
if (cmds[0] == ctx.ACTION && cmds[1] == ice.RUN && can.onengine.plugin.meta[cmds[2]]) {
|
||||||
|
return can.core.CallFunc(can.onengine.plugin.meta[cmds[2]], {can: panel, msg: msg, cmds: cmds.slice(3), cb: cb}), true
|
||||||
|
}
|
||||||
|
var p = can.onengine.plugin.meta[cmds[0]], n = 1; if (p) {
|
||||||
|
if (p.meta && p.meta[cmds[1]] && cmds[0] == ctx.ACTION) { n = 3 } else if (p.meta && p.meta[cmds[0]]) { n = 2 }
|
||||||
|
return can.core.CallFunc(p, {can: panel, msg: msg, cmds: cmds.slice(n), cb: cb}), true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
|
||||||
plugin: shy("添加插件", function(can, name, command) { name = can.base.trimPrefix(name, "can.")
|
plugin: shy("添加插件", function(can, name, command) { name = can.base.trimPrefix(name, "can.")
|
||||||
var type = html.TEXT; command.list = can.core.List(command.list, function(item) {
|
var type = html.TEXT; command.list = can.core.List(command.list, function(item) {
|
||||||
@ -151,7 +154,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", list: [], _init: function(can, me
|
|||||||
},
|
},
|
||||||
}, list, function(sub) { sub.Conf(meta), meta.feature = can.base.Obj(meta.feature, {})
|
}, list, function(sub) { sub.Conf(meta), meta.feature = can.base.Obj(meta.feature, {})
|
||||||
can.page.ClassList.add(can, field, meta.index? meta.index.split(ice.PT).pop(): meta.name)
|
can.page.ClassList.add(can, field, meta.index? meta.index.split(ice.PT).pop(): meta.name)
|
||||||
var style = can.base.getValid(meta.style, meta.feature.style); switch (typeof style) {
|
var style = can.base.getValid(meta.style||meta.feature.style); switch (typeof style) {
|
||||||
case lang.STRING: can.page.ClassList.add(can, field, style); break
|
case lang.STRING: can.page.ClassList.add(can, field, style); break
|
||||||
case lang.OBJECT: can.page.style(can, sub._target, style); break
|
case lang.OBJECT: can.page.style(can, sub._target, style); break
|
||||||
}
|
}
|
||||||
|
313
panel/action.js
313
panel/action.js
@ -1,8 +1,8 @@
|
|||||||
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg) {
|
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg) {
|
||||||
var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM)
|
var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM)
|
||||||
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) {
|
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) {
|
||||||
item.height = can.Conf(html.HEIGHT)-can.Conf(html.MARGIN_Y)
|
item.height = can.ConfHeight()-can.Conf(html.MARGIN_Y)
|
||||||
item.width = can.Conf(html.WIDTH)-can.Conf(html.MARGIN_X)
|
item.width = can.ConfWidth()-can.Conf(html.MARGIN_X)
|
||||||
item.feature = can.base.Obj(item.feature||item.meta)
|
item.feature = can.base.Obj(item.feature||item.meta)
|
||||||
item.inputs = can.base.Obj(item.inputs||item.list)
|
item.inputs = can.base.Obj(item.inputs||item.list)
|
||||||
|
|
||||||
@ -10,23 +10,23 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
|||||||
can.onimport._plugin(can, river, storm, sub, meta), skip || next()
|
can.onimport._plugin(can, river, storm, sub, meta), skip || next()
|
||||||
})
|
})
|
||||||
}, function() {
|
}, function() {
|
||||||
can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||Volcanos.meta.args.layout||"auto", true)
|
can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||Volcanos.meta.args.layout, true)
|
||||||
can.onimport._menu(can, msg), can.onkeymap._init(can)
|
can.onimport._menu(can, msg), can.onkeymap._init(can)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_plugin: function(can, river, storm, sub, meta) { sub._target._meta = meta
|
_plugin: function(can, river, storm, sub, meta) { sub._target._meta = meta
|
||||||
|
meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id)
|
||||||
|
|
||||||
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
||||||
return can.run(event, can.misc.concat(can, [river, storm, meta.id||meta.index], cmds), function(msg) {
|
return can.run(event, can.misc.concat(can, [river, storm, meta.id||meta.index], cmds), function(msg) {
|
||||||
can.base.isFunc(cb) && cb(msg)
|
can.base.isFunc(cb) && cb(msg)
|
||||||
})
|
})
|
||||||
}, can._plugins = can.misc.concat(can, can._plugins, [sub])
|
}, can._plugins = can.misc.concat(can, can._plugins, [sub])
|
||||||
|
|
||||||
meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id)
|
can.page.style(can, sub._output, html.MAX_WIDTH, meta.width-(can.user.isWindows? 20: 0))
|
||||||
|
can.onengine.listen(can, chat.ORIENTATIONCHANGE, function(event) {
|
||||||
can.onengine.listen(can, "orientationchange", function(event) {
|
|
||||||
can.page.style(can, sub._output, html.MAX_WIDTH, meta.width-(can.user.isWindows? 20: 0))
|
can.page.style(can, sub._output, html.MAX_WIDTH, meta.width-(can.user.isWindows? 20: 0))
|
||||||
})
|
})
|
||||||
can.page.style(can, sub._output, html.MAX_WIDTH, meta.width-(can.user.isWindows? 20: 0))
|
|
||||||
|
|
||||||
can.page.Append(can, can._action, [{view: [html.TABS, html.DIV, meta.name], onclick: function(event) {
|
can.page.Append(can, can._action, [{view: [html.TABS, html.DIV, meta.name], onclick: function(event) {
|
||||||
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, sub._target)
|
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, sub._target)
|
||||||
@ -38,25 +38,6 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
|||||||
can.core.CallFunc([can.onaction, list[0]], [can, button])
|
can.core.CallFunc([can.onaction, list[0]], [can, button])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
_share: function(can, share) { share && can.run({}, ["_share", share], function(msg) {
|
|
||||||
can.user.title(msg.OptionOrSearch(chat.TITLE))
|
|
||||||
can.setHeader(chat.TOPIC, msg.OptionOrSearch(chat.TOPIC))
|
|
||||||
|
|
||||||
if (msg.Length() == 1) {
|
|
||||||
can.search(event, ["Header.onmotion.hidden"])
|
|
||||||
can.search(event, ["Footer.onmotion.hidden"])
|
|
||||||
can.page.ClassList.add(can, can._target, "cmd")
|
|
||||||
can.Conf(html.HEIGHT, can._root._height)
|
|
||||||
can.Conf(html.WIDTH, can._root._width)
|
|
||||||
}
|
|
||||||
|
|
||||||
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
|
||||||
can.onlayout._init(can, document.body)
|
|
||||||
|
|
||||||
can.Conf(chat.RIVER, "_share", chat.STORM, share)
|
|
||||||
msg.Length() > 0 && can.onimport._init(can, msg)
|
|
||||||
}) },
|
|
||||||
_cmd: function(can, item, next) {
|
_cmd: function(can, item, next) {
|
||||||
can.base.Copy(item, {
|
can.base.Copy(item, {
|
||||||
height: can._root._height-can.Conf(html.MARGIN_Y)+(can.user.isWindows? 17: 0),
|
height: can._root._height-can.Conf(html.MARGIN_Y)+(can.user.isWindows? 17: 0),
|
||||||
@ -68,13 +49,24 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
|||||||
can.user.title(meta.name), skip || next()
|
can.user.title(meta.name), skip || next()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
_share: function(can, share) { share && can.run({}, ["_share", share], function(msg) {
|
||||||
|
can.setHeader(chat.TOPIC, msg.OptionOrSearch(chat.TOPIC))
|
||||||
|
can.user.title(msg.OptionOrSearch(chat.TITLE))
|
||||||
|
|
||||||
|
msg.Length() == 1 && can.onengine.signal(can, chat.ONACTION_CMD)
|
||||||
|
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
||||||
|
can.onlayout._init(can, can._root._target)
|
||||||
|
|
||||||
|
can.Conf(chat.RIVER, "_share", chat.STORM, share)
|
||||||
|
msg.Length() > 0 && can.onimport._init(can, msg)
|
||||||
|
}) },
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONENGINE, {help: "解析引擎", list: [], _engine: function(event, page, msg, can, cmds, cb) {
|
Volcanos(chat.ONENGINE, {help: "解析引擎", list: [], _engine: function(event, page, msg, can, cmds, cb) {
|
||||||
var storm = can.core.Value(can._root, can.core.Keys(chat.RIVER, cmds[0], chat.STORM, cmds[1]))
|
var storm = can.core.Value(can._root, can.core.Keys(chat.RIVER, cmds[0], chat.STORM, cmds[1]))
|
||||||
if (!storm || cmds.length != 2) { return false }
|
if (!storm || cmds.length != 2) { return false }
|
||||||
|
|
||||||
if (storm.index) { // 命令索引
|
if (storm.index) { // 命令索引
|
||||||
can.run(event, [ctx.ACTION, ctx.COMMAND].concat(storm.index), cb)
|
can.runAction(event, ctx.COMMAND, [storm.index], cb)
|
||||||
} else { // 命令列表
|
} else { // 命令列表
|
||||||
can.core.List(storm.list, function(value) {
|
can.core.List(storm.list, function(value) {
|
||||||
msg.Push(mdb.NAME, value.name||"")
|
msg.Push(mdb.NAME, value.name||"")
|
||||||
@ -83,12 +75,97 @@ Volcanos(chat.ONENGINE, {help: "解析引擎", list: [], _engine: function(event
|
|||||||
msg.Push(ctx.FEATURE, JSON.stringify(value.feature))
|
msg.Push(ctx.FEATURE, JSON.stringify(value.feature))
|
||||||
msg.Push(ctx.INDEX, value.index||"")
|
msg.Push(ctx.INDEX, value.index||"")
|
||||||
msg.Push(ctx.ARGS, value.args||"[]")
|
msg.Push(ctx.ARGS, value.args||"[]")
|
||||||
|
msg.Push(ctx.STYLE, value.style||"")
|
||||||
|
msg.Push(ctx.DISPLAY, value.display||"")
|
||||||
msg.Push(ice.MSG_ACTION, value._action||"")
|
msg.Push(ice.MSG_ACTION, value._action||"")
|
||||||
msg.Push("display", value.display||"")
|
|
||||||
}), can.base.isFunc(cb) && cb(msg)
|
}), can.base.isFunc(cb) && cb(msg)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}})
|
}})
|
||||||
|
Volcanos(chat.ONPLUGIN, {help: "注册插件", list: [],
|
||||||
|
"alert": shy("提示", {}, ["text", "list", "back"], function(can, msg, cmds) {
|
||||||
|
can.user.alert(cmds[0])
|
||||||
|
}),
|
||||||
|
"parse": shy("解析", {
|
||||||
|
"show": function(can, msg, cmds) {
|
||||||
|
can.require(["/plugin/story/parse.js"], function() {
|
||||||
|
can.onmotion.hidden(can, can._legend)
|
||||||
|
can.onmotion.hidden(can, can._option)
|
||||||
|
can.onmotion.hidden(can, can._status)
|
||||||
|
|
||||||
|
can.ConfHeight(can.ConfHeight()+can.Conf(html.MARGIN_Y)-(can.user.isWindows? 17: 0))
|
||||||
|
|
||||||
|
can.onengine.listen(can, "menu", function(msg) { can.user.toast(can, msg.Option(html.ITEM)) })
|
||||||
|
can.onengine.listen(can, "高级配置", function(msg) { can.user.toast(can, msg.Option(html.ITEM)) })
|
||||||
|
can.onengine.listen(can, "h1", function(msg) { can.user.toast(can, "h1") })
|
||||||
|
|
||||||
|
can.onappend.parse(can, can.onappend._parse(can, cmds[0]))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, ["text", "show:button@auto"], function(can, msg, cmds, cb) { can.run({}, cmds, cb, true) }),
|
||||||
|
|
||||||
|
"cookie": shy("提示", {}, ["text", "list", "back"], function(can, msg, cmds) {
|
||||||
|
can.core.Item(can.misc.Cookie(can), function(key, value) {
|
||||||
|
msg.Push("key", key)
|
||||||
|
msg.Push("value", value)
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
"plugin": shy("插件", {}, ["text", "list", "back"], function(can, msg, cmds) {
|
||||||
|
msg.Echo("hello world")
|
||||||
|
}),
|
||||||
|
"info": shy("信息", {}, ["text", "list", "back"], function(can, msg, cmds) {
|
||||||
|
msg.Echo("hello world")
|
||||||
|
}),
|
||||||
|
"log": shy("日志", {}, ["text", "list", "back"], function(can, msg, cmds) {
|
||||||
|
console.log(cmds[0])
|
||||||
|
}),
|
||||||
|
|
||||||
|
"nfs.save": shy("保存文件", {}, ["file=hi.txt", "text:textarea='hello world'", "save:button"], function(can, msg, cmds, cb) {
|
||||||
|
can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||||
|
"save", function(cmds) { can.user.downloads(can, cmds[1], cmds[0]) }
|
||||||
|
))
|
||||||
|
}),
|
||||||
|
|
||||||
|
"pie": shy("比例图", {}, ["list", "back"], function(can, msg, cmds) {
|
||||||
|
msg.DisplayStory("pie.js")
|
||||||
|
msg.Push("value", 200)
|
||||||
|
msg.Push("value", 300)
|
||||||
|
msg.Push("value", 400)
|
||||||
|
}),
|
||||||
|
"can.code.inner.plugin": shy("插件", {}, [{type: "button", name: "list", action: "auto"}, "back"], function(can, msg, cmds) {}),
|
||||||
|
})
|
||||||
|
Volcanos(chat.ONKEYMAP, {help: "键盘交互", list: [], _focus: [], _init: function(can, target) {
|
||||||
|
can.onkeymap._build(can), can.onengine.listen(can, chat.ONKEYDOWN, function(msg, model) {
|
||||||
|
can._keylist = can.onkeymap._parse(msg._event, can, model, can._keylist||[], can._output)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_mode: {
|
||||||
|
normal: {
|
||||||
|
j: function(event, can, target) { target.scrollBy(0, event.ctrlKey? 300: 30) },
|
||||||
|
k: function(event, can, target) { target.scrollBy(0, event.ctrlKey? -300: -30) },
|
||||||
|
|
||||||
|
b: function(event, can, target) { can.search(event, ["Header.onaction.black"]) },
|
||||||
|
w: function(event, can, target) { can.search(event, ["Header.onaction.white"]) },
|
||||||
|
|
||||||
|
g: function(event, can, target) { can.search(event, ["River.ondetail.创建群组"]) },
|
||||||
|
s: function(event, can, target) { can.search(event, ["River.ondetail.添加应用"]) },
|
||||||
|
t: function(event, can, target) { can.search(event, ["River.ondetail.添加工具"]) },
|
||||||
|
|
||||||
|
" ": function(event, can, target) {
|
||||||
|
can.onengine.signal(can, "onsearchfocus"), can.onkeymap.prevent(event)
|
||||||
|
},
|
||||||
|
":": function(event, can, target) {
|
||||||
|
can.onengine.signal(can, "oncommandfocus"), can.onkeymap.prevent(event)
|
||||||
|
},
|
||||||
|
enter: function(event, can, target) { can.misc.Log("enter") },
|
||||||
|
escape: function(event, can, target) {
|
||||||
|
can.page.Select(can, document.body, can.page.Keys(html.FIELDSET_FLOAT, html.DIV_FLOAT), function(item) {
|
||||||
|
can.page.Remove(can, item)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, _engine: {},
|
||||||
|
})
|
||||||
Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb, target) {
|
Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb, target) {
|
||||||
can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN)
|
can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN)
|
||||||
can.Conf(html.MARGIN_X, 4*html.PLUGIN_MARGIN)
|
can.Conf(html.MARGIN_X, 4*html.PLUGIN_MARGIN)
|
||||||
@ -100,60 +177,8 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb
|
|||||||
}}])
|
}}])
|
||||||
}
|
}
|
||||||
|
|
||||||
can.onengine.plugin(can, "parse", shy("解析", {
|
target.ontouchstart = function(event) { can.onengine.signal(can, chat.ONACTION_TOUCH, can.request(event)) }
|
||||||
"show": function(can, msg, cmds) {
|
can.base.isFunc(cb) && cb()
|
||||||
can.require(["/plugin/story/parse.js"], function() {
|
|
||||||
can.onmotion.hidden(can, can._legend)
|
|
||||||
can.onmotion.hidden(can, can._option)
|
|
||||||
can.onmotion.hidden(can, can._status)
|
|
||||||
|
|
||||||
can.ConfHeight(can.ConfHeight()+can.Conf(html.MARGIN_Y)-(can.user.isWindows? 17: 0))
|
|
||||||
|
|
||||||
can.onengine.listen(can, "menu", function(msg) { can.user.toast(can, msg.Option(html.ITEM)) })
|
|
||||||
can.onengine.listen(can, "高级配置", function(msg) { can.user.toast(can, msg.Option(html.ITEM)) })
|
|
||||||
can.onengine.listen(can, "h1", function(msg) { can.user.toast(can, "h1") })
|
|
||||||
|
|
||||||
can.onappend.parse(can, can.onappend._parse(can, cmds[0]))
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}, ["text", "show:button@auto"], function(msg, cmds, cb) { can.run({}, cmds, cb, true) }))
|
|
||||||
|
|
||||||
can.onengine.plugin(can, "cookie", shy("提示", {}, ["text", "list", "back"], function(msg, cmds) {
|
|
||||||
can.core.Item(can.misc.Cookie(can), function(key, value) {
|
|
||||||
msg.Push("key", key)
|
|
||||||
msg.Push("value", value)
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
can.onengine.plugin(can, "alert", shy("提示", {}, ["text", "list", "back"], function(msg, cmds) {
|
|
||||||
can.user.alert(cmds[0])
|
|
||||||
}))
|
|
||||||
can.onengine.plugin(can, "plugin", shy("插件", {}, ["text", "list", "back"], function(msg, cmds) {
|
|
||||||
msg.Echo("hello world")
|
|
||||||
}))
|
|
||||||
can.onengine.plugin(can, "info", shy("信息", {}, ["text", "list", "back"], function(msg, cmds) {
|
|
||||||
msg.Echo("hello world")
|
|
||||||
}))
|
|
||||||
can.onengine.plugin(can, "log", shy("日志", {}, ["text", "list", "back"], function(msg, cmds) {
|
|
||||||
console.log(cmds[0])
|
|
||||||
}))
|
|
||||||
|
|
||||||
can.onengine.plugin(can, "nfs.save", shy("保存文件", {}, ["file=hi.txt", "text:textarea='hello world'", "save:button"], function(msg, cmds, cb) {
|
|
||||||
can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
|
||||||
"save", function(cmds) { can.user.downloads(can, cmds[1], cmds[0]) }
|
|
||||||
))
|
|
||||||
}))
|
|
||||||
|
|
||||||
can.onengine.plugin(can, "pie", shy("比例图", {}, ["list", "back"], function(msg, cmds) {
|
|
||||||
msg.DisplayStory("pie.js")
|
|
||||||
msg.Push("value", 200)
|
|
||||||
msg.Push("value", 300)
|
|
||||||
msg.Push("value", 400)
|
|
||||||
}))
|
|
||||||
can.onengine.plugin(can, "can.code.inner.plugin", shy("插件", {}, [{type: "button", name: "list", action: "auto"}, "back"], function(msg, cmds) {}))
|
|
||||||
|
|
||||||
target.ontouchstart = function(event) {
|
|
||||||
can.onengine.signal(can, chat.ONACTION_TOUCH, can.request(event))
|
|
||||||
}, can.base.isFunc(cb) && cb()
|
|
||||||
},
|
},
|
||||||
_menus: [
|
_menus: [
|
||||||
[chat.LAYOUT, "auto", "tabs", "grid", "free", "flow", "page", "toimage"],
|
[chat.LAYOUT, "auto", "tabs", "grid", "free", "flow", "page", "toimage"],
|
||||||
@ -176,9 +201,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb
|
|||||||
"devops": "编程手册",
|
"devops": "编程手册",
|
||||||
"refer": "参考手册",
|
"refer": "参考手册",
|
||||||
},
|
},
|
||||||
onmain: function(can) {
|
onmain: function(can) { can.onimport._share(can, can.misc.Search(can, web.SHARE)) },
|
||||||
can.onimport._share(can, can.misc.Search(can, web.SHARE))
|
|
||||||
},
|
|
||||||
onlogin: function(can) { if (!can.Conf(chat.TOOL) && !can.user.mod.isCmd) { return }
|
onlogin: function(can) { if (!can.Conf(chat.TOOL) && !can.user.mod.isCmd) { return }
|
||||||
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
can.Conf(html.MARGIN_X, 0, html.MARGIN_Y, 2*html.ACTION_HEIGHT)
|
||||||
can.page.ClassList.add(can, can._target, ice.CMD)
|
can.page.ClassList.add(can, can._target, ice.CMD)
|
||||||
@ -187,101 +210,68 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb
|
|||||||
can._names = location.pathname
|
can._names = location.pathname
|
||||||
can.Conf(chat.TOOL)? can.core.Next(can.Conf(chat.TOOL), function(item, next) {
|
can.Conf(chat.TOOL)? can.core.Next(can.Conf(chat.TOOL), function(item, next) {
|
||||||
can.onimport._cmd(can, item, next)
|
can.onimport._cmd(can, item, next)
|
||||||
|
}): can.runAction(can.request(), ctx.COMMAND, [], function(msg) { can.core.Next(msg.Table(), function(item, next) {
|
||||||
}): can.run(can.request(), [ctx.ACTION, ctx.COMMAND], function(msg) {
|
can.onimport._cmd(can, item, next)
|
||||||
can.core.Next(msg.Table(), function(item, next) {
|
}) })
|
||||||
can.onimport._cmd(can, item, next)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
onstorm_select: function(can, msg, river, storm) { can.onlayout._init(can)
|
onsize: function(can, msg, height, width) { can.Conf({height: height, width: width}) },
|
||||||
|
onsearch: function(can, msg, word) {
|
||||||
|
if (word[0] == mdb.PLUGIN || word[1] != "") { can.onexport.plugin(can, msg, word) }
|
||||||
|
},
|
||||||
|
onstorm_select: function(can, msg, river, storm) {
|
||||||
if (can.onmotion.cache(can, function() {
|
if (can.onmotion.cache(can, function() {
|
||||||
var key = can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm))
|
return can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm))
|
||||||
return key
|
|
||||||
}, can._action, can._output)) {
|
}, can._action, can._output)) {
|
||||||
var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{}
|
var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{}
|
||||||
can.onaction.layout(can, conf.layout||can.misc.SearchOrConf(can, chat.LAYOUT)||Volcanos.meta.args.layout||"auto", true)
|
return can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||Volcanos.meta.args.layout||conf.layout, true)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
can.run({}, [river, storm], function(msg) { if (msg.Length() > 0) { return can.onimport._init(can, msg) }
|
can.run({}, [river, storm], function(msg) { if (msg.Length() > 0) { return can.onimport._init(can, msg) }
|
||||||
can.onengine.signal(can, chat.ONACTION_NOTOOL, can.request({}, {river: river, storm: storm}))
|
can.onengine.signal(can, chat.ONACTION_NOTOOL, can.request({}, {river: river, storm: storm}))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onsearch: function(can, msg, word) {
|
onaction_cmd: function(can, msg) {
|
||||||
if (word[0] == mdb.PLUGIN || word[1] != "") { can.onexport.plugin(can, msg, word) }
|
can.page.ClassList.add(can, can._target, "cmd")
|
||||||
|
can.ConfHeight(can._root._height)
|
||||||
|
can.ConfWidth(can._root._width)
|
||||||
},
|
},
|
||||||
onsize: function(can, msg, height, width) { can.Conf({height: height, width: width}) },
|
|
||||||
|
|
||||||
help: function(can, button) { can.user.open("/help/"+button+".shy") },
|
layout: function(can, button, silent) { button = button||ice.AUTO
|
||||||
layout: function(can, button, silent) {
|
var cb = can.onlayout[button]; if (can.base.isFunc(cb) && cb(can, silent)) { return }
|
||||||
if (button == "toimage") {
|
|
||||||
can.onmotion.toimage(event, can, can.Conf(chat.STORM), can._output)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT))
|
can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT))
|
||||||
can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button))
|
can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button))
|
||||||
|
|
||||||
if (button == "auto") {
|
|
||||||
can.Conf(chat.LAYOUT, "")
|
|
||||||
|
|
||||||
} else if (button == "tabs") {
|
|
||||||
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, 0)
|
|
||||||
can.onmotion.select(can, can._action, html.DIV_TABS, 0)
|
|
||||||
} else if (button == "free") {
|
|
||||||
can.page.Select(can, can._target, [[html.DIV_OUTPUT, html.FIELDSET_PLUGIN]], function(item, index) {
|
|
||||||
can.page.Modify(can, item, {style: {left: 40*index, top: 40*index}})
|
|
||||||
can.onmotion.move(can, item, {left: 40*index, top: 40*index})
|
|
||||||
})
|
|
||||||
} else if (button == "grid") {
|
|
||||||
can.user.input(event, can, [{name: "m", value: 2}, {name: "n", value: 2}], function(event, button, data, list, args) {
|
|
||||||
can.getActionSize(function(height, width) { var m = parseInt(data.m)||2, n = parseInt(data.n)||2
|
|
||||||
can.page.css(can.base.replaceAll(chat.ACTION_LAYOUT_FMT, "_width", (width-(4*m+1)*html.PLUGIN_MARGIN)/m+"px", "_height", (height-(4*n+1)*html.PLUGIN_MARGIN)/n+"px"))
|
|
||||||
})
|
|
||||||
}, silent)
|
|
||||||
}
|
|
||||||
can.onlayout._init(can)
|
can.onlayout._init(can)
|
||||||
},
|
},
|
||||||
|
help: function(can, button) { can.user.open("/help/"+button+".shy") },
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONKEYMAP, {help: "键盘交互", list: [], _focus: [], _init: function(can, target) {
|
Volcanos(chat.ONLAYOUT, {help: "导出数据", list: [],
|
||||||
can.onkeymap._build(can), can.onengine.listen(can, chat.ONKEYDOWN, function(msg, model) {
|
toimage: function(can) {
|
||||||
can._keylist = can.onkeymap._parse(msg._event, can, model, can._keylist||[], can._output)
|
return can.onmotion.toimage(event, can, can.Conf(chat.STORM), can._output), true
|
||||||
|
},
|
||||||
|
auto: function(can) {
|
||||||
|
can.Conf(chat.LAYOUT, "")
|
||||||
|
},
|
||||||
|
tabs: function(can) {
|
||||||
|
can.onmotion.select(can, can._action, html.DIV_TABS, 0)
|
||||||
|
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, 0)
|
||||||
|
},
|
||||||
|
free: function(can) {
|
||||||
|
can.page.Select(can, can._target, [[html.DIV_OUTPUT, html.FIELDSET_PLUGIN]], function(item, index) {
|
||||||
|
can.page.Modify(can, item, {style: {left: 40*index, top: 40*index}})
|
||||||
|
can.onmotion.move(can, item, {left: 40*index, top: 40*index})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_mode: {
|
grid: function(can, silent) {
|
||||||
normal: {
|
var ACTION_LAYOUT_FMT = " fieldset.Action.grid>div.output fieldset.plugin { width:_width; height:_height; } fieldset.Action.grid>div.output fieldset.plugin>div.output { width:_width; height:_height; } "
|
||||||
j: function(event, can, target) { target.scrollBy(0, event.ctrlKey? 300: 30) },
|
can.user.input(event, can, [{name: "m", value: 2}, {name: "n", value: 2}], function(event, button, data, list, args) {
|
||||||
k: function(event, can, target) { target.scrollBy(0, event.ctrlKey? -300: -30) },
|
can.getActionSize(function(height, width) { var m = parseInt(data.m)||2, n = parseInt(data.n)||2
|
||||||
|
can.page.css(can.base.replaceAll(ACTION_LAYOUT_FMT, "_width", (width-(4*m+1)*html.PLUGIN_MARGIN)/m+"px", "_height", (height-(4*n+1)*html.PLUGIN_MARGIN)/n+"px"))
|
||||||
b: function(event, can, target) { can.search(event, ["Header.onaction.black"]) },
|
})
|
||||||
w: function(event, can, target) { can.search(event, ["Header.onaction.white"]) },
|
}, silent)
|
||||||
|
},
|
||||||
g: function(event, can, target) { can.search(event, ["River.ondetail.创建群组"]) },
|
|
||||||
s: function(event, can, target) { can.search(event, ["River.ondetail.添加应用"]) },
|
|
||||||
t: function(event, can, target) { can.search(event, ["River.ondetail.添加工具"]) },
|
|
||||||
|
|
||||||
" ": function(event, can, target) {
|
|
||||||
can.onengine.signal(can, "onsearchfocus")
|
|
||||||
can.onkeymap.prevent(event)
|
|
||||||
},
|
|
||||||
":": function(event, can, target) {
|
|
||||||
can.onengine.signal(can, "oncommandfocus")
|
|
||||||
can.onkeymap.prevent(event)
|
|
||||||
},
|
|
||||||
enter: function(event, can, target) { can.misc.Log("enter") },
|
|
||||||
escape: function(event, can, target) {
|
|
||||||
can.page.Select(can, document.body, html.FIELDSET_AUTO, function(item) {
|
|
||||||
// can.onmotion.hidden(can, item)
|
|
||||||
})
|
|
||||||
can.page.Select(can, document.body, can.page.Keys(html.FIELDSET_FLOAT, html.DIV_FLOAT), function(item) {
|
|
||||||
can.page.Remove(can, item)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}, _engine: {},
|
|
||||||
})
|
})
|
||||||
Volcanos(chat.ONEXPORT, {help: "导出数据", list: [],
|
Volcanos(chat.ONEXPORT, {help: "导出数据", list: [],
|
||||||
args: function(can, cb, target) {
|
args: function(can, msg, cb, target) {
|
||||||
can.core.Next(can.page.Select(can, target, [[html.FIELDSET_PLUGIN, html.FORM_OPTION]]), function(item, next, index, array) {
|
can.core.Next(can.page.Select(can, target, [[html.FIELDSET_PLUGIN, html.FORM_OPTION]]), function(item, next, index, array) {
|
||||||
item.dataset.args = JSON.stringify(can.page.Select(can, item, html.OPTION_ARGS, function(item) { return item.value||"" }))
|
item.dataset.args = JSON.stringify(can.page.Select(can, item, html.OPTION_ARGS, function(item) { return item.value||"" }))
|
||||||
cb(item, next, index, array)
|
cb(item, next, index, array)
|
||||||
@ -303,13 +293,12 @@ Volcanos(chat.ONEXPORT, {help: "导出数据", list: [],
|
|||||||
can.page.Select(can, can._output, [[html.FIELDSET_PLUGIN, html.LEGEND]], function(item) {
|
can.page.Select(can, can._output, [[html.FIELDSET_PLUGIN, html.LEGEND]], function(item) {
|
||||||
if (item.innerHTML.indexOf(word[1]) == -1) { return }
|
if (item.innerHTML.indexOf(word[1]) == -1) { return }
|
||||||
|
|
||||||
var meta = item.parentNode._meta
|
|
||||||
var list = can.page.Select(can, item.nextSibling, html.OPTION_ARGS, function(item) { return item.value||"" })
|
var list = can.page.Select(can, item.nextSibling, html.OPTION_ARGS, function(item) { return item.value||"" })
|
||||||
|
var meta = item.parentNode._meta
|
||||||
|
|
||||||
var data = {ctx: "web.chat", cmd: ctx.ACTION,
|
var data = {ctx: "web.chat", cmd: ctx.ACTION,
|
||||||
type: mdb.PLUGIN, name: item.innerHTML, text: shy("跳转", function(event) {
|
type: mdb.PLUGIN, name: item.innerHTML, text: shy("跳转", function(event) {
|
||||||
var input = can.page.Select(can, item.parentNode, html.INPUT_ARGS)[0]
|
var input = can.page.Select(can, item.parentNode, html.INPUT_ARGS)[0]; input && input.focus()
|
||||||
input && input.focus()
|
|
||||||
}), argument: JSON.stringify(list),
|
}), argument: JSON.stringify(list),
|
||||||
}
|
}
|
||||||
if (meta.index) {
|
if (meta.index) {
|
||||||
|
@ -115,6 +115,7 @@ Volcanos(chat.ONACTION, {help: "交互数据", list: [], _init: function(can, cb
|
|||||||
oncommandfocus: function(can) {
|
oncommandfocus: function(can) {
|
||||||
can.page.Select(can, can._output, "div.cmd input", function(target) { target.focus() })
|
can.page.Select(can, can._output, "div.cmd input", function(target) { target.focus() })
|
||||||
},
|
},
|
||||||
|
onaction_cmd: function(can, msg) { can.onmotion.hidden(can) },
|
||||||
|
|
||||||
_cmd: function(can) {
|
_cmd: function(can) {
|
||||||
return can.onimport.float(can, can._cmds, function(value, key, index, line, list) {
|
return can.onimport.float(can, can._cmds, function(value, key, index, line, list) {
|
||||||
|
@ -183,6 +183,7 @@ Volcanos(chat.ONACTION, {help: "交互数据", list: [], _init: function(can, cb
|
|||||||
can.page.Select(can, can._output, "div.search input", function(target) { target.focus() })
|
can.page.Select(can, can._output, "div.search input", function(target) { target.focus() })
|
||||||
},
|
},
|
||||||
onwebpack: function(can, msg) { can.onaction["webpack"](msg._event, can) },
|
onwebpack: function(can, msg) { can.onaction["webpack"](msg._event, can) },
|
||||||
|
onaction_cmd: function(can, msg) { can.onmotion.hidden(can) },
|
||||||
|
|
||||||
title: function(event, can) {
|
title: function(event, can) {
|
||||||
var args = {}; can.core.List([chat.TITLE, chat.TOPIC, chat.LAYOUT], function(key) {
|
var args = {}; can.core.List([chat.TITLE, chat.TOPIC, chat.LAYOUT], function(key) {
|
||||||
|
@ -6,7 +6,9 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
|||||||
return can.onimport._river(can, item, function(target) {
|
return can.onimport._river(can, item, function(target) {
|
||||||
(index == 0 || item.hash == can._main_river) && (select = target)
|
(index == 0 || item.hash == can._main_river) && (select = target)
|
||||||
})
|
})
|
||||||
})), select && select.click()
|
})), select && can.onmotion.delay(can, function() {
|
||||||
|
can.onlayout._init(can), select.click()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
_main: function(can, msg) {
|
_main: function(can, msg) {
|
||||||
// if (can.user.isMobile) { can._main_river = "product", can._main_storm = "office" }
|
// if (can.user.isMobile) { can._main_river = "product", can._main_storm = "office" }
|
||||||
|
5
proto.js
5
proto.js
@ -148,7 +148,6 @@ var chat = {
|
|||||||
AGENT: "agent", CHECK: "check", GRANT: "grant",
|
AGENT: "agent", CHECK: "check", GRANT: "grant",
|
||||||
STATE: "state", MENUS: "menus", TRANS: "trans",
|
STATE: "state", MENUS: "menus", TRANS: "trans",
|
||||||
SSO: "sso", WEBSITE: "website",
|
SSO: "sso", WEBSITE: "website",
|
||||||
ACTION_LAYOUT_FMT: " fieldset.Action.grid>div.output fieldset.plugin { width:_width; height:_height; } fieldset.Action.grid>div.output fieldset.plugin>div.output { width:_width; height:_height; } ",
|
|
||||||
|
|
||||||
libs: ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"],
|
libs: ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"],
|
||||||
panel_list: [
|
panel_list: [
|
||||||
@ -179,11 +178,13 @@ var chat = {
|
|||||||
|
|
||||||
ONENGINE: "onengine", ONDAEMON: "ondaemon", ONAPPEND: "onappend", ONLAYOUT: "onlayout", ONMOTION: "onmotion", ONKEYMAP: "onkeymap",
|
ONENGINE: "onengine", ONDAEMON: "ondaemon", ONAPPEND: "onappend", ONLAYOUT: "onlayout", ONMOTION: "onmotion", ONKEYMAP: "onkeymap",
|
||||||
ONIMPORT: "onimport", ONSYNTAX: "onsyntax", ONACTION: "onaction", ONDETAIL: "ondetail", ONFIGURE: "onfigure", ONEXPORT: "onexport",
|
ONIMPORT: "onimport", ONSYNTAX: "onsyntax", ONACTION: "onaction", ONDETAIL: "ondetail", ONFIGURE: "onfigure", ONEXPORT: "onexport",
|
||||||
|
ONPLUGIN: "onplugin",
|
||||||
|
|
||||||
ONMAIN: "onmain", ONLOGIN: "onlogin", ONSEARCH: "onsearch",
|
ONMAIN: "onmain", ONLOGIN: "onlogin", ONSEARCH: "onsearch",
|
||||||
ONSIZE: "onsize", ONTOAST: "ontoast", ONREMOTE: "onremote",
|
ONSIZE: "onsize", ONTOAST: "ontoast", ONREMOTE: "onremote",
|
||||||
ONKEYDOWN: "onkeydown", ONMOUSEENTER: "onmouseenter", ORIENTATIONCHANGE: "orientationchange",
|
ONKEYDOWN: "onkeydown", ONMOUSEENTER: "onmouseenter", ORIENTATIONCHANGE: "orientationchange",
|
||||||
ONSTORM_SELECT: "onstorm_select", ONACTION_TOUCH: "onaction_touch", ONACTION_NOTOOL: "onaction_notool",
|
ONSTORM_SELECT: "onstorm_select", ONACTION_TOUCH: "onaction_touch", ONACTION_NOTOOL: "onaction_notool",
|
||||||
|
ONACTION_CMD: "onaction_cmd",
|
||||||
|
|
||||||
_INIT: "_init", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1",
|
_INIT: "_init", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1",
|
||||||
_NAMES: "_names", _TOAST: "_toast",
|
_NAMES: "_names", _TOAST: "_toast",
|
||||||
@ -296,7 +297,7 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack:
|
|||||||
for (var i = 0; i < cache.length; i++) { var sub = cache[i], name = sub._name
|
for (var i = 0; i < cache.length; i++) { var sub = cache[i], name = sub._name
|
||||||
if (typeof each == lang.FUNCTION && each(can, name, sub)) { continue }
|
if (typeof each == lang.FUNCTION && each(can, name, sub)) { continue }
|
||||||
!can[name] && (can[name] = {}); for (var k in sub) {
|
!can[name] && (can[name] = {}); for (var k in sub) {
|
||||||
can[name].hasOwnProperty(k) || (can[name][k] = sub[k])
|
can[name].hasOwnProperty(k) || !sub.hasOwnProperty(k) || (can[name][k] = sub[k])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user