From 672f5fc594aad4245ca78f3ba37aa5290bd6911f Mon Sep 17 00:00:00 2001 From: shaoying Date: Sat, 4 Feb 2023 10:00:43 +0800 Subject: [PATCH] opt some --- lib/base.js | 23 +++++++---------------- panel/search.js | 2 +- proto.js | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/base.js b/lib/base.js index b29281cd..683370f6 100644 --- a/lib/base.js +++ b/lib/base.js @@ -9,29 +9,20 @@ Volcanos("base", { } catch (e) { return val&&val.split&&val.split(ice.FS) || def } }, Copy: function(to, from, merge) { if (!from) { return to } - if (arguments.length == 2 || typeof merge == lang.BOOLEAN) { - for (var k in from) { if (k == undefined) { continue } - if (merge && 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 + if (arguments.length == 2 || typeof merge == lang.BOOLEAN) { for (var k in from) { if (k == undefined) { continue } + if (merge && 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 }, Eq: function(to, from, skip) { var call = arguments.callee; if (typeof to != typeof from) { return false } if (typeof to == lang.OBJECT) { if (to.length != from.length) { return false } for (var i = 0; i < to.length; i++) { if (!call(to[i], from[i])) { return false } } - for (var k in to) { if (k != skip && !call(to[k], from[k])) { return false } } - return true + for (var k in to) { if (k != skip && !call(to[k], from[k])) { return false } } return true } return to === from }, - Dir: function(path) { - if (path.endsWith(ice.PS)) { - return path - } else { - return path.slice(0, path.lastIndexOf(ice.PS)+1) - } - }, + Dir: function(path) { return path.endsWith(ice.PS)? path: path.slice(0, path.lastIndexOf(ice.PS)+1) }, Ext: function(path) { return path.split(ice.PS).pop().split(ice.PT).pop().toLowerCase() }, - Path: function(path) { var res = "" + Path: function(path) { var res = "", arg = arguments for (var i = 0; i < arguments.length; i++) { if (!arguments[i]) { continue } res += (arguments[i][0]==ice.PS || res=="" || res[res.length-1]==ice.PS? "": ice.PS) + arguments[i].trim() } return res diff --git a/panel/search.js b/panel/search.js index da3f0f4f..706fe0e6 100644 --- a/panel/search.js +++ b/panel/search.js @@ -17,7 +17,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can, can }, select: function(can, msg, cmds, cb) { can.ui.filter.value = cmds[1], can.ui.input = function(event, word) { cmds[1] = word||cmds[1]; can.onimport._input(can, msg, cmds, fields) } var fields = (cmds[2]||msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(ice.FS); can.page.Appends(can, can.ui.display, [{th: fields}]), can.onmotion.hidden(can, can.ui.display), can.onmotion.clear(can, can.ui.profile) - can.ui.done = function() { can.base.isFunc(cb) && cb(can.onexport.select(can)), can.onmotion.hide(can) }, can.db = {}, can._plugins = [], can.onimport._input(can, msg, cmds, fields) + can.ui.done = function() { can.base.isFunc(cb) && cb(can.onexport.select(can)), can.onmotion.hidden(can) }, can.db = {}, can._plugins = [], can.onimport._input(can, msg, cmds, fields) }, }) Volcanos(chat.ONACTION, {_init: function(can) { can.onmotion.hidden(can) }, list: [cli.CLOSE, cli.CLEAR, cli.DONE], diff --git a/proto.js b/proto.js index f908a97f..0c5c4ed2 100644 --- a/proto.js +++ b/proto.js @@ -10,7 +10,7 @@ var kit = {proto: function(sub, sup) { return sub.__proto__ = sup, sub }, } return res }, } var ice = { - TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", PS: "/", PT: ".", FS: ",", NL: "\n", LT: "<", GT: ">", + TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", PS: "/", PT: ".", FS: ",", QS: "?", NL: "\n", LT: "<", GT: ">", OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process", AUTO: "auto",