diff --git a/plugin/local/code/inner/favor.js b/plugin/local/code/inner/favor.js new file mode 100644 index 00000000..28238ce8 --- /dev/null +++ b/plugin/local/code/inner/favor.js @@ -0,0 +1,32 @@ +Volcanos("onimport", {help: "导入数据", _init: function(can, cb) { + can.onimport.toolkit(can, {index: "web.code.favor"}, function(sub) { + sub.run = function(event, cmds, cb) { var msg = can.request(event) + if (can.misc.runAction(can, msg, cmds, cb, kit.Dict( + code.INNER, function(cmds) { + can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), msg.Option(nfs.LINE)) + }, + ))) { return } + + can.run(event, can.misc.concat(can, [ctx.ACTION, code.FAVOR], cmds), function(msg) { var sub = msg._can + sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) { + if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) { + if (key == mdb.VALUE) { key = line.key } + } + if (key != ctx.ACTION) { value = sub.page.replace(sub, value, ice.PWD, "") } + + return {text: ["", html.TD], list: [{text: [value, html.DIV]}], onclick: function(event) { var target = event.target + if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onaction.change(event, sub, key, value) } + + if (target.tagName == "INPUT" && target.type == html.BUTTON) { var msg = sub.request(event, line, sub.Option()) + return sub.run(event, [ctx.ACTION, target.name], function(msg) { sub.run() }, true) + } + + line.line && can.onimport.tabview(can, line.path, line.file.replace(ice.PWD, ""), parseInt(line.line)) + }} + }, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length()) + }, true) + } + can.base.isFunc(cb) && cb() + }) +}}) + diff --git a/plugin/local/code/inner/search.js b/plugin/local/code/inner/search.js new file mode 100644 index 00000000..4d56ec93 --- /dev/null +++ b/plugin/local/code/inner/search.js @@ -0,0 +1,24 @@ +Volcanos("onimport", {help: "导入数据", _init: function(can, cb) { var history = [] + function show(msg, word) { if (!msg) { return } history.push(msg); var sub = msg._can; sub.Option("word", word||msg._word) + sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) { + return {text: ["", html.TD], list: [{text: [can.page.replace(can, value, ice.PWD, ""), html.DIV]}], onclick: function(event) { + line.line && can.onimport.tabview(can, can.Option(nfs.PATH), line.file.replace(ice.PWD, ""), parseInt(line.line)) + }} + }, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length()) + } + can.onengine.plugin(can, "can.code.inner.search", shy("搜索", {}, [ + {type: html.TEXT, name: "word", value: cli.MAIN}, {type: html.BUTTON, name: nfs.FIND}, {type: html.BUTTON, name: "last"}, + ], function(msg, cmds, cb) { can.misc.runAction(can, msg, cmds, cb, kit.Dict( + nfs.FIND, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text")) + can.run(msg._event, [ctx.ACTION, mdb.SEARCH, can.parse, cmds[0], can.Option(nfs.PATH)], function(msg) { var sub = msg._can + can.page.style(can, sub._output, html.MAX_HEIGHT, 200), show(msg, msg._word = cmds[0]) + can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click() + }, true) + }, + "last", function(cmds) { history.pop(), show(history.pop()) }, + )) })) +can.onimport.toolkit(can, {index: "can.code.inner.search"}, function(sub) { + can.ui.search = sub, can.base.isFunc(cb) && cb() +}) +}}) + diff --git a/plugin/local/code/inner/sess.js b/plugin/local/code/inner/sess.js new file mode 100644 index 00000000..ac754d1f --- /dev/null +++ b/plugin/local/code/inner/sess.js @@ -0,0 +1,42 @@ +Volcanos("onimport", {help: "导入数据", _init: function(can, cb) { + can.onimport.toolkit(can, {index: "web.code.sess"}, function(sub) { + sub.run = function(event, cmds, cb) { var msg = can.request(event) + if (can.misc.runAction(can, msg, cmds, cb, kit.Dict( + "save", function(cmds) { + can.run(event, [ctx.ACTION, ice.RUN, "web.code.sess"].concat([ctx.ACTION, mdb.CREATE, + "tool", can.core.Item(can.toolkit).join(ice.FS), + "tabs", can.core.Item(can.tabview).join(ice.FS), + ]), cb, true) + }, + "load", function(cmds) { + can.core.List(can.core.Split(msg.Option("tabs")), function(item) { + var ls = can.core.Split(item, ":"); can.onimport.tabview(can, ls[0], ls[1]) + }) + // var repos = can.base.trimSuffix(can.base.trimPrefix(can.Option(nfs.PATH), "usr/"), ice.PS) + can.run({}, [ctx.ACTION, ctx.COMMAND].concat(can.core.Split(msg.Option("tool")).reverse()), function(msg) { + can.core.Next(msg.Table(), function(item, next) { + item.args = can.base.getValid(item.args, []), can.onimport.toolkit(can, item, next) + }) + }, true) + }, + mdb.INPUTS, function(cmds) { + switch (cmds[0]) { + case mdb.TYPE: + msg.Push(cmds[0], "hi") + break + case mdb.NAME: + msg.Push(cmds[0], "hi") + break + case mdb.TEXT: + msg.Push(cmds[0], "hi") + break + } + can.base.isFunc(cb) && cb(msg) + }, + ))) { return } + can.run(event, [ctx.ACTION, ice.RUN, "web.code.sess"].concat(cmds), cb, true) + } + can.base.isFunc(cb) && cb() + }) +}}) +