diff --git a/frame.js b/frame.js index a4715db7..1f8284e3 100644 --- a/frame.js +++ b/frame.js @@ -75,14 +75,21 @@ Volcanos(chat.ONDAEMON, {_init: function(can, name) { if (can.user.isLocalFile) toast: function(can, sub, arg) { can.core.CallFunc(can.user.toast, [sub].concat(arg)) }, refresh: function(can, sub) { can.base.isFunc(sub.Update) && sub.Update() }, action: function(can, msg, sub, arg) { - if (can.page.SelectInput(can, sub._option, arg[0], function(target) { - // can.onmotion.delay(can, function() { - target.type == html.BUTTON? target.click(): arg[1] && (target.value = arg[1], target.focus()) - // }) - return target })) { return } - var _sub = can.core.Value(sub, chat._OUTPUTS_CURRENT) - if (_sub && _sub.onaction && _sub.onaction[arg[0]]) { return _sub.onaction[arg[0]]({}, _sub, arg[0]) } + if (arg[0] == "ctrl") { var list = []; can.misc.Log("what ", document.activeElement) + can.page.Select(can, can._root._target, "input", function(target, index) { list[index] = target + if (document.activeElement == document.body) { return target.focus() } + switch (arg[1]) { + case "next": if (list[index-1] == document.activeElement) { target.focus() } break + case "prev": if (target == document.activeElement) { list[index-1].focus() } break + case "ok": if (target == document.activeElement) { target.focus() } break + } + }) + return + } + if (arg[0].indexOf(ice.PT) == -1 && can.page.SelectInput(can, sub._option, arg[0], function(target) { target.type == html.BUTTON? target.click(): (target.value = arg[1]||"", target.focus()); return target })) { return } + var _sub = can.core.Value(sub, chat._OUTPUTS_CURRENT); if (_sub && _sub.onaction && _sub.onaction[arg[0]]) { return _sub.onaction[arg[0]]({}, _sub, arg[0]) } if (sub && sub.onaction && sub.onaction[arg[0]]) { return sub.onaction[arg[0]]({}, sub, arg[0], _sub) } + can.core.CallFunc(can.core.Value(can, arg[0]), kit.Dict({can: can}, arg.slice(1))) }, input: function(can, msg, sub, arg) { can.page.Select(can, sub._target, "input:focus", function(target) { target.value += arg[0] }) }, grow: function(can, msg, sub, arg) { if (sub.sup && sub.sup.onimport._grow) { return sub.sup.onimport._grow(sub.sup, msg, can.page.Color(arg.join(""))) } }, @@ -249,7 +256,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.onmotion.modifys(can, event.target, function(event, value, old) { run(event, mdb.MODIFY, [key, value]) }, item) }} }); table && can.page.styleClass(can, table, chat.CONTENT), msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.page.ClassList.add(can, table, ctx.ACTION) - return sort && can.page.RangeTable(can, table, sort), table + return sort && can.page.RangeTable(can, table, can.core.List(sort, function(key) { + return can.page.Select(can, table, html.TH, function(th, index) { if (th.innerHTML == key) { return index } })[0] + })), table }, board: function(can, text, target) { text && text.Result && (text = text.Result()); if (!text) { return } var code = can.page.Append(can, target||can._output, [{text: [can.page.Color(text), html.DIV, html.CODE]}]).code @@ -394,8 +403,18 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { }) }, }, + clearFloat: function(can) { + can.page.SelectChild(can, can._root._target, "div.float", function(target) { + can.page.Remove(can, target) + }) + }, clearCarte: function(can) { - can.page.Select(can, can._root._target, "div.carte", function(target) { + can.page.SelectChild(can, can._root._target, "div.carte.float", function(target) { + can.page.Remove(can, target) + }) + }, + clearInput: function(can) { + can.page.SelectChild(can, can._root._target, "div.input.float", function(target) { can.page.Remove(can, target) }) }, diff --git a/lib/page.js b/lib/page.js index 43a9f04b..885442c1 100644 --- a/lib/page.js +++ b/lib/page.js @@ -108,28 +108,19 @@ Volcanos("page", {ClassList: { can.page.RangeTable(can, table, index, (dataset["sort_asc"] = (dataset["sort_asc"] == "1") ? 0: 1) == "1") } }); return table }, - RangeTable: function(can, table, index, sort_asc) { - index = can.core.List(index, function(item) { if (item > -1) { return item } }); if (index.length == 0) { return } - var list = can.page.Select(can, table, html.TR, function(tr) { - return tr.style.display == html.NONE||can.page.ClassList.has(can, tr, html.HIDE)? null: tr - }).slice(1) - var is_time = true, is_number = true; can.core.List(list, function(tr) { - var text = tr.childNodes[index[0]].innerText; is_time = is_time && Date.parse(text) > 0, is_number = is_number && !isNaN(parseInt(text)) - }) - var num_list = can.core.List(list, function(tr) { var text = tr.childNodes[index[0]].innerText - return is_time? Date.parse(text): is_number? can.base.ParseSize(text): text - }) - function isless(a, b, index) { - if (a.childNodes[index[0]] && b.childNodes[index[0]]) { - if (a.childNodes[index[0]].innerText < b.childNodes[index[0]].innerText) { return true } - if (a.childNodes[index[0]].innerText > b.childNodes[index[0]].innerText) { return false } - } return index.length > 1 && isless(a, b, index.slice(1)) - } + RangeTable: function(can, table, index, sort_asc) { index = can.base.isArray(index)? can.core.List(index, function(item) { if (item > -1) { return item } }): [index]; if (index.length == 0) { return } + var list = can.page.Select(can, table, html.TR, function(tr) { if (tr.style.display != html.NONE && !can.page.ClassList.has(can, tr, html.HIDE)) { return tr } }).slice(1) + var is_time = true, is_number = true; can.core.List(list, function(tr) { var text = tr.childNodes[index[0]].innerHTML; is_time = is_time && Date.parse(text) > 0, is_number = is_number && !isNaN(parseInt(text)) }) + var num_list = can.core.List(list, function(tr) { var text = tr.childNodes[index[0]].innerHTML; return is_time? Date.parse(text): is_number? can.base.ParseSize(text): text }) + function isless(a, b, index) { if (a.childNodes[index[0]] && b.childNodes[index[0]]) { + if (a.childNodes[index[0]].innerHTML < b.childNodes[index[0]].innerHTML) { return true } + if (a.childNodes[index[0]].innerHTML > b.childNodes[index[0]].innerHTML) { return false } + } return index.length > 1 && isless(a, b, index.slice(1)) } + for (var i = 0; i < num_list.length; i++) { var min = i for (var j = i+1; j < num_list.length; j++) { - if (num_list[min] == num_list[j] && index.length > 1 && list[index[1]]) { - if (sort_asc? isless(list[min], list[j], index.slice(1)): isless(list[j], list[min], index.slice(1))) { min = j } - } else if (sort_asc? num_list[min] < num_list[j]: num_list[j] < num_list[min]) { min = j } + if (sort_asc? num_list[min] < num_list[j]: num_list[j] < num_list[min]) { min = j; continue } + if (num_list[min] == num_list[j] && index.length > 1) { if (sort_asc? isless(list[min], list[j], index.slice(1)): isless(list[j], list[min], index.slice(1))) { min = j } } } if (min != i) { var temp = num_list[i]; num_list[i] = num_list[min]; num_list[min] = temp diff --git a/page/index.css b/page/index.css index 935cebbd..71c67086 100644 --- a/page/index.css +++ b/page/index.css @@ -31,7 +31,7 @@ table.layout td.content div.toggle.project { padding-top:50px; height:100px; wid table.layout td.content div.toggle.profile { padding-top:50px; height:100px; width:15px; top:20%; right:0px; border-top-left-radius:10px; border-bottom-left-radius:10px; } table.layout td.content div.toggle.display { margin-top:-15px; height:15px; width:100px; position:sticky; left:40%; border-top-left-radius:10px; border-top-right-radius:10px; overflow:hidden; } table.layout td.content div.toggle.display>div { text-align:center; width:100px; transform: rotate(-90deg) translate(5px, 0px); } -table.content { width:-webkit-fill-available;} +// table.content { width:-webkit-fill-available;} table.content thead { position:sticky; top:2px; } table.content th { background-color:steelblue; padding:2px 6px; } table.content td { padding:2px 6px; } @@ -278,7 +278,7 @@ body.mobile.landscape div.output.card div.item { width:auto; float:left; } body.mobile.landscape.simple div.output.card div.item { width:auto; float:left; } -body.simple fieldset.Header { border-bottom:solid 1px #e7e7e7; height:60px; display:block; } +body.simple fieldset.Header { border-bottom:solid 1px #e7e7e7; height:60px; } body.simple fieldset.River { border-right:solid 1px #e7e7e7; } body.simple fieldset.River>div.output { padding:10px 10px; width:200px; } body.simple fieldset.River>div.output div.item { color:black; padding:10px 40px; border-left:none; } diff --git a/panel/header.js b/panel/header.js index 6de9446e..6c333b75 100644 --- a/panel/header.js +++ b/panel/header.js @@ -66,7 +66,6 @@ Volcanos(chat.ONACTION, { ), onmain: function(can) { can.onimport.topic(can) can.run({}, [], function(msg) { if (!can.Conf(aaa.USERNICK, msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME))) { - debugger return msg.Option(chat.SSO)? can.user.jumps(msg.Option(chat.SSO)): can.user.login(can, function() { can.onengine.signal(can, chat.ONMAIN, msg) }, msg.Option(aaa.LOGIN)) } can.user.info.usernick = can.Conf(aaa.USERNICK), can.user.info.language = can.misc.Search(can, aaa.LANGUAGE)||msg.Option(aaa.LANGUAGE) can.user.info.background = msg.Option(aaa.BACKGROUND), can.user.info.avatar = msg.Option(aaa.AVATAR) diff --git a/plugin/local/chat/keyboard.css b/plugin/local/chat/keyboard.css index b7961a72..7568c4b1 100644 --- a/plugin/local/chat/keyboard.css +++ b/plugin/local/chat/keyboard.css @@ -1,3 +1,2 @@ -fieldset.keyboard div.output div.item { - float:left; -} +fieldset.keyboard div.output div.item { float:left; margin:5px; } +fieldset.keyboard div.output div.space { clear:both; } diff --git a/plugin/local/chat/keyboard.js b/plugin/local/chat/keyboard.js index b31bb668..22b01cb8 100644 --- a/plugin/local/chat/keyboard.js +++ b/plugin/local/chat/keyboard.js @@ -1,40 +1,24 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.onmotion.clear(can) - var data = msg.TableDetail(), list = can.base.Obj(data.list), meta = can.base.Obj(data.meta) - can.user.trans(can, meta._trans), can.core.List(list, function(item) { - item._init = function(target) { - switch (target.type) { - case html.BUTTON: - target.onclick = function(event) { can.request(event, data) - can.runAction(event, web.SPACE, [ctx.ACTION, item.name], function() {}) - } - break - case html.TEXT: - target.onkeydown = function(event) { can.request(event, data) - if (event.key == lang.ENTER) { - can.runAction(event, web.SPACE, [ctx.ACTION, item.name, target.value], function() {}) - } - } - break - } - } - can.onappend.input(can, item, "", can._output) - }) - can.onimport._button(can, can.sup.onaction.list, data) - return - can.onappend.table(can, msg), can.onappend.board(can, msg) - can.require(["/plugin/input/keyboard.js"], function() { - can.onfigure.keyboard._show(can, function(value) { - can.runAction(can.request({}, meta, can.Option()), "input", [value]) - }) - }) -}, - _button: function(can, item, data) { item = can.base.isObject(item)? item: {type: html.BUTTON, name: item} - if (can.base.isArray(item)) { return can.core.List(item, function(item) { can.onimport._button(can, item, data) }) } - item._init = item._init||function(target) { - target.onclick = function(event) { can.request(event, data) - can.runAction(event, web.SPACE, [ctx.ACTION, item.name], function() {}) - } - } - can.onappend.input(can, item, "", can._output) + var data = msg.TableDetail(), list = can.base.Obj(data.list), meta = can.base.Obj(data.meta) + var ui = can.page.Append(can, can._output, ["global", "option", "legend"]); can.user.trans(can, meta._trans) + can.onimport._input(can, [ + {type: html.BUTTON, name: "清屏", cmds: "onmotion.clearFloat"}, + {type: html.TEXT}, + {type: html.BUTTON, name: "下一个", cmds: ["ctrl", "next"]}, + {type: html.BUTTON, name: "上一个", cmds: ["ctrl", "prev"]}, + {type: html.BUTTON, name: "确定", cmds: ["ctrl", "ok"]}, + ], data, ui.global) + can.onimport._input(can, list, data, ui.option), can.onimport._input(can, can.sup.onaction.list, data, ui.legend) + }, + _input: function(can, item, data, target) { item = can.base.isObject(item)? item: {type: html.BUTTON, name: item} + if (can.base.isArray(item)) { return can.page.Append(can, target, [{view: "space"}]), can.core.List(item, function(item) { can.onimport._input(can, item, data, target) }) } + item._init = item._init||function(target) { switch (target.type) { + case html.TEXT: target.onkeydown = function(event) { if (event.key == lang.ENTER) { + can.runAction(can.request(event, data), web.SPACE, [ctx.ACTION, item.name, target.value], function() {}) + } }; break + case html.BUTTON: target.onclick = function(event) { + can.runAction(can.request(event, data), web.SPACE, [ctx.ACTION].concat(item.cmds||item.name), function() {}) + }; break + } }, can.onappend.input(can, item, "", target) }, }, [""]) diff --git a/plugin/local/code/vimer.js b/plugin/local/code/vimer.js index d21c6673..9cfd1ff1 100644 --- a/plugin/local/code/vimer.js +++ b/plugin/local/code/vimer.js @@ -28,7 +28,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { Volcanos(chat.ONFIGURE, { create: function(can, target, zone, path) { can.isCmdMode()? can.onappend._action(can, can.base.Obj(can._msg.Option(ice.MSG_ACTION)).concat( - ["查找", "git", "首页", "官网" , "文档" , "百度"], window.webview? ["浏览器", "录屏", "编辑器", "日志"]: [], + ["favor", "git", "首页", "官网" , "文档" , "百度"], window.webview? ["浏览器", "录屏", "编辑器", "日志"]: [], ), target): can.onmotion.hidden(can, target.parentNode) }, recent: function(can, target, zone, path) { var total = 0 @@ -319,6 +319,7 @@ Volcanos(chat.ONACTION, { can.onimport.exts(can, list[0]) }) }, + "favor": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.chat.favor", ctx.INDEX) }, "plan": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.team.plan", ctx.INDEX) }, "git": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) }, "vim": function(event, can) { @@ -331,10 +332,12 @@ Volcanos(chat.ONACTION, { "日志": function(event, can) { window.opencmd("cd ~/contexts; tail -f var/log/bench.log") }, "编辑器": function(event, can) { window.opencmd("cd ~/contexts; vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)) }, "浏览器": function(event, can) { window.openurl(location.href) }, - "首页": function(event, can) { can.user.isWebview? window.openurl(location.protocol+"//"+location.host): window.open(location.protocol+"//"+location.host) }, - "百度": function(event, can) { can.user.isWebview? window.openurl("https://baidu.com"): can.user.open("https://baidu.com") }, - "文档": function(event, can) { can.user.isWebview? window.openurl("https://developer.mozilla.org/"): can.user.open("https://developer.mozilla.org/") }, - "官网": function(event, can) { can.user.isWebview? window.openurl("https://shylinux.com/"): can.user.open("https://shylinux.com/") }, + _open: function(can, url) { can.user.isWebview? window.openurl(url): window.open(url) }, + "收藏": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host+"/chat/cmd/web.chat.favor") }, + "首页": function(event, can) { can.onaction._open(can, location.protocol+"//"+location.host) }, + "百度": function(event, can) { can.onaction._open(can, "https://baidu.com") }, + "文档": function(event, can) { can.onaction._open(can, "https://developer.mozilla.org/") }, + "官网": function(event, can) { can.onaction._open(can, "https://shylinux.com/") }, "查找": function(event, can) { var ui = can.page.Append(can, can._output, [{view: "vimer find float", list: [html.ACTION, html.OUTPUT], style: {position: "absolute", left: can.ui.project.offsetWidth+can.ui.content.offsetWidth/2, top: can.base.Max(can.base.Min(can.current.line.offsetTop-can.ui.content.scrollTop, 100), can.ConfHeight()/2)+57+28}}]) diff --git a/proto.js b/proto.js index 5351381c..d404b4ae 100644 --- a/proto.js +++ b/proto.js @@ -1,6 +1,8 @@ var kit = {proto: function(sub, sup) { return sub.__proto__ = sup, sub }, - Dict: function() { var res = {}, args = arguments; for (var i = 0; i < args.length; i += 2) { - if (typeof args[i] == "object") { for (var k in args[i]) { res[k] = args[i][k] } i-- } else if (typeof args[i] == "string" && args[i]) { res[args[i]] = args[i+1] } + Dict: function() { var res = {}, args = arguments; for (var i = 0; i < args.length; i += 2) { var value = args[i] + if (typeof value == "object") { i--; for (var k in value) { res[k] = value[k] } + for (var j = 0; j < value.length; j += 2) { res[value[j]] = value[j+1] } + } else if (typeof value == "string" && value) { res[value] = args[i+1] } } return res }, } var ice = {