From 67d3e2e8c35c552c0fda60daa3c8d87742afe4af Mon Sep 17 00:00:00 2001 From: harveyshao Date: Thu, 12 Jan 2023 22:26:02 +0800 Subject: [PATCH] opt some --- frame.js | 41 ++++++++++++++++++++----------------- page/index.css | 6 +----- plugin/local/code/inner.css | 6 +++--- plugin/local/code/inner.js | 31 +++++++++------------------- plugin/local/code/vimer.css | 4 ++-- 5 files changed, 38 insertions(+), 50 deletions(-) diff --git a/frame.js b/frame.js index 8b9d292b..c3cf2a5b 100644 --- a/frame.js +++ b/frame.js @@ -22,17 +22,19 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { can.onappend.topic(can, "light", {topic: "white", plugin: "#f3f5f6", input: "white", output: "white", table: "#f3f5f6", hover: "#E1F2F4", border: "#0000", label: "black", text: "black", warn: "red", notice: "blue"}) can.onappend.icon(can, { - open: [-27, -158], - close: [-82, -158], - }, 16) - can.onappend.icon(can, { - open: [-30, -177], - close: [-93, -177], - }, 18) - can.onappend.icon(can, { - open: [-40, -236], - close: [-123, -236], - }, 24) + 16: { + open: [-27, -158], + close: [-82, -158], + }, + 18: { + open: [-30, -177], + close: [-93, -177], + }, + 24: { + open: [-40, -236], + close: [-123, -236], + }, + }) }, _search: function(event, can, msg, panel, cmds, cb) { var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split(ice.PT), function(value) { fun && (sub = mod, mod = fun, fun = mod[value], key = value) }) @@ -354,13 +356,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { } }), can.onfigure[input]._init && can.onfigure[input]._init(can, meta, target, _cb) }) }, - icon: function(can, list, size) { - can.core.Item(list, function(key, value) { - var text = `div.icon.s${size}.${key} { + icon: function(can, list) { + var text = can.core.Item(list, function(size, list) { return can.core.Item(list, function(key, value) { + return `div.icon.s${size}.${key} { background:url(/publish/icon/full.jpg); background-size:${size*20}px; width:${size}px; height:${size}px; background-repeat: no-repeat; background-position-x:${value[0]}px; background-position-y:${value[1]}px; -}`; can.page.Append(can, document.head, "style", {"innerText": text}), console.log("icon", size, key, text) - }) +}` + }).join(ice.NL) }).join(ice.NL) + can.page.Append(can, document.head, ctx.STYLE, {"innerText": text}), console.log("icon", text) }, topic: function(can, topic, color, style, list) { const SOLID = " solid 1px", GLASS = "#0000" const INPUT_STYLE = "input-style", INPUT_HOVER_STYLE = "input-hover-style", OUTPUT_STYLE = "output-style", GLASS_STYLE = "glass-style" @@ -413,9 +416,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { {type: html.DIV_FLOAT, style: [PLUGIN_STYLE]}, {type: html.FIELDSET_FLOAT, style: [PLUGIN_STYLE]}, {type: html.FIELDSET_PANEL, style: [PANEL_STYLE]}, {type: html.FIELDSET_PANEL, list: [{type: ">"+html.DIV_OUTPUT, style: [PANEL_STYLE]}]}, - {type: html.FIELDSET_PANEL, name: ["Footer"], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV_TOAST, style: [TABLE_HEAD_STYLE]}], }]}, - {type: html.FIELDSET_PANEL, name: ["Footer"], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV, style: [ITEM_HOVER_STYLE]}], }]}, - {type: html.FIELDSET_PANEL, name: ["Header"], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV, style: [ITEM_HOVER_STYLE]}], }]}, + {type: html.FIELDSET_PANEL, name: [chat.HEADER], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV, style: [ITEM_HOVER_STYLE]}], }]}, + {type: html.FIELDSET_PANEL, name: [chat.FOOTER], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV, style: [ITEM_HOVER_STYLE]}], }]}, + {type: html.FIELDSET_PANEL, name: [chat.FOOTER], list: [{type: html.DIV_OUTPUT, list: [{type: html.DIV_TOAST, style: [TABLE_HEAD_STYLE]}], }]}, {type: html.FIELDSET_PLUGIN, style: [PLUGIN_STYLE]}, {type: html.FIELDSET_PLUGIN, list: [{type: html.DIV_STATUS, style: {"border-top": color.border+SOLID}}]}, {type: html.FIELDSET_STORY, style: [PLUGIN_STYLE]}, {type: html.FIELDSET_STORY, list: [{type: html.DIV_STATUS, style: {"border-top": color.border+SOLID}}]}, {type: html.FIELDSET_INPUT, style: [PLUGIN_STYLE]}, {type: html.FIELDSET_INPUT, style: _b_r(0)}, diff --git a/page/index.css b/page/index.css index aea2f886..7d6f4db5 100644 --- a/page/index.css +++ b/page/index.css @@ -22,7 +22,7 @@ input[type=button][name=stop] { background-color:red; } input[type=button][name=trash] { background-color:red; } input[type=button][name=delete] { background-color:red; } input[type=button][name=remove] { background-color:red; } -textarea { background-color:cyan; padding:5px; width:400px; resize:vertical; } +textarea { background-color:cyan; padding:5px; width:600px; resize:vertical; } /* output */ div.output { position:relative; } div.layout.flex>* { float:left; } @@ -44,7 +44,6 @@ table.content.action td:last-child { background-color:steelblue; position:sticky div.code { background-color:#343a3445; font-size:12px; padding:10px; border:green solid 1px; } div.story[data-type=spark] { background-color:#2169a9a6; color:white; padding:5px 10px; border-left:solid 5px blue; margin:10px; } /* fieldset */ -// div.tabs div { background-color:gray; } div.tabs div:hover { background-color:#0000; } div.tabs div.select { background-color:#0000; } fieldset.plugin { background-color:#061c3c9e; padding:10px; margin:10px; } @@ -89,7 +88,6 @@ fieldset.input.date div.output td span.lunar.term { color:green; } fieldset.input.date div.output td span.lunar.fest { color:red; } fieldset.input.date div.status { text-align:center; } /* float */ -// body div.float { background-color:#0e3369b3; color:white; padding:5px; } body div.float { background-color:#0e3369b3; padding:5px; } body>div.toast div.title { color:yellow; float:left; } body>div.toast div.duration { color:gray; float:right; } @@ -215,7 +213,6 @@ body.mobile textarea { font-size:1.2rem; } body.mobile table.content th { padding:6px 6px; } body.mobile form.option>div.item { margin:0; height:38px; } body.mobile div.action>div.item { margin:0; height:38px; } -// body.mobile div.action { display:none; } body.mobile>div.carte div.item { font-size:1.6rem; } body.mobile>div.input.login input { font-size:1.4rem; width:264px; } body.mobile fieldset.plugin { margin:10px 0; } @@ -256,7 +253,6 @@ fieldset.plugin.parse.cmd>div.status { display:none; } fieldset.plugin.inner.cmd>legend { display:none; } fieldset.plugin.inner.cmd>div.action { display:none; } fieldset.plugin.inner.cmd>form.option { display:none; } -// fieldset.story.inner.float { background-color:black; } fieldset.xterm div.toggle { display:none; } /* layout */ table.layout { border-spacing:0; } diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index e6905cd9..7da8f01b 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -46,15 +46,15 @@ body.mobile fieldset.word fieldset.inner>form.option input[type=text] { display: div.zone>div.action>div.item input[type=text] { margin-right:-10px; } div.zone>div.list>div.zone>div.name:hover { margin-left:10px; transition:all 0.3s; } -div.tabs>div div.icon { margin-left:10px; margin-top:2px; float:right; visibility:hidden; } div.tabs>div:hover div.icon { visibility:visible; } -div.action>div div.icon { margin-left:10px; margin-top:2px; float:right; visibility:hidden; } div.action>div:hover div.icon { visibility:visible; } +div.tabs>div div.icon { margin-left:10px; margin-top:1px; float:right; visibility:hidden; } div.tabs>div:hover div.icon { visibility:visible; } +div.action>div div.icon { margin-left:10px; margin-top:1px; float:right; visibility:hidden; } div.action>div:hover div.icon { visibility:visible; } div.carte.path.float { font-size:14px; border-radius:0; } div.carte.path.float div.item { padding:5px; } div.path span.item { padding:5px; cursor:pointer; } tr.line>td.line { text-align:right; padding:0 10px; position:sticky; left:0; } tr.line>td.text { line-height:20px; white-space:pre; padding-left:10px; cursor:text; } body.white tr.line.select { background-color:dimgray; } body.white tr.line:hover { background-color:dimgray; } body.black tr.line.select { background-color:darkblue; } body.black tr.line:hover { background-color:darkblue; } -fieldset>div.output>fieldset.plug { bottom:0px; right:0px; display:none; } +fieldset>div.output>fieldset.plug { position:absolute; bottom:0px; right:0px; display:none; } fieldset>div.output>fieldset.plug.select { display:block; } body.mobile fieldset.plugin>legend { border:none; } .unselectable { -webkit-touch-callout:none; -webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; -o-user-select:none; user-select:none; } diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 8c6f9313..599b8e1c 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -12,7 +12,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl switch (can.Mode()) { case chat.SIMPLE: can.onmotion.hidden(can, can.ui.project); break case chat.FLOAT: can.onmotion.hidden(can, can.ui.project); break - case chat.CMD: can.page.style(can, document.body, "overflow", "hidden") + case chat.CMD: can.page.style(can, document.body, html.OVERFLOW, html.HIDDEN) can.onmotion.hidden(can, can._status), can.onimport._keydown(can) // no break case chat.FULL: // no break default: can.onimport.project(can, paths), can.onimport._tabs(can) @@ -80,6 +80,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl if (can.parse == nfs.JS) { if (_indent == 0 && can.base.beginWith(text, "Volcanos")) { var ls = can.core.Split(text, "\t ({:}),"); block = can.base.trimPrefix(ls[1], "chat.").toLowerCase() + if (text.indexOf("_init") > -1) { push(block+ice.PT+"_init"+ice.DF+(index+1)) } } else if (_indent == 4) { var ls = can.core.Split(text, "\t ({:}),"); ls[0] && push(block+ice.PT+ls[0]+ice.DF+(index+1)) } @@ -89,21 +90,11 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl switch (ls[0]) { case "package": package = ls[1]; break case "func": if (ls[1] == "(") { ls[1] = ls[2]+ice.PT+ls[5] - if (ls[5].toLowerCase()[0] == ls[5][0]) { - push("- "+ls[1]+ice.DF+(index+1)) - } else { - push("+ "+ls[1]+ice.DF+(index+1)) - } - break + if (ls[5].toLowerCase()[0] == ls[5][0]) { push("- "+ls[1]+ice.DF+(index+1)) } else { push("+ "+ls[1]+ice.DF+(index+1)) } break } case "type": case "var": - if (ls[1].toLowerCase()[0] == ls[1][0]) { - push("- "+ls[1]+ice.DF+(index+1)) - } else { - push("+ "+package+"."+ls[1]+ice.DF+(index+1)) - } - break + if (ls[1].toLowerCase()[0] == ls[1][0]) { push("- "+ls[1]+ice.DF+(index+1)) } else { push("+ "+package+"."+ls[1]+ice.DF+(index+1)) } break } } else if (_indent == 4) { if (text.indexOf("MergeCommands(") > -1) { block = "cmds" } else if (text == "})") { block = "" } @@ -127,7 +118,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.db.tabview[key] can.Option(can.onimport.history(can, {path: path, file: file, line: line||can.misc.localStorage(can, "web.code.inner:selectLine:"+path+file)||can._msg.Option(nfs.LINE)||1})) can.onsyntax._init(can, can._msg, function(content) { var msg = can._msg - can.onexport.hash(can), can.onmotion.select(can, can.ui.tabs, html.DIV_TABS, msg._tab) + can.onexport.hash(can), can.onmotion.select(can, can.ui.tabs, html.DIV_TABS, msg._tab), msg._tab.scrollIntoView() if (isCommand()) { can.ui.path.innerHTML = can.Option(nfs.FILE) } else if (isDream()) { @@ -149,7 +140,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl }), can.ui.current && can.onmotion.toggle(can, can.ui.current, !isCommand() && !isDream()) var ls = can.file.split(ice.PS); if (ls.length > 4) { ls = [ls.slice(0, 2).join(ice.PS)+"/.../"+ls.slice(-2).join(ice.PS)] } can.Status(kit.Dict("文件", ls.join(ice.PS), "类型", can.parse)), can.onimport.layout(can) - can.onaction.selectLine(can, can.Option(nfs.LINE)), can.onaction.scrollIntoView(can) can.base.isFunc(cb) && cb(), cb = null }) @@ -239,7 +229,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl layout: function(can) { if (can.isSimpleMode()) { return can.page.style(can, can.ui.content, html.WIDTH, can.ConfWidth()) } if (can.isCmdMode()) { can.page.styleHeight(can, can._output, can.ConfHeight(can.page.height())), can.ConfWidth(can.page.width()) } - if (can.isFloatMode()) { can.onmotion.hidden(can, can.ui.profile) } var width = can.ConfWidth()+(can.user.isWindows && !can.isCmdMode()? 20: 0) var height = can.user.isMobile && can.isFloatMode()? can.page.height()-2*html.ACTION_HEIGHT: can.base.Min(can.ConfHeight(), 320)-1 can.user.isMobile && can.isCmdMode() && can.page.style(can, can._output, html.MAX_HEIGHT, height) @@ -252,10 +241,10 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl sub.run = function(event, cmds, cb) { if (cmds.length > 0 && cmds[0] == ctx.ACTION) { can.run(can.request(event, can.Option()), cmds, cb||function(msg) { - can.onappend._output(sub, msg, sub.Conf("display")) + can.onappend._output(sub, msg, sub.Conf(ctx.DISPLAY)) }, true) } else { - can.onappend._output(sub, can.request(event), sub.Conf("display")) + can.onappend._output(sub, can.request(event), sub.Conf(ctx.DISPLAY)) } } can.db.extentions[url.split("?")[0]] = sub, can.base.isFunc(cb)? cb(sub): sub.select() @@ -337,8 +326,8 @@ Volcanos(chat.ONSYNTAX, {_init: function(can, msg, cb) { }, }) Volcanos(chat.ONACTION, { - _getLine: function(can, line) { return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0] }, - _getLineno: function(can, line) { return can.page.Select(can, can.ui.content, "tr>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return index+1 } })[0] }, + _getLine: function(can, line) { return can.page.Select(can, can.ui.content, "tr.line>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return td.parentNode } })[0] }, + _getLineno: function(can, line) { return can.page.Select(can, can.ui.content, "tr.line>td.line", function(td, index) { if (td.parentNode == line || index+1 == line) { return index+1 } })[0] }, appendLine: function(can, value) { var ui = can.page.Append(can, can.ui._content, [{type: html.TR, className: "line", list: [ {view: [[nfs.LINE, "unselectable"], html.TD, ++can.max], onclick: function(event) { @@ -354,7 +343,7 @@ Volcanos(chat.ONACTION, { ]}]); return ui.tr }, selectLine: function(can, line) { if (!line) { return can.onexport.line(can, can.page.SelectOne(can, can.ui._content, "tr.select")) } - can.page.Select(can, can.ui._content, "tr>td.line", function(td, index) { var tr = td.parentNode, n = parseInt(td.innerText) + can.page.Select(can, can.ui._content, "tr.line>td.line", function(td, index) { var tr = td.parentNode, n = parseInt(td.innerText) if (!can.page.ClassList.set(can, tr, html.SELECT, tr == line || n == line)) { return } line = tr, can.Status("行号", can.onexport.position(can, can.Option(nfs.LINE, n))) }); if (!can.base.isObject(line)) { return 0 } diff --git a/plugin/local/code/vimer.css b/plugin/local/code/vimer.css index f6a60e44..a5c4c8d2 100644 --- a/plugin/local/code/vimer.css +++ b/plugin/local/code/vimer.css @@ -1,12 +1,12 @@ fieldset.vimer>div.output div.project div.zone.create>div.action { display:none; } fieldset.vimer>div.output div.project div.zone.create>div.list div.item { padding:2px; float:left; clear:none; } fieldset.vimer>div.output div.project div.zone.create>div.list div.item input { letter-spacing:2px; } -fieldset.vimer>div.output div.project div.zone.recent>div.list { max-height:240px; overflow:auto; } +fieldset.vimer>div.output div.project div.zone.recent>div.list { min-width:200px; max-height:240px; overflow:auto; } fieldset.vimer>div.output input.current { background-color:#0000; color:#0000; padding-left:10px; height:20px; position:absolute; } fieldset.vimer>div.output input.current.insert { caret-color:black; } fieldset.vimer>div.output input.current.normal { caret-color:lightgray; } fieldset.vimer>div.output div.complete { padding-top:0; display:none; overflow:auto; position:absolute; } -fieldset.vimer>div.output div.complete.insert { display:block; } +fieldset.vimer>div.output div.complete.insert:not(.hide) { display:block; } fieldset.vimer>div.output div.complete div.prefix { color:#0000; white-space:pre; float:left; } fieldset.vimer>div.output div.complete table.content thead { display:none; } body.black fieldset.vimer>div.output input.current.normal { caret-color:gray; }