From 5bee32804f834cf4cd3e76bb5946c410fe0a1a16 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 24 Oct 2022 13:58:06 +0800 Subject: [PATCH] opt state.js --- frame.js | 2 +- lib/core.js | 23 ++--- page/index.css | 16 ++-- panel/action.js | 23 ++--- plugin/local/chat/media.js | 2 +- plugin/local/code/inner/favor.js | 2 +- plugin/local/code/inner/syntax.js | 3 +- plugin/local/code/vimer.css | 2 +- plugin/local/wiki/word.css | 2 +- plugin/state.js | 142 +++++++++++++----------------- proto.js | 13 ++- 11 files changed, 100 insertions(+), 130 deletions(-) diff --git a/frame.js b/frame.js index b8b948a8..4c3dcc7b 100644 --- a/frame.js +++ b/frame.js @@ -407,7 +407,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, } can.sup && can.sup.onexport && can.sup.onexport.record && can.sup.onexport.record(can.sup, line) if (key == mdb.HASH && can.user.mod.isDiv) { return can.user.jumps("/chat/div/"+value) } - if (can.sup.onaction.change(event, can.sup, key, event.target.innerText).length == 0) { + if (can.sup.onimport.change(event, can.sup, key, event.target.innerText).length == 0) { can.sup && can.sup._item_click && can.sup._item_click(value, key) } }, ondblclick: function(event) { if ([mdb.KEY].indexOf(key) > -1) { return } diff --git a/lib/core.js b/lib/core.js index 61201e84..891c4869 100644 --- a/lib/core.js +++ b/lib/core.js @@ -89,27 +89,14 @@ Volcanos("core", {help: "数据结构", return res }), CallFunc: shy("调用器", function(func, args, mod) { args = args||{} - var event = args["event"]||{}, can = args["can"]||args[0], msg = args["msg"]||args[1], cmds = args["cmds"]||[] - event = event._event||event - - // 查找调用 - func = typeof func == lang.FUNCTION? func: typeof func == lang.STRING? this.Value(mod||can, func): - typeof func == lang.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): null + var event = args["event"]||{}, can = args["can"]||args[0], msg = args["msg"]||args[1], cmds = args["cmds"]||[]; event = event._event||event + func = typeof func == lang.FUNCTION? func: typeof func == lang.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): typeof func == lang.STRING? this.Value(mod||can, func): null if (typeof func != lang.FUNCTION) { if (typeof args["cb"] == lang.FUNCTION) { args["cb"]() } return } - // 解析参数 - var list = [], echo = false, cb = args["cb"] - this.List(func.toString().split(")")[0].split("(")[1].split(ice.FS), function(item, index) { item = item.trim(); if (item == "") { return } - var arg = args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || - event&&!(event instanceof Event)&&event[item] || args[index] || cmds[index] || args.res || null - if (item == "cb") { echo = true } - list.push(arg) + var list = [], echo = false, cb = args["cb"]; args.length > 0? list = args: this.List(func.toString().split(")")[0].split("(")[1].split(ice.FS), function(item, index) { item = item.trim(); if (item == "") { return } + list.push(args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || event&&!(event instanceof Event)&&event[item] || null); if (item == "cb") { echo = true } }) - - // 执行调用 - var res = func.apply(mod||can, list) - if (!echo && typeof cb == lang.FUNCTION) { res && msg && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) } - return res + var res = func.apply(mod||can, list); if (!echo && typeof cb == lang.FUNCTION) { res && msg && msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) } return res }), List: shy("迭代器", function(list, cb, interval, cbs) { diff --git a/page/index.css b/page/index.css index bcb2c654..b4049320 100644 --- a/page/index.css +++ b/page/index.css @@ -56,9 +56,8 @@ fieldset.plugin { background-color:#061c3c9e; padding:10px; margin:10px; } fieldset.float { background-color:#0e3369; color:white; padding:0; margin:0; } fieldset.full { background-color:#0e3369; color:white; padding:0; margin:0; left:0; top:0; overflow:auto; } -fieldset.plugin>legend { float:none; } -fieldset.plugin.full>legend { float:left; } -fieldset.plugin.float>legend { float:left; } +fieldset.Action>div.output>fieldset.plugin>legend { float:none; } +fieldset.Action>div.output>fieldset.plugin>legend { box-shadow:4px 4px 20px 4px #626bd0; } fieldset>form.option input[type=button][name=close]{ display:none; } fieldset.float>form.option input[type=button][name=close]{ display:block; } @@ -139,11 +138,12 @@ legend, select, input[type=button], div.item, div.tabs, th, td, h1, h2, h3 { cur div.title, div.story[data-type=spark] { cursor:copy; } /* box-shadow */ -fieldset.plugin { box-shadow:2px 2px 10px 4px #626bd0; } -fieldset.plugin:hover { box-shadow:4px 4px 12px 6px #626bd0; } -fieldset.story { box-shadow:4px 4px 10px 1px #626bd0; } -fieldset.story:hover { box-shadow:12px 12px 12px 6px #5764efd1; } -legend, select, textarea, input[type=text], div.code, div.story[data-type=spark] { box-shadow:4px 4px 20px 4px #626bd0; } +// fieldset.plugin { box-shadow:2px 2px 10px 4px #626bd0; } +// fieldset.plugin:hover { box-shadow:4px 4px 12px 6px #626bd0; } +// fieldset.story { box-shadow:4px 4px 10px 1px #626bd0; } +// fieldset.story:hover { box-shadow:12px 12px 12px 6px #5764efd1; } +// select, textarea, input[type=text], div.code, div.story[data-type=spark] { box-shadow:4px 4px 20px 4px #626bd0; } +select, textarea, input[type=text] { box-shadow:4px 4px 20px 4px #626bd0; } /* hover */ legend:hover { background-color:skyblue; } diff --git a/panel/action.js b/panel/action.js index 7d9e3265..ebe348f6 100644 --- a/panel/action.js +++ b/panel/action.js @@ -11,7 +11,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can) msg.Length() > 1? can.onlayout._init(can): can.onengine.signal(can, chat.ONACTION_CMD) can.Conf(chat.RIVER, web.SHARE, chat.STORM, share), can.onimport._init(can, msg) }) }, - _cmd: function(can, item, next) { can.onengine.signal(can, chat.ONACTION_CMD), can.base.Copy(item, {mode: "cmd", opts: can.misc.Search(can)}) + _cmd: function(can, item, next) { can.base.Copy(item, {mode: chat.CMD, opts: can.misc.Search(can)}), can.onengine.signal(can, chat.ONACTION_CMD) can.onappend.plugin(can, item, function(sub, meta, skip) { can.onimport._run(can, sub, function(event, cmds, cb) { return can.runActionCommand(event, sub._index, cmds, cb) }), can.user.title(meta.name), skip || next() }) @@ -45,8 +45,8 @@ Volcanos(chat.ONKEYMAP, {_init: function(can, target) { can.onkeymap._build(can) }, _mode: { normal: { - j: function(event, can) { can._output.scrollBy(0, event.ctrlKey? 300: 30) }, - k: function(event, can) { can._output.scrollBy(0, event.ctrlKey? -300: -30) }, + 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) { can.search(event, ["Header.onaction.black"]) }, w: function(event, can) { can.search(event, ["Header.onaction.white"]) }, @@ -113,14 +113,14 @@ Volcanos(chat.ONACTION, {_init: function(can, target) { can.run({}, [river, storm], function(msg) { if (msg.Length() == 0) { return can.onengine.signal(can, chat.ONACTION_NOTOOL, can.request({}, {river: river, storm: storm})) } can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||msg.Option(chat.LAYOUT), true) - return can.onimport._menu(can, msg), can.onkeymap._init(can), can.onimport._init(can, msg) + return can.onkeymap._init(can), can.onimport._menu(can, msg), can.onimport._init(can, msg) }) }, onaction_cmd: function(can, msg) { can.Conf(html.MARGIN_Y, 2*html.ACTION_HEIGHT), can.Conf(html.MARGIN_X, 0) can.ConfHeight(can.page.height()-can.Conf(html.MARGIN_Y)), can.ConfWidth(can.page.width()) can.page.style(can, can._target, html.HEIGHT, can.page.height(), html.WIDTH, can.page.width()) - can.page.ClassList.add(can, can._target, can.Mode("cmd")), can.page.ClassList.add(can, document.body, "simple") + can.page.ClassList.add(can, can._target, can.Mode(chat.CMD)), can.page.ClassList.add(can, document.body, "simple") }, onkeydown: function(can, msg) { var event = msg._event if (event.ctrlKey && event.key >= "1" && event.key <= "9") { @@ -137,18 +137,16 @@ Volcanos(chat.ONACTION, {_init: function(can, target) { layout: function(can, button, silent) { button = button||ice.AUTO can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT)); if (button == ice.AUTO) { button = "" } can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button)) - can._header_tabs && can.onmotion.hidden(can, can._header_tabs) can.user.isMobile || can.isCmdMode() || (can.onmotion.toggle(can, can._root.River._target, true), can.onmotion.toggle(can, can._root.Footer._target, true)) - can.onlayout._init(can); var cb = can.onlayout[button]; if (can.base.isFunc(cb) && cb(can, silent)) { return } - can.core.Next(can._plugins, function(sub, next) { can.onmotion.delay(can, function() { sub.onaction._resize(sub, button == "" || button == "free" || button == "flow", can.ConfHeight(), can.ConfWidth()), next() }, 10) }) + can.onlayout._plugin(can, button) }, help: function(can, button) { can.user.open("/help/"+button+".shy") }, }) Volcanos(chat.ONLAYOUT, { tabs: function(can) { - can.getActionSize(function(height, width) { can.ConfHeight(height-can.Conf(html.MARGIN_Y)+200), can.ConfWidth(width-can.Conf(html.MARGIN_X)) }) + can.getActionSize(function(height, width) { can.ConfHeight(height-can.Conf(html.MARGIN_Y)+html.ACTION_MARGIN), can.ConfWidth(width-can.Conf(html.MARGIN_X)) }) can.onmotion.select(can, can._action, html.DIV_TABS) || can.onmotion.select(can, can._action, html.DIV_TABS, 0, function(target) { target.click() }) }, tabview: function(can) { can.onmotion.toggle(can, can._header_tabs, true) @@ -167,7 +165,7 @@ Volcanos(chat.ONLAYOUT, { can.getActionSize(function(height, width) { can.ConfHeight(height/2), can.ConfWidth(width) }) }, free: function(can) { - can.getActionSize(function(height, width) { can.ConfHeight(height-can.Conf(html.MARGIN_X)-2*html.ACTION_HEIGHT), can.ConfWidth(width-can.Conf(html.MARGIN_X)) }) + can.getActionSize(function(height, width) { can.ConfHeight(height-can.Conf(html.MARGIN_Y)+html.ACTION_MARGIN), can.ConfWidth(width-can.Conf(html.MARGIN_X)) }) can.core.List(can._plugins, function(sub, index) { can.onmotion.move(can, sub._target, {left: 40*index, top: 40*index}) }) }, grid: function(can, silent) { @@ -177,9 +175,12 @@ Volcanos(chat.ONLAYOUT, { can.getActionSize(function(height, width) { var h = (height-(4*n+1)*html.PLUGIN_MARGIN)/n, w = (width-(4*m+1)*html.PLUGIN_MARGIN)/m can.ConfHeight(h-2*html.ACTION_HEIGHT-3*html.PLUGIN_MARGIN), can.ConfWidth(w) - can.core.Next(can._plugins, function(sub, next) { can.onmotion.delay(can, function() { sub.onaction._resize(sub, false, can.ConfHeight(), can.ConfWidth()), next() }, 10) }) + can.onlayout._plugin(can, "grid") }) }, + _plugin: function(can, button) { + can.core.List(can._plugins, function(sub) { sub.onaction._resize(sub, button == "" || button == "free" || button == "flow", can.ConfHeight(), can.ConfWidth()) }) + }, }) Volcanos(chat.ONEXPORT, { size: function(can, msg) { diff --git a/plugin/local/chat/media.js b/plugin/local/chat/media.js index a4a41b34..3ca6d594 100644 --- a/plugin/local/chat/media.js +++ b/plugin/local/chat/media.js @@ -4,7 +4,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, ta can.onappend.table(can, msg, function(value, key, index, line, array) { return {text: [value, "td"], onclick: function(event) { - can.sup.onaction.change(event, can.sup, key, value, function(msg) { + can.sup.onimport.change(event, can.sup, key, value, function(msg) { can.run(event) }) }} diff --git a/plugin/local/code/inner/favor.js b/plugin/local/code/inner/favor.js index 9d947419..1bf6cd12 100644 --- a/plugin/local/code/inner/favor.js +++ b/plugin/local/code/inner/favor.js @@ -15,7 +15,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, cb) { if (key != ctx.ACTION) { value = sub.page.replace(sub, value, ice.PWD, "") } return {text: ["", html.TD], list: [{text: [value, html.DIV]}], onclick: function(event) { var target = event.target - if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onaction.change(event, sub, key, value) } + if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onimport.change(event, sub, key, value) } if (target.tagName == "INPUT" && target.type == html.BUTTON) { var msg = sub.request(event, line, sub.Option()) return sub.runAction(event, target.name, [], function(msg) { sub.run() }) diff --git a/plugin/local/code/inner/syntax.js b/plugin/local/code/inner/syntax.js index 4ea91dd9..8d8d3ca0 100644 --- a/plugin/local/code/inner/syntax.js +++ b/plugin/local/code/inner/syntax.js @@ -290,7 +290,6 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", "sub": code.KEYWORD, "sup": code.KEYWORD, "msg": code.KEYWORD, - "res": code.KEYWORD, "ice": code.KEYWORD, "kit": code.KEYWORD, @@ -298,8 +297,8 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", "event": code.KEYWORD, "target": code.KEYWORD, "window": code.KEYWORD, - "document": code.KEYWORD, "location": code.KEYWORD, + "document": code.KEYWORD, "null": code.CONSTANT, "true": code.CONSTANT, diff --git a/plugin/local/code/vimer.css b/plugin/local/code/vimer.css index fc465113..b7598d1e 100644 --- a/plugin/local/code/vimer.css +++ b/plugin/local/code/vimer.css @@ -42,6 +42,6 @@ body.simple fieldset.vimer>div.output input.current { body.white fieldset.vimer>div.output input.current.insert { caret-color:black; } body.white fieldset.vimer>div.output input.current.normal { caret-color:lightgray; } -div.project div.zone.create>div.list div.item { padding:5px; float:left; clear:none; } +div.project div.zone.create>div.list div.item { padding:2px; float:left; clear:none; } body.webview div.project div.zone.create>div.list div.item { padding:2px; } div.project div.zone.create>div.action { display:none; } diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index 237fe3f1..773efbba 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -19,7 +19,7 @@ fieldset.word ul.story[data-type=endmenu] { clear:both; } fieldset.word p.story[data-name=inner] { background-color:#4b6c8a7a; padding:4px 10px; border-left:solid 4px blue; margin:10px 0px; } fieldset.word p.story[data-name=inner]:hover { background-color:#c10c8a; cursor:copy; } fieldset.word table.content { display:block; max-height:400px; } -fieldset.word fieldset.story { margin:10px; } +fieldset.word fieldset.story { margin:10px; background-color:#58a4d37d; } fieldset.word fieldset.story.full { margin:0px; } fieldset.word fieldset.story.float { margin:0px; } diff --git a/plugin/state.js b/plugin/state.js index da65eefb..5cf69ab5 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -1,4 +1,4 @@ -Volcanos(chat.ONIMPORT, {help: "导入数据", _process: function(can, msg) { +Volcanos(chat.ONIMPORT, {_process: function(can, msg) { msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, msg.OptionStatus()) return can.core.CallFunc([can.onimport, msg.OptionProcess()], {can: can, msg: msg}) }, @@ -25,15 +25,13 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _process: function(can, msg) { can.page.style(can, can._output, html.DISPLAY, html.BLOCK); return true }, _field: function(can, msg) { var opts = {} - can.page.Select(can, can._option, html.INPUT_ARGS, function(target) { var value = msg.Option(target.name); target.name && value && (opts[target.name] = value) }) + can.page.SelectArgs(can, can._option, "", function(target) { var value = msg.Option(target.name); target.name && value && (opts[target.name] = value) }) msg.Table(function(item) { can.onappend._plugin(can, item, {type: chat.STORY, index: item.index, args: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) { sub.Conf(can.base.Obj(item.conf)); if (sub.isSimpleMode()) { (function() { sub.ConfHeight(can.ConfHeight()/2) - var msg = can.request(); msg.Echo(sub.Conf(ice.MSG_RESULT)) - can.onappend._output(sub, msg, sub.Conf("feature.display")) + var msg = can.request(); msg.Echo(sub.Conf(ice.MSG_RESULT)), can.onappend._output(sub, msg, sub.Conf("feature.display")) })(); return } - var opt = can.base.Obj(item[ice.OPT], []) - sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) + var opt = can.base.Obj(item[ice.OPT], []); sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) sub.run = function(event, cmds, cb) { var res = can.request(event, can.Option(), opts, {pid: msg.Option("pid")}) for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) } @@ -42,10 +40,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _process: function(can, msg) { }) }); return true }, _float: function(can, msg) { var _arg = msg._arg - msg.Table(function(item) { can.onappend._plugin(can, item, {type: chat.STORY, mode: chat.FLOAT, index: item.index, args: _arg.slice(1), mode: chat.FLOAT}, function(sub, meta) { + msg.Table(function(item) { can.onappend._plugin(can, item, {type: chat.STORY, mode: chat.FLOAT, index: item.index, args: _arg.slice(1)}, function(sub, meta) { sub.run = function(event, cmds, cb) { can.runAction(can.request(event, {path: msg.Option(nfs.PATH), text: msg.Option(mdb.TEXT)}), [ice.RUN, msg._arg[0]], cmds, cb) } can.getActionSize(function(left, top, width, height) { left = left||0 - var top = can.Mode() == undefined? 120: 0; if (can.user.isMobile) { top = can.user.isLandscape()? 0: 48 } + var top = !can.Mode()? 120: 0; if (can.user.isMobile) { top = can.user.isLandscape()? 0: 48 } sub.onimport.size(sub, can.base.Max(height, can.page.height())-top-2*html.ACTION_HEIGHT-(can.user.isMobile&&!can.user.isLandscape()? 2*html.ACTION_HEIGHT: 0), width, true) can.onmotion.move(can, sub._target, {left: left, top: top}) }) @@ -83,23 +81,26 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _process: function(can, msg) { }, _open: function(can, msg, _arg) { return can.user.open(_arg), can.Update() }, - size: function(can, height, width, auto, mode) { // height += html.ACTION_HEIGHT-can.onexport.statusHeight(can) + size: function(can, height, width, auto, mode) { if (auto) { - // height && can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "", html.MAX_HEIGHT, can.ConfHeight(height), html.MAX_WIDTH, can.ConfWidth(width)) - height && can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "", html.MAX_HEIGHT, "", html.MAX_WIDTH, can.ConfWidth(width)) + can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, "", html.MAX_HEIGHT, "", html.MAX_WIDTH, can.ConfWidth(width)) } else { can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(height), html.WIDTH, can.ConfWidth(width), html.MAX_HEIGHT, "", html.MAX_WIDTH, "") } - var sub = can.core.Value(can, chat._OUTPUTS_CURRENT); if (!sub) { return } sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) - if (mode) { sub.Mode(can.Mode(mode)), sub.onlayout[mode](sub) } else { can.onaction["刷新页面"]({}, can, "刷新页面", sub) } can.user.isMobile && can.onmotion.toggle(can, can._action, can.ConfHeight() < can.ConfWidth()-100) + var sub = can.core.Value(can, chat._OUTPUTS_CURRENT); if (!sub) { return } sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) + if (mode) { sub.Mode(can.Mode(mode)), sub.onlayout[mode](sub) } else { sub.onlayout._init(sub) } }, - title: function(can, title) { - can.isCmdMode() && can.user.title(title) + change: function(event, can, name, value, cb) { + return can.page.SelectArgs(can, can._option, "", function(input) { + if (input.name != name || value == input.value) { return } + return input.value = value, can.Update(event, can.Input(), cb), input + }) }, + title: function(can, title) { can.isCmdMode() && can.user.title(title) }, }) -Volcanos(chat.ONACTION, {help: "交互操作", list: [ - "刷新页面", "刷新数据", "切换浮动", "切换全屏", "共享工具", "远程控制", "打开链接", "生成链接", "生成脚本", "生成图片", [ +Volcanos(chat.ONACTION, {list: [ + "刷新界面", "刷新数据", "切换浮动", "切换全屏", "共享工具", "远程控制", "打开链接", "生成链接", "生成脚本", "生成图片", [ "其它", "保存参数", "清空参数", "扩展参数", "复制数据", "下载数据", "清空数据", "查看文档", "查看脚本", "查看源码", "查看配置", "删除配置", "删除工具", ], @@ -107,64 +108,42 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ _engine: function(event, can, button) { can.Update(event, [ctx.ACTION, button].concat(can.Input([], true))) }, _switch: function(can, sub, mode, save, load) { if (can.page.ClassList.neg(can, can._target, mode)) { - can._mode_bak = can.Mode(), can._height_bak = can.ConfHeight()||"", can._width_bak = can.ConfWidth()||"" - can._output_bak = {}, can.core.List([html.HEIGHT, html.WIDTH, html.MAX_HEIGHT, html.MAX_WIDTH], function(key) { - can._output_bak[key] = can._output.style[key] - }) - save(), can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), false, mode) - } else { - can.Mode(can._mode_bak||""), can.ConfHeight(can._height_bak), can.ConfWidth(can._width_bak) - can.page.style(can, can._output, can._output_bak) - load(), sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) - sub.Mode(can.Mode()), sub.onlayout._init(sub) + (can._mode_list = can._mode_list||[]).push(kit.Dict( + ice.MODE, can.Mode()||"", html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth(), + html.ACTION, can._action.style.display == "", html.STATUS, can._status.style.display == "", + html.OUTPUT, can.base.Copy({}, can._output.style, html.HEIGHT, html.WIDTH, html.MAX_HEIGHT, html.MAX_WIDTH), + ctx.STYLE, can.base.Copy({}, can._target.style, html.LEFT, html.TOP, html.RIGHT, html.BOTTOM), + save(), + )), can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), false, mode) + } else { var back = (can._mode_list = can._mode_list||[]).pop(); if (!back) { return } + can.Mode(back.mode), can.ConfHeight(back.height), can.ConfWidth(back.width), can.page.style(can, can._output, back.output) + can.page.style(can, can._target, back.style) + can.onmotion.toggle(can, can._action, back.action), can.onmotion.toggle(can, can._status, back.status) + can.base.isFunc(load) && load(back), sub.Mode(can.Mode()), sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()), sub.onlayout._init(sub) } }, _resize: function(can, auto, height, width) { can.onimport.size(can, height, width, auto) }, - _output: function(can, msg) { }, + _output: function(can, msg) {}, - "刷新页面": function(event, can, button, sub) { can.core.CallFunc([sub.onlayout, "_init"], {can: sub}) }, - "刷新数据": function(event, can) { can.Update({}, can.Input([], true)) }, + "刷新界面": function(event, can, button, sub) { sub.onlayout._init(sub) }, + "刷新数据": function(event, can) { can.Update(event, can.Input([], true)) }, "切换浮动": function(event, can, button, sub) { - can.onaction._switch(can, sub, "float", function() { - can._action_bak = can._action.style.display == "" - can._status_bak = can._status.style.display == "" - can.onmotion.hidden(can, can._action) - can.onmotion.hidden(can, can._status) + can.onaction._switch(can, sub, chat.FLOAT, function() { can.onmotion.hidden(can, can._action), can.onmotion.hidden(can, can._status) can.ConfHeight(can.page.height()/2-2*html.ACTION_HEIGHT-can.onexport.statusHeight(can)), html.WIDTH, can.ConfWidth(can.page.width()/(can.user.isMobile? 1: 2)) can.getActionSize(function(left) { can.onmotion.move(can, can._target, {left: (left||0)+(can.user.isMobile? 0: html.PLUGIN_MARGIN), top: can.page.height()/2-html.PLUGIN_MARGIN}) }) - }, function() { - can.onmotion.toggle(can, can._action, can._action_bak) - can.onmotion.toggle(can, can._status, can._status_bak) - can.page.style(can, can._target, html.LEFT, "", html.TOP, "") }) }, "切换全屏": function(event, can, button, sub) { - can.onaction._switch(can, sub, "full", function() { can.ConfWidth(can.page.width()) - can.page.style(can, can._target, html.LEFT, "", html.BOTTOM, "") - can.ConfHeight(can.page.height()-html.ACTION_HEIGHT-can.onexport.statusHeight(can)) - }, function() {}) + can.onaction._switch(can, sub, chat.FULL, function() { can.page.style(can, can._target, html.LEFT, "", html.TOP, "", html.BOTTOM, "") + can.ConfHeight(can.page.height()-html.ACTION_HEIGHT-can.onexport.statusHeight(can)), can.ConfWidth(can.page.width()) + }) }, "共享工具": function(event, can) { var meta = can.Conf() - can.onmotion.share(event, can, [{name: chat.TITLE, value: meta.name}, {name: chat.TOPIC, values: [cli.WHITE, cli.BLACK]}], [mdb.NAME, meta.index, mdb.TEXT, JSON.stringify(can.Input([], true))]) - }, - "远程控制": function(event, can) { - can.base.isUndefined(can._daemon) && can.ondaemon._list[0] && (can._daemon = can.ondaemon._list.push(can)-1) - can.request(event, kit.Dict(ctx.INDEX, can._index, ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], can._daemon))) - - can.runAction(event, "keyboard", [], function(msg) { - can.onmotion.move(can, can.user.toast(can, { - title: msg.Append(mdb.NAME), duration: -1, content: msg.Append(mdb.TEXT), action: [cli.CLOSE, cli.OPEN], - })._target, {}), can.user.copy(msg._event, can, msg.Append(mdb.NAME)) - }, true) - }, - "打开链接": function(event, can) { var meta = can.Conf(), args = can.Option(); args.river = "", args.storm = "" - args.cmd = meta.index||can.core.Keys(meta.ctx, meta.cmd), args.cmd == "web.wiki.word" && (args.cmd = args.path) - can.user.isWeiXin? can.user.jumps(can.misc.MergeURL(can, args)): can.user.open(can.misc.MergeURL(can, args)) - }, - "生成链接": function(event, can) { var meta = can.Conf(), args = can.Option() - args.cmd = meta.index||can.core.Keys(meta.ctx, meta.cmd), args.cmd == "web.wiki.word" && (args.cmd = args.path) - can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.misc.MergePodCmd(can, args))]) + can.onmotion.share(event, can, [{name: chat.TITLE, value: meta.name}, {name: chat.TOPIC, values: [can.getHeader(chat.TOPIC), cli.WHITE, cli.BLACK]}], [mdb.NAME, meta.index, mdb.TEXT, JSON.stringify(can.Input([], true))]) }, + "远程控制": function(event, can) { can.onaction.keyboard(event, can) }, + "打开链接": function(event, can) { can.user.open(can.onexport.link(can)) }, + "生成链接": function(event, can) { can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.onexport.link(can))]) }, "生成脚本": function(event, can) { var conf = can.Conf() var args = can.Input("", true).join(ice.SP), list = [ "export ctx_dev="+location.origin+"; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev;"+" source $ctx_temp "+(conf.index||"")+ice.SP+args, @@ -179,9 +158,9 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ "清空参数": function(event, can) { can.page.SelectArgs(can, can._option, "", function(item) { return item.value = "" }) }, "扩展参数": function(event, can) { can.onmotion.toggle(can, can._action) }, "复制数据": function(event, can, button, sub) { can.user.copy(event, can, sub.onexport.table(sub)||sub.onexport.board(sub)) }, - "下载数据": function(event, can, button, sub) { var meta = can.Conf() - can.user.input(event, can, [{name: "filename", value: meta.name}], function(list) { - can.user.downloads(can, sub.onexport.table(sub), list[0], nfs.CSV)||can.user.downloads(can, sub.onexport.board(sub), meta.name, nfs.TXT) + "下载数据": function(event, can, button, sub) { + can.user.input(event, can, [{name: "filename", value: can.Conf(mdb.NAME)}], function(list) { + can.user.downloads(can, sub.onexport.table(sub), list[0], nfs.CSV), can.user.downloads(can, sub.onexport.board(sub), list[0], nfs.TXT) }) }, "清空数据": function(event, can) { can.onmotion.clear(can, can._output) }, @@ -193,18 +172,10 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ "删除配置": function(event, can) { can.runAction(event, ctx.CONFIG, ["reset"]) }, "删除工具": function(event, can) { can.page.Remove(can, can._target) }, - change: function(event, can, name, value, cb) { - return can.page.SelectArgs(can, can._option, "", function(input) { - if (input.name == name && value != input.value) { input.value = value - var data = input.dataset||{}; can.Update(event, can.Input(), cb); return input - } - }) - }, refresh: function(event, can) { var sub = can.core.Value(can, chat._OUTPUTS_CURRENT); if (!sub) { return } sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()), sub.onimport.layout(sub) }, - clear: function(event, can, name) { can.onmotion.clear(can, can._output) }, close: function(event, can) { if (can.isFullMode()) { can.onaction["切换全屏"](event, can, "切换全屏", can.core.Value(can, chat._OUTPUTS_CURRENT)) @@ -214,13 +185,22 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ can.page.Remove(can, can._target) } }, - - upload: function(event, can) { can.user.upload(event, can) }, - actions: function(event, can) { can.onmotion.toggle(can, can._action) }, + clear: function(event, can) { can.onmotion.clear(can, can._output) }, full: function(event, can) { can.onaction["切换全屏"](event, can, "切换全屏", can.core.Value(can, chat._OUTPUTS_CURRENT)) }, - keyboard: function(event, can) { can.onaction["远程控制"](event, can, "远程控制", can.core.Value(can, chat._OUTPUTS_CURRENT)) }, next: function(event, can) { can.Update(event, [ctx.ACTION, mdb.NEXT, can.Status(mdb.TOTAL)||0, can.Option(mdb.LIMIT)||can.Action(mdb.LIMIT)||"", can.Option(mdb.OFFEND)||can.Action(mdb.OFFEND)||""]) }, prev: function(event, can) { can.Update(event, [ctx.ACTION, mdb.PREV, can.Status(mdb.TOTAL)||0, can.Option(mdb.LIMIT)||can.Action(mdb.LIMIT)||"", can.Option(mdb.OFFEND)||can.Action(mdb.OFFEND)||""]) }, + keyboard: function(event, can) { + can.base.isUndefined(can._daemon) && can.ondaemon._list[0] && (can._daemon = can.ondaemon._list.push(can)-1) + can.request(event, kit.Dict(ctx.INDEX, can._index, ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], can._daemon))) + + can.runAction(event, "keyboard", [], function(msg) { + can.onmotion.move(can, can.user.toast(can, { + title: msg.Append(mdb.NAME), duration: -1, content: msg.Append(mdb.TEXT), action: [cli.CLOSE, cli.OPEN], + })._target, {}), can.user.copy(msg._event, can, msg.Append(mdb.NAME)) + }, true) + }, + actions: function(event, can) { can.onmotion.toggle(can, can._action) }, + upload: function(event, can) { can.user.upload(event, can) }, getClipboardData: function(event, can, button) { function add(text) { can.runAction(event, button, can.base.Simple(can.base.ParseJSON(text)), function() { can.Update() }) } @@ -242,8 +222,12 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ }) }, }) -Volcanos(chat.ONEXPORT, {help: "导出数据", - actionHeight: function(can) { return can._action.style.display == html.NONE || can._action.innerHTML == ""? 0: html.ACTION_HEIGHT }, +Volcanos(chat.ONEXPORT, { statusHeight: function(can) { return can._status.style.display == html.NONE || can._status.innerHTML == "" || can._status.offsetHeight == 0? 0: html.ACTION_HEIGHT }, + actionHeight: function(can) { return can._action.style.display == html.NONE || can._action.innerHTML == ""? 0: html.ACTION_HEIGHT }, record: function(can, line) {}, + link: function(can) { var meta = can.Conf(), args = can.Option() + args.cmd = meta.index||can.core.Keys(meta.ctx, meta.cmd), args.cmd == "web.wiki.word" && (args.cmd = args.path) + return can.misc.MergePodCmd(can, args, true) + }, }) diff --git a/proto.js b/proto.js index 51d3d554..e83633fe 100644 --- a/proto.js +++ b/proto.js @@ -2,14 +2,11 @@ var kit = { Dict: function() { var res = {} for (var i = 0; i < arguments.length; i += 2) { if (typeof arguments[i] == "object") { - for (var k in arguments[i]) { - res[k] = arguments[i][k] - } i-- - continue + for (var k in arguments[i]) { res[k] = arguments[i][k] } i-- + } else if (arguments[i] != undefined) { + res[arguments[i]] = arguments[i+1] } - res[arguments[i]] = arguments[i+1] - } - return res + } return res } } var ice = { @@ -222,6 +219,8 @@ var chat = { _INIT: "_init", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1", _NAMES: "_names", _TOAST: "_toast", + + FLOAT: "float", FULL: "full", CMD: "cmd", } var team = { TASK: "task", PLAN: "plan",