From 1505c294bde17ccb6224a2a8d29c61be5125f693 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Tue, 1 Nov 2022 20:00:41 +0800 Subject: [PATCH] opt some --- frame.js | 6 +++--- lib/base.js | 2 +- proto.js | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frame.js b/frame.js index 965fd51a..e4add85d 100644 --- a/frame.js +++ b/frame.js @@ -27,7 +27,7 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { toast = toast||can.user.toastProcess(msg._can, _toast) }, 500) } msg.option = can.core.List(msg.option, function(item) { return [chat._TOAST, ice.MSG_HANDLE].indexOf(item) > -1 && delete(msg[item])? undefined: item }) - can.getHeader(chat.TOPIC, function(topic) { msg.Option(chat.TOPIC, topic) }) + msg.Option(chat.TOPIC) || msg.Option(chat.TOPIC, can.getHeader(chat.TOPIC)) if (can.base.isUndefined(msg._daemon)) { var sub = msg._can; can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1) if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) } } can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds})) @@ -101,7 +101,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, Action: function(key, value) { return can.page.SelectArgs(can, action, key, value)[0] }, Option: function(key, value) { return can.page.SelectArgs(can, option, key, value)[0] }, - Update: function(event, cmds, cb, silent) { sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input(), cb, silent); return true }, + Update: function(event, cmds, cb, silent) { sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input([], !silent), cb, silent); return true }, Focus: function() { can.page.SelectOne(can, option, html.INPUT_ARGS, function(target) { target.focus() }) }, Input: function(cmds, save) { cmds = cmds && cmds.length > 0? cmds: can.page.SelectArgs(sub), cmds = can.base.trim(cmds) return !save || cmds[0] == ctx.ACTION || can.base.Eq(sub._history[sub._history.length-1], cmds) || sub._history.push(cmds), cmds @@ -206,7 +206,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { field: function(can, type, item, target) { type = type||html.PLUGIN, item = item||{} var name = (item.nick||item.name||"").split(ice.SP)[0], title = !item.help || can.user.language(can) == "en"? name: name+"("+item.help.split(ice.SP)[0]+")" return can.page.Append(can, target||can._output, [{view: [can.base.join([type||"", item.name||"", item.pos||""]), html.FIELDSET], list: [ - title && {text: [name == "word"? item.help.split(ice.SP)[0]: title, html.LEGEND]}, {view: [html.OPTION, html.FORM]}, html.ACTION, html.OUTPUT, html.STATUS, + {text: [name == "word"? item.help.split(ice.SP)[0]: title, html.LEGEND]}, {view: [html.OPTION, html.FORM]}, html.ACTION, html.OUTPUT, html.STATUS, ]}]) }, input: function(can, item, value, target, style) { diff --git a/lib/base.js b/lib/base.js index 914854a4..9ae21d5a 100644 --- a/lib/base.js +++ b/lib/base.js @@ -11,7 +11,7 @@ Volcanos("base", { Copy: function(to, from, hold) { if (!from) { return to } if (arguments.length == 2 || typeof hold == lang.BOOLEAN) { for (var k in from) { if (k == undefined) { continue } - if (hold && to.hasOwnProperty(k) && to[k] != undefined) { continue } + if (hold && to.hasOwnProperty(k) && to[k] != undefined && to[k] != "") { continue } if (from[k] === "") { delete(to[k]) } else { to[k] = from[k] } } return to } for (var i = 2; i < arguments.length; i++) { var k = arguments[i]; to[k] = from[k] } return to diff --git a/proto.js b/proto.js index 43db1b70..397a94cb 100644 --- a/proto.js +++ b/proto.js @@ -7,8 +7,8 @@ var ice = { TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", PS: "/", PT: ".", FS: ",", NL: "\n", LT: "<", GT: ">", OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process", - AUTO: "auto", HTTP: "http", HELP: "help", COPY: "copy", - LIST: "list", BACK: "back", SHOW: "show", HIDE: "hide", + AUTO: "auto", HTTP: "http", LIST: "list", BACK: "back", + SHOW: "show", HIDE: "hide", HELP: "help", COPY: "copy", VIEW: "view", MODE: "mode", SHIP: "ship", EXEC: "exec", POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg", OPT: "opt", @@ -39,7 +39,6 @@ var ice = { MSG_TOPIC: "sess.topic", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm", - MSG_TOAST: "sess.toast", MSG_USERNAME: "user.name", MSG_USERNICK: "user.nick",