From 57ba47402051a202913d74f2683fc9df2e818a45 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 13 Oct 2019 13:36:39 +0800 Subject: [PATCH] fix some --- src/contexts/cli/version.go | 2 +- src/contexts/nfs/nfs.go | 49 +++++++++++++++++++++++++++++++++++++ src/plugin/mind/index.shy | 2 +- usr/librarys/example.css | 1 - usr/librarys/example.js | 8 +++--- usr/librarys/toolkit.js | 2 +- 6 files changed, 55 insertions(+), 9 deletions(-) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index f69a21a6..844460b5 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -7,5 +7,5 @@ var version = struct { self int }{ []string{"2017-11-01 01:02:03", "2019-07-13 18:02:21"}, - `2019-10-09 20:58:29`, `centos`, 630, + `2019-10-13 12:01:52`, `mac`, 640, } diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index a3c67d10..84b652bd 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -1243,6 +1243,55 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", } return }}, + + "xls": {Name: "xls", Help: "表格", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + switch len(arg) { + case 0: + m.Cmdy("ssh.data", "show", "xls") + m.Meta["append"] = []string{"id", "title"} + + case 1: + var data map[int]map[int]string + what := m.Cmd("ssh.data", "show", "xls", arg[0], "format", "object").Append("content") + json.Unmarshal([]byte(what), &data) + + max, n := 0, 0 + for i, v := range data { + if i > n { + n = i + } + for i := range v { + if i > max { + max = i + } + } + } + m.Log("info", "m: %d n: %d", m, n) + + for k := 0; k < n+2; k++ { + for i := 0; i < max+2; i++ { + m.Push(kit.Format(k), kit.Format(data[k][i])) + } + } + + case 2: + m.Cmdy("ssh.data", "insert", "xls", "title", arg[0], "content", arg[1]) + + default: + data := map[int]map[int]string{} + what := m.Cmd("ssh.data", "show", "xls", arg[0], "format", "object").Append("content") + json.Unmarshal([]byte(what), &data) + + for i := 1; i < len(arg)-2; i += 3 { + if _, ok := data[kit.Int(arg[i])]; !ok { + data[kit.Int(arg[i])] = make(map[int]string) + } + data[kit.Int(arg[i])][kit.Int(arg[i+1])] = arg[i+2] + } + m.Cmdy("ssh.data", "update", "xls", arg[0], "content", kit.Format(data)) + } + return + }}, }, } diff --git a/src/plugin/mind/index.shy b/src/plugin/mind/index.shy index c2a83a4c..b207def3 100644 --- a/src/plugin/mind/index.shy +++ b/src/plugin/mind/index.shy @@ -1,4 +1,4 @@ -kit xls "表格" "index.js" "index.css" private \ +kit xls "表格" "index.js" "index.css" private "nfs.xls" \ text "" name title imports plugin_xls_id action auto \ text "" name content \ button "执行" \ diff --git a/usr/librarys/example.css b/usr/librarys/example.css index 967f38d3..e9442996 100644 --- a/usr/librarys/example.css +++ b/usr/librarys/example.css @@ -340,7 +340,6 @@ fieldset.Footer>div.output div.state { float:right; } fieldset.Footer>div.output div.state div { - margin-left:5px; float:right; } diff --git a/usr/librarys/example.js b/usr/librarys/example.js index aa9341e1..7343ce07 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -1038,7 +1038,7 @@ function Plugin(page, pane, field, inits, runs) { return Inputs(plugin, input, item, plugin.View(option, "input", input)[input.name], option).target }), Select: shy("选择控件", function(target, focus) {field.onclick(event) - page.input = target = target || option.querySelectorAll("input")[1] + page.plugin = field, page.input = target = target || option.querySelectorAll("input")[1] plugin.which.set(page.input.name) focus && page.input.focus() }), @@ -1056,9 +1056,7 @@ function Plugin(page, pane, field, inits, runs) { return JSON.stringify(field.Meta) }), Clone: shy("复制插件", function() { - return pane.Append("field", {text: plugin.Reveal()}, [], "", function(line, index, event, cmds, cbs) { - plugin.Run(event, cmds, cbs, true) - }).item.Plugin.Select() + return pane.Append("field", {text: plugin.Reveal(), init: meta.init, view: meta.view}, [], "").item.Plugin.Select() }), Move: function() { @@ -1337,7 +1335,7 @@ function Inputs(plugin, meta, item, target, option) { if (event.key == "Enter" && (event.ctrlKey || item.type == "text")) { // Event入口 2.1 input.which.set(target.value) != undefined && plugin.History(target.value, target) - input.Event(event, {}) && plugin.Check(target) + input.Event(event, {}) && plugin.Check(event, target) } }, onkeyup: function(event) { diff --git a/usr/librarys/toolkit.js b/usr/librarys/toolkit.js index 26c5cecd..028c552a 100644 --- a/usr/librarys/toolkit.js +++ b/usr/librarys/toolkit.js @@ -35,7 +35,7 @@ kit = toolkit = (function() {var kit = {__proto__: document, } return meta[type] = list, list.push({time: Date.now(), data: data})-1 }), - Debug: shy("调试断点", {why: true, msg: true}, function(key) { + Debug: shy("调试断点", {why: true, msg: true, config: false}, function(key) { if (arguments.callee.meta[key]) {debugger} }), Log: shy("输出日志", {hide: {"init": true, "wss": false}, call: [],