From 5c5ea7d85e8ea095673d5233781011be117c8d2b Mon Sep 17 00:00:00 2001 From: shylinux Date: Sun, 14 Apr 2019 14:00:25 +0800 Subject: [PATCH] opt code.tmpl --- src/contexts/web/web.go | 1 + src/examples/code/code.go | 23 +- usr/librarys/code.css | 232 ++++++++-------- usr/librarys/code.js | 486 ++++++++++++++++----------------- usr/{ => librarys}/favicon.ico | Bin usr/librarys/toolkit.js | 5 + usr/template/code/code.tmpl | 210 ++++++-------- 7 files changed, 461 insertions(+), 496 deletions(-) rename usr/{ => librarys}/favicon.ico (100%) diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index ae05290d..68a465c4 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -968,6 +968,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", } } } + msg.Log("fuck", "what %v", msg.Option("componet_name")) // 添加设备 arg = arg[:0] diff --git a/src/examples/code/code.go b/src/examples/code/code.go index b3bee7f7..7ad29fb6 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -89,17 +89,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", "componet_group": &ctx.Config{Name: "component_group", Value: "index", Help: "默认组件"}, "componet": &ctx.Config{Name: "componet", Value: map[string]interface{}{ "login": []interface{}{ - map[string]interface{}{"name": "head", "template": "head"}, + map[string]interface{}{"name": "code", "template": "head", "metas": []interface{}{ + map[string]interface{}{"name": "viewport", "content": "width=device-width, initial-scale=0.7"}, + map[string]interface{}{"name": "user-scalable", "content": "no"}, + }, "favicon": "favicon.ico", "styles": []interface{}{"example.css", "code.css"}}, map[string]interface{}{"name": "login", "help": "login", "template": "componet", - "componet_ctx": "aaa", "componet_cmd": "auth", "arguments": []interface{}{"@sessid", "ship", "username", "@username", "password", "@password"}, - "inputs": []interface{}{ + "componet_ctx": "aaa", "componet_cmd": "auth", "arguments": []interface{}{"@sessid", "ship", "username", "@username", "password", "@password"}, "inputs": []interface{}{ map[string]interface{}{"type": "text", "name": "username", "label": "username", "value": ""}, map[string]interface{}{"type": "password", "name": "password", "label": "password", "value": ""}, map[string]interface{}{"type": "button", "value": "login"}, }, "display_append": "", "display_result": "", }, - map[string]interface{}{"name": "tail", "template": "tail"}, + map[string]interface{}{"name": "tail", "template": "tail", + "scripts": []interface{}{"toolkit.js", "context.js", "example.js", "code.js"}, + }, }, "flash": []interface{}{ map[string]interface{}{"name": "flash", "template": "head"}, @@ -121,7 +125,11 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", map[string]interface{}{"name": "tail", "template": "tail"}, }, "index": []interface{}{ - map[string]interface{}{"name": "code", "template": "head"}, + map[string]interface{}{"name": "code", "template": "head", "metas": []interface{}{ + map[string]interface{}{"name": "viewport", "content": "width=device-width, initial-scale=0.7"}, + map[string]interface{}{"name": "user-scalable", "content": "no"}, + }, "favicon": "favicon.ico", "styles": []interface{}{"example.css", "code.css"}}, + map[string]interface{}{"name": "toolkit", "help": "Ctrl+B", "template": "toolkit", "componet_view": "KitList", "componet_init": "initKitList", }, @@ -138,7 +146,6 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", // "componet_ctx": "aaa", "componet_cmd": "login", "arguments": []interface{}{"@sessid"}, // "pre_run": true, // }, - map[string]interface{}{"name": "clipboard", "help": "clipboard", "template": "clipboard"}, map[string]interface{}{"name": "buffer", "help": "buffer", "template": "componet", "componet_ctx": "cli", "componet_cmd": "tmux", "arguments": []interface{}{"buffer"}, "inputs": []interface{}{ map[string]interface{}{"type": "text", "name": "limit", "label": "limit", "value": "3"}, @@ -211,7 +218,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", }, }, // map[string]interface{}{"name": "mp", "template": "mp"}, - map[string]interface{}{"name": "tail", "template": "tail"}, + map[string]interface{}{"name": "tail", "template": "tail", + "scripts": []interface{}{"toolkit.js", "context.js", "example.js", "code.js"}, + }, }, }, Help: "组件列表"}, "upgrade": &ctx.Config{Name: "upgrade", Value: map[string]interface{}{ diff --git a/usr/librarys/code.css b/usr/librarys/code.css index a1f14d5e..bf001e88 100644 --- a/usr/librarys/code.css +++ b/usr/librarys/code.css @@ -1,119 +1,119 @@ -fieldset { - margin-top:8px; -} -fieldset legend { - font-size:16px; - font-weight:bold; - font-family:monospace; -} -fieldset form.option div { - float:left; -} -fieldset form.option input { - margin-right:10px; -} -fieldset form.option select { - margin-right:10px; -} -fieldset form.option hr { - clear:both; -} +/* ----- common ----- */ + fieldset { + margin-top:8px; + } + fieldset legend { + font-size:16px; + font-weight:bold; + font-family:monospace; + } + fieldset form.option div { + float:left; + } + fieldset form.option input { + margin-right:10px; + } + fieldset form.option input.cmd { + color:white; + background-color:#272822; + padding-left:10px; + width:600px; + } + fieldset form.option select { + margin-right:10px; + } + fieldset form.option hr { + clear:both; + } -fieldset table.append { - font-size:14px; - overflow: auto; -} -fieldset table.append tr:hover { - background-color:lightgreen; -} -fieldset table.append th { - font-family:monospace; - background-color:lightgreen; - cursor:pointer; -} -fieldset table.append th.order { - background-color:red; - cursor:pointer; -} -fieldset table.append td { - max-width:1200px; - font-family:monospace; - padding-left: 10px; - padding-right: 20px; -} -fieldset table.append td.clip { - background-color:red; -} -fieldset table.append td:hover { - background-color:red; -} -fieldset code.result pre { - color:white; - font-size:14px; - background-color:#272822; - overflow:scroll; - padding:5px; - border:solid 2px green; - border-left:solid 4px green; - margin:0; -} -fieldset code.result pre.clipboard { - height:2em; -} + fieldset table.append { + font-size:14px; + overflow: auto; + } + fieldset table.append tr:hover { + background-color:lightgreen; + } + fieldset table.append th { + font-family:monospace; + background-color:lightgreen; + cursor:pointer; + } + fieldset table.append th.order { + background-color:red; + cursor:pointer; + } + fieldset table.append td { + max-width:1200px; + font-family:monospace; + padding-left: 10px; + padding-right: 20px; + } + fieldset table.append td.clip { + background-color:red; + } + fieldset table.append td:hover { + background-color:red; + } + fieldset code.result pre { + color:white; + font-size:14px; + background-color:#272822; + overflow:scroll; + padding:5px; + border:solid 2px green; + border-left:solid 4px green; + margin:0; + } + fieldset code.result pre.clipboard { + height:2em; + } +/* ----- FlashList ----- */ + fieldset.flasktext { + } -fieldset.flasktext { -} + fieldset.flasklist div.detail { + border:ridge 2px green; + border-bottom:0px; + margin-top:20px; + padding:5px; + } + fieldset.flasklist div.action { + border:ridge 2px green; + border-top:0px; + border-bottom:0px; + } + fieldset.flasklist code.output pre { + border:ridge 2px green; + margin:0px; + padding:5px; + border-top: 0px; + } +/* ----- KitList ----- */ + fieldset.KitList { + color:#e6dd37; + font-size:14px; + font-family:monospace; + background-color:#498bb1a8; + border:solid 3px red; + width:60px; + height:20px; + overflow:scroll; + position:fixed; + } + fieldset.KitList:hover, fieldset.KitList.max {} + fieldset.KitList div:hover, fieldset.KitList li li:hover { + background-color:red; + } + fieldset.KitList div.stick, fieldset.KitList li li.stick { + background-color:red; + } + fieldset.KitList li>label.result{ + background-color:rgba(0,0,0,0.2); + padding:0 5px; + border:2px solid green; + margin-left: 10px; + } + fieldset.KitList li>input { + background-color:rgba(0,0,0,0.2); + } -fieldset.flasklist div.detail { - border:ridge 2px green; - border-bottom:0px; - margin-top:20px; - padding:5px; -} -fieldset.flasklist div.action { - border:ridge 2px green; - border-top:0px; - border-bottom:0px; -} -fieldset.flasklist code.output pre { - border:ridge 2px green; - margin:0px; - padding:5px; - border-top: 0px; -} - - -textarea.clipboard { - color:white; - background-color:#272822; - width:600px; -} - -form.option label.keymap { - color:red; - display:none; -} -form.option label.keymap.show { - display:inline; -} -form.option input.cmd { - color:white; - background-color:#272822; - padding-left:10px; - width:600px; -} -form.option input.file_cmd { - color:white; - background-color:#272822; - padding-left:10px; - width:400px; -} -form.option input.file_name { - width:200px; -} -form.option.exec input { - color:white; - background-color:#272822; - padding-left:10px; - width:600px; -} diff --git a/usr/librarys/code.js b/usr/librarys/code.js index 311789cd..bbee02ad 100644 --- a/usr/librarys/code.js +++ b/usr/librarys/code.js @@ -7,11 +7,11 @@ var page = Page({ initFlashList: function(page, field, option, append, result) { option.dataset.flash_index = ctx.Search("flash_index") option.onactions = function(msg) { - page.onFlashShow(msg, field, option, append, result) + page.showFlashList(msg, option, append, result) } ctx.Run(page, option.dataset, [], option.onactions) }, - onFlashShow: function(msg, field, option, append, result) { + showFlashList: function(msg, option, append, result) { var page = this result.innerHTML = "" ctx.Table(msg, function(tip) { @@ -81,243 +81,6 @@ var page = Page({ return {"button": ["ctx", "shy", "web", "mdb"], "action": change, "table": {"names": change}} }, - getCmdList: function(input, step, cmd) { - var history = kit.History.get("cmd") - var length = history.length - var last = (parseInt(input.dataset["history_last"]||length)+step+length)%length - if (0 <= last && last < length) { - input.dataset["history_last"] = last - cmd = history[last].data - } - return cmd - }, - showCmdResult: function(page) { - page.conf.show_result = !page.conf.show_result - document.querySelectorAll("body>fieldset>code.result>pre").forEach(function(result) { - result.style.height = (page.conf.show_result || result.innerText=="")? "": page.conf.show_height - }) - }, - showCmdList: function(msg, option, append, result) { - append.innerHTML = "" - kit.AppendTable(append, ctx.Table(msg), msg.append) - result.innerHTML = "" - result.innerText = msg.result.join("") - return - }, - initCmdList: function(page, field, option, append, result) { - option.dataset["componet_name_alias"] = "cmd" - option.dataset["componet_name_order"] = 0 - option.onactions = function(msg) { - page.showCmdList(msg, option, append, result) - } - - var cmd = option.querySelector("input[name=cmd]") - cmd.onkeyup = function(event) { - page.onCmdList("input", cmd, option, append, result, event) - } - - var action = bench_data.action - if (action && action["cmd"]) { - cmd.value = action["cmd"].cmd[1] - ctx.Runs(page, option) - page.History.add("cmd", cmd.value) - } - - var max = 0 - for (var k in action) { - var order = parseInt(action[k].order) - if (order > max) { - max = order - } - } - - for (var i = 1; i <= max; i++) { - var ui = page.addCmdList("cmd", i) - if (action["cmd"+i]) { - ui.cmd.value = action["cmd"+i].cmd[1] - ctx.Runs(page, ui.option) - page.History.add("cmd", ui.cmd.value) - } - } - page.conf.ncommand = i - return - }, - addCmdList: function(name, order) { - var page = this - var alias = name+order - var ui = kit.AppendChild(document.querySelector("body"), [{"type": "fieldset", "data": {}, "list": [ - {"text": [alias, "legend"]}, - {"view": ["option "+alias, "form", "", "option"], "data": {"dataset": { - "componet_group": "index", "componet_name": name, "componet_name_alias": alias, "componet_name_order": order, - }, "onactions": function(msg) { - page.showCmdList(msg, ui.option, ui.append, ui.result) - }}, "list": [ - {"type": "input", "data": {"style": {"display": "none"}}}, - {"name": "cmd", "type": "input", "data": {"name": "cmd", "className": "cmd", "onkeyup": function(event) { - page.onCmdList("input", ui.cmd, ui.option, ui.append, ui.result, event) - }}}, - ]}, - {"view": ["append "+alias, "table", "", "append"]}, - {"code": ["", "result", "result "+alias]}, - ]}]) - page.OrderTable(ui.append) - page.OrderCode(ui.code) - ui.cmd.focus() - return ui - }, - delCmdList: function(name, order) { - var option = document.querySelector("form.option.cmd"+order) - option && document.body.removeChild(option.parentElement) - - for (;order < page.conf.ncommand; order++) { - var input = document.querySelector("form.option.cmd"+order+" input[name=cmd]") - if (input) { - input.focus() - return - } - } - for (;order >= 0; order--) { - var input = document.querySelector("form.option.cmd"+(order? order: "")+" input[name=cmd]") - page.conf.ncommand = order+1 - if (input) { - input.focus() - return - } - } - }, - onCmdList: function(action, target, option, append, result, event) { - var page = this - var order = option.dataset.componet_name_order - var prev_order = (parseInt(order)-1+page.conf.ncommand)%page.conf.ncommand||"" - var next_order = (parseInt(order)+1)%page.conf.ncommand||"" - - switch (action) { - case "input": - if (event.key == "Escape") { - target.blur() - - } else if (event.key == "Enter") { - target.dataset.history_last = page.History.get("cmd").length - page.History.add("cmd", target.value) - ctx.Runs(page, option) - - } else if (event.ctrlKey) { - switch (event.key) { - case "0": - var pre_pre = document.querySelector("code.result.cmd"+(event.shiftKey? next_order: prev_order)+" pre") - pre_pre && (target.value += pre_pre.innerText) - break - case "1": - case "2": - case "3": - case "4": - case "5": - case "6": - case "7": - case "8": - case "9": - if (code.quick_txt) { - var item = document.querySelectorAll("div.workflow>ul>li>ul.txt>li[data-text]") - target.value += item[parseInt(event.key)-1].dataset["text"] - } else { - var item = document.querySelectorAll("table.append.cmd"+(event.shiftKey? next_order: prev_order)+" td") - target.value += item[parseInt(event.key)-1].innerText - } - break - case "p": - target.value = page.getCmdList(target, -1, target.value) - break - case "n": - target.value = page.getCmdList(target, 1, target.value) - break - case "g": - var value = target.value.substr(0, target.selectionStart) - var last = parseInt(target.dataset.search_last || kit.History.get("cmd").length-1) - for (var i = last; i >= 0; i--) { - var cmd = kit.History.get("cmd", i).data - if (cmd.startsWith(value)) { - target.value = cmd - target.dataset.search_last = i-1 - target.setSelectionRange(value.length, cmd.length) - break - } - } - target.dataset.search_last = "" - break - case "a": - case "e": - case "f": - case "b": - case "h": - case "d": - break - case "k": - kit.DelText(target, target.selectionStart) - break - case "u": - kit.DelText(target, 0, target.selectionEnd) - break - case "w": - var start = target.selectionStart-2 - var end = target.selectionEnd-1 - for (var i = start; i >= 0; i--) { - if (target.value[end] == " " && target.value[i] != " ") { - break - } - if (target.value[end] != " " && target.value[i] == " ") { - break - } - } - kit.DelText(target, i+1, end-i) - break - case "c": - append.innerHTML = "" - result.innerHTML = "" - break - case "r": - append.innerHTML = "" - result.innerHTML = "" - case "j": - target.dataset.history_last = page.History.get("cmd").length - page.History.add("cmd", target.value) - ctx.Runs(page, option) - break - case "l": - window.scrollTo(0, option.parentElement.offsetTop) - break - case "m": - page.addCmdList("cmd", page.conf.ncommand++) - break - case "i": - var input = document.querySelector("form.option.cmd"+next_order+" input[name=cmd]") - input && input.focus() - break - case "o": - var input = document.querySelector("form.option.cmd"+prev_order+" input[name=cmd]") - input && input.focus() - break - case "x": - result.style.height = result.style.height? "": page.conf.hide_height - break - case "z": - result.style.height = result.style.height? "": page.conf.show_height - break - case "q": - page.delCmdList("cmd", order) - default: - return - } - } else { - kit.History.add("key", event.key) - if (kit.HitText(target, "jk")) { - kit.DelText(target, target.selectionStart-2, 2) - target.blur() - } - } - event.stopPropagation() - } - }, - initKitList: function(page, field, option, append, result) { var ui = kit.AppendChild(field, [{"type": "ul", "list": [ {"fork": ["粘贴板", [ @@ -334,7 +97,7 @@ var page = Page({ {"fork": ["命令行", [ {"leaf": ["+ 折叠命令行(Ctrl+Z)", function(event, target) { target.className = page.conf.show_result? "": "stick" - page.showCmdResult(page) + page.showResult(page) }]}, {"leaf": ["+ 添加命令行(Ctrl+M)", function(event) { page.addCmdList("cmd", page.conf.ncommand++) @@ -507,8 +270,237 @@ var page = Page({ }) return }, + initCmdList: function(page, field, option, append, result) { + option.dataset["componet_name_alias"] = "cmd" + option.dataset["componet_name_order"] = 0 + option.onactions = function(msg) { + page.showCmdList(msg, option, append, result) + } - onaction: function(action, target, event) { + var cmd = option.querySelector("input[name=cmd]") + cmd.onkeyup = function(event) { + page.onCmdList(event, cmd, "input", option, append, result) + } + + var action = conf.bench_data.action + if (action && action["cmd"]) { + cmd.value = action["cmd"].cmd[1] + ctx.Runs(page, option) + page.History.add("cmd", cmd.value) + } + + var max = 0 + for (var k in action) { + var order = parseInt(action[k].order) + if (order > max) { + max = order + } + } + + for (var i = 1; i <= max; i++) { + var ui = page.addCmdList("cmd", i) + if (action["cmd"+i]) { + ui.cmd.value = action["cmd"+i].cmd[1] + ctx.Runs(page, ui.option) + page.History.add("cmd", ui.cmd.value) + } + } + page.conf.ncommand = i + return + }, + showCmdList: function(msg, option, append, result) { + append.innerHTML = "" + msg && msg.append && kit.AppendTable(append, ctx.Table(msg), msg.append) + result.innerText = (msg && msg.result)? msg.result.join(""): "" + return + }, + getCmdList: function(input, step, cmd) { + var history = kit.History.get("cmd") + var length = history.length + var last = (parseInt(input.dataset["history_last"]||length)+step+length)%length + if (0 <= last && last < length) { + input.dataset["history_last"] = last + cmd = history[last].data + } + return cmd + }, + addCmdList: function(name, order) { + var page = this + var alias = name+order + var ui = kit.AppendChild(document.querySelector("body"), [{"type": "fieldset", "data": {}, "list": [ + {"text": [alias, "legend"]}, + {"view": ["option "+alias, "form", "", "option"], "data": {"dataset": { + "componet_group": "index", "componet_name": name, "componet_name_alias": alias, "componet_name_order": order, + }, "onactions": function(msg) { + page.showCmdList(msg, ui.option, ui.append, ui.result) + }}, "list": [ + {"type": "input", "data": {"style": {"display": "none"}}}, + {"name": "cmd", "type": "input", "data": {"name": "cmd", "className": "cmd", "onkeyup": function(event) { + page.onCmdList(event, ui.cmd, "input", ui.option, ui.append, ui.result) + }}}, + ]}, + {"view": ["append "+alias, "table", "", "append"]}, + {"code": ["", "result", "result "+alias]}, + ]}]) + page.OrderTable(ui.append) + page.OrderCode(ui.code) + ui.cmd.focus() + return ui + }, + delCmdList: function(name, order) { + var option = document.querySelector("form.option.cmd"+order) + option && document.body.removeChild(option.parentElement) + + for (;order < page.conf.ncommand; order++) { + var input = document.querySelector("form.option.cmd"+order+" input[name=cmd]") + if (input) { + input.focus() + return + } + } + for (;order >= 0; order--) { + var input = document.querySelector("form.option.cmd"+(order? order: "")+" input[name=cmd]") + page.conf.ncommand = order+1 + if (input) { + input.focus() + return + } + } + }, + onCmdList: function(event, target, action, option, append, result) { + var page = this + var order = option.dataset.componet_name_order + var prev_order = (parseInt(order)-1+page.conf.ncommand)%page.conf.ncommand||"" + var next_order = (parseInt(order)+1)%page.conf.ncommand||"" + + switch (action) { + case "input": + if (event.key == "Escape") { + target.blur() + + } else if (event.key == "Enter") { + target.dataset.history_last = page.History.get("cmd").length + page.History.add("cmd", target.value) + ctx.Runs(page, option) + + } else if (event.ctrlKey) { + switch (event.key) { + case "0": + var pre_pre = document.querySelector("code.result.cmd"+(event.shiftKey? next_order: prev_order)+" pre") + pre_pre && (target.value += pre_pre.innerText) + break + case "1": + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + case "9": + if (code.quick_txt) { + var item = document.querySelectorAll("div.workflow>ul>li>ul.txt>li[data-text]") + target.value += item[parseInt(event.key)-1].dataset["text"] + } else { + var item = document.querySelectorAll("table.append.cmd"+(event.shiftKey? next_order: prev_order)+" td") + target.value += item[parseInt(event.key)-1].innerText + } + break + case "p": + target.value = page.getCmdList(target, -1, target.value) + break + case "n": + target.value = page.getCmdList(target, 1, target.value) + break + case "g": + var value = target.value.substr(0, target.selectionStart) + var last = parseInt(target.dataset.search_last || kit.History.get("cmd").length-1) + for (var i = last; i >= 0; i--) { + var cmd = kit.History.get("cmd", i).data + if (cmd.startsWith(value)) { + target.value = cmd + target.dataset.search_last = i-1 + target.setSelectionRange(value.length, cmd.length) + break + } + } + target.dataset.search_last = "" + break + case "a": + case "e": + case "f": + case "b": + case "h": + case "d": + break + case "k": + kit.DelText(target, target.selectionStart) + break + case "u": + kit.DelText(target, 0, target.selectionEnd) + break + case "w": + var start = target.selectionStart-2 + var end = target.selectionEnd-1 + for (var i = start; i >= 0; i--) { + if (target.value[end] == " " && target.value[i] != " ") { + break + } + if (target.value[end] != " " && target.value[i] == " ") { + break + } + } + kit.DelText(target, i+1, end-i) + break + case "c": + append.innerHTML = "" + result.innerHTML = "" + break + case "r": + append.innerHTML = "" + result.innerHTML = "" + case "j": + target.dataset.history_last = page.History.get("cmd").length + page.History.add("cmd", target.value) + ctx.Runs(page, option) + break + case "l": + window.scrollTo(0, option.parentElement.offsetTop) + break + case "m": + page.addCmdList("cmd", page.conf.ncommand++) + break + case "i": + var input = document.querySelector("form.option.cmd"+next_order+" input[name=cmd]") + input && input.focus() + break + case "o": + var input = document.querySelector("form.option.cmd"+prev_order+" input[name=cmd]") + input && input.focus() + break + case "x": + result.style.height = result.style.height? "": page.conf.hide_height + break + case "z": + result.style.height = result.style.height? "": page.conf.show_height + break + case "q": + page.delCmdList("cmd", order) + default: + return + } + } else { + kit.History.add("key", event.key) + if (kit.HitText(target, "jk")) { + kit.DelText(target, target.selectionStart-2, 2) + target.blur() + } + } + event.stopPropagation() + } + }, + + onaction: function(event, target, action) { var page = this switch (action) { case "scroll": @@ -569,7 +561,7 @@ var page = Page({ page.addCmdList("cmd", page.conf.ncommand++) return case "z": - page.showCmdResult(page) + page.showResult(page) return case "0": case "1": @@ -587,14 +579,20 @@ var page = Page({ } } }, + showResult: function(page, type) { + page.conf.show_result = !page.conf.show_result + document.querySelectorAll("body>fieldset>code.result>pre").forEach(function(result) { + result.style.height = (page.conf.show_result || result.innerText=="")? "": page.conf.show_height + }) + }, init: function(exp) { var page = this var body = document.body body.onkeydown = function(event) { - page.onaction("scroll", body, event) + page.onaction(event, body, "scroll") } body.onkeyup = function(event) { - page.onaction("keymap", body, event) + page.onaction(event, body, "keymap") } document.querySelectorAll("body>fieldset").forEach(function(field) { diff --git a/usr/favicon.ico b/usr/librarys/favicon.ico similarity index 100% rename from usr/favicon.ico rename to usr/librarys/favicon.ico diff --git a/usr/librarys/toolkit.js b/usr/librarys/toolkit.js index 1500d92a..59f98ce7 100644 --- a/usr/librarys/toolkit.js +++ b/usr/librarys/toolkit.js @@ -255,6 +255,11 @@ kit = toolkit = { case "button": input.onclick = function(event) { if (index == array.length-1) { + if (input.value == "login") { + form.onactions = function(msg) { + page.reload() + } + } page.Runs(page, form) return } diff --git a/usr/template/code/code.tmpl b/usr/template/code/code.tmpl index 4e7224ca..924f7883 100644 --- a/usr/template/code/code.tmpl +++ b/usr/template/code/code.tmpl @@ -1,88 +1,45 @@ {{define "head"}} - - - - - -{{option . "componet_name"}} - - - - - - -{{end}} + + + + {{range $index, $meta := option . "metas"}} + + {{end}} -{{define "clipboard"}} -
clipboard - - - -
+ {{option . "componet_name"|meta}} + + {{range $index, $lib := option . "styles"}} + + {{end}} + + + {{end}} - {{define "toolkit"}} -{{$bench_data := option . "bench_data"}} -
-
{{option .Meta "name"}}({{option .Meta "help"}})
-
+
+
{{option .Meta "name"}}({{option .Meta "help"}})
+
{{end}} - {{define "componet"}} -
- {{option .Meta "name"}}({{option .Meta "help"}}) - {{$msg := .}} - {{$form_type := option . "form_type"|meta}} +
+ {{option .Meta "name"}}({{option .Meta "help"}}) + {{$msg := .}} {{$form_type := option . "form_type"|meta}} -
+ - - {{range $index, $input := option . "inputs"}} -
- {{$type := index $input "type"}} - {{$value := index $input "value" | parse $msg}} + + {{range $index, $input := option . "inputs"}} +
{{$type := index $input "type"}} {{$value := index $input "value" | parse $msg}} {{if index $input "label"}} {{end}} @@ -93,11 +50,9 @@ {{else if eq $type "file"}} - {{else if eq $type "choice"}} - {{$default_value := index $input "value"}} + {{else if eq $type "choice"}} {{$default_value := index $input "value"}} - {{end}} -
- {{end}} -
- + {{end}}
+ {{end}} +
+ - {{if index .Meta "display_append"}} {{option .Meta "display_append"}} {{else}} - - {{$msg := .}} - {{range $field := append .}}{{end}} - {{range $line := table .}} - {{range $field := append $msg}}{{end}} - {{end}} -
{{$field}}
{{index $line $field|unescape}}
- {{end}} - {{if index .Meta "display_result"}} {{option .Meta "display_result"}} {{else}} -
{{result .Meta}}
- {{end}} - {{if index .Meta "display_div"}} {{option .Meta "display_div"}} {{else}} -
- {{end}} -
+ {{if index .Meta "display_append"}} {{option .Meta "display_append"}} {{else}} + {{$msg := .}} + {{range $field := append .}}{{end}} + {{range $line := table .}} + {{range $field := append $msg}}{{end}} + {{end}} +
{{$field}}
{{index $line $field|unescape}}
+ {{end}} + + {{if index .Meta "display_result"}} {{option .Meta "display_result"}} {{else}} +
{{result .Meta}}
+ {{end}} + + {{if index .Meta "display_div"}} {{option .Meta "display_div"}} {{else}} +
+ {{end}} +
{{end}} - {{define "mp"}} - - - + + + {{end}} - {{define "tail"}} - - - - - + {{range $index, $lib := option . "scripts"}} + + {{end}} + {{end}}