diff --git a/frame.js b/frame.js index 511f54b7..115c6189 100644 --- a/frame.js +++ b/frame.js @@ -241,7 +241,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, }) }); return node }, - field: function(can, type, item, target) { type = type||html.INPUT, item = item||{} + field: function(can, type, item, target) { type = type||html.PLUGIN, item = item||{} var name = (item.nick||item.name||"").split(ice.SP)[0] var title = !item.help || can.user.language(can) == "en"? name: name+"("+item.help.split(ice.SP)[0]+")" return can.page.Append(can, target||can._output, [{view: [can.base.join([type||"", item.name||"", item.pos||""]), html.FIELDSET], list: [ diff --git a/lib/core.js b/lib/core.js index 0e30b034..e98bcca9 100644 --- a/lib/core.js +++ b/lib/core.js @@ -159,6 +159,7 @@ Volcanos("core", {help: "数据结构", typeof cb == "function" && setTimeout(function() { loop(0) }, interval.interval||interval[0]) return timer }), + Timer300ms: function(cb) { this.Timer(300, cb) }, Delay: shy("延时器", function(list, interval, cb, cbs) { list = list || [] list.push(cb); this.Timer(interval, function() { var cb = list.pop(); list.length = 0 diff --git a/page/index.css b/page/index.css index d9765b75..9704739a 100644 --- a/page/index.css +++ b/page/index.css @@ -287,7 +287,9 @@ fieldset.plugin>div.status { border-top:1px solid darkcyan; } fieldset.story>legend { - display:none; + display:block; + padding:2px 20px; + letter-spacing:4px; } fieldset.story>div.status { border-top:1px solid darkcyan; diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index c5d4acb2..3a4029fa 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -40,9 +40,6 @@ fieldset.word>div.navmenu div.list { fieldset.word a { word-break:break-word; } -fieldset.word fieldset.story>legend { - display:block; -} fieldset.word ul.story[data-type=premenu] { cursor:pointer; } diff --git a/plugin/story/spide.js b/plugin/story/spide.js index 6ac4e9bd..e0d10976 100644 --- a/plugin/story/spide.js +++ b/plugin/story/spide.js @@ -2,20 +2,22 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg) if (msg.Option("branch")) { return can.onappend.table(can, msg) } - can.dir_root = msg.Option("dir_root") - can._tree = can.onimport._tree(can, msg.Table(), "path", "/") + can._tree = can.onimport._tree(can, msg.Table(), nfs.PATH, ice.PS) if (!can._tree[""]) { return } - can._tree[""].name = can.dir_root.split("/").slice(-2)[0] + can.dir_root = msg.Option(nfs.DIR_ROOT) + can._tree[""].name = can.dir_root.split(ice.PS).slice(-2)[0] can.size = 30, can.margin = 30 - can.onappend.plugin(can, {index: "web.wiki.draw", style: chat.OUTPUT}, function(sub) { + can.onappend.plugin(can, {type: chat.OUTPUT, index: "web.wiki.draw"}, function(sub) { sub.run = function(event, cmds, cb) { sub.Action("go", "run") can.base.isFunc(cb) && cb(sub.request()) - can.core.Timer(100, function() { can.draw = sub._outputs[0] + can.core.Timer300ms(function() { can.draw = sub._outputs[0] can.draw.onmotion.hidden(can.draw, can.draw.ui.project) can.draw.require(["/plugin/local/wiki/draw/path.js"], function() { - can.onaction[can.Action("view")](event, can) + var p = can.sup.view||can.Action("view"); + can.Action("view", p) + can.onaction[p](event, can, p) }) }) } @@ -28,7 +30,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, var last = array.slice(0, index).join(split) || "", name = array.slice(0, index+1).join(split) if (!value || node[name]) { return } - node[last] = node[last] || {name: last, meta: {}, list: []} + node[last] = node[last]||{name: last, meta: {}, list: []} node[last].list.push(node[name] = { name: value+(index==array.length-1? "": split), meta: item, list: [], last: last, @@ -39,34 +41,92 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, return node }, _height: function(can, tree) { if (!tree) { return 0 } - if (tree.list.length == 0) { return tree.height = 1 } - if (tree.hide) { return tree.height = 1 } + if (tree.list.length == 0 || tree.hide) { return tree.height = 1 } var height = 0; can.core.List(tree.list, function(item) { height += can.onimport._height(can, item) }) return tree.height = height }, -}, ["/plugin/story/spide.css"]) + _width: function(can, tree) { if (!tree) { return 0 } + if (tree.list.length == 0 || tree.hide) { + tree.view = can.draw.onimport.draw({}, can.draw, { + shape: "text", point: [{x: 0, y: 0}], style: { + "stroke-width": 1, "text-anchor": "middle", inner: tree.name, + }, + }) + return tree.width = tree.view.Val("textLength")+can.margin + } + + var width = 0; can.core.List(tree.list, function(item) { + width += can.onimport._width(can, item) + }) + return tree.width = width + }, +}, [""]) Volcanos("onaction", {help: "用户操作", list: ["编辑", ["view", "横向", "纵向"]], "编辑": function(event, can) { can.onmotion.toggle(can, can.draw._action) can.onmotion.toggle(can, can.draw._status) }, - "横向": function(event, can) { + "横向": function(event, can, button) { + can.sup.view = button can.onmotion.clear(can, can.draw.svg) - can.onimport._height(can, can._tree[""]) + can.draw.svg.Val(chat.HEIGHT, can._tree[""].height*can.size+2*can.margin) can.width = 0, can.onaction._draw(can, can._tree[""], can.margin, can.margin) can.draw.svg.Val(chat.WIDTH, can.width+can.margin) }, - "纵向": function(event, can) { + "纵向": function(event, can, button) { + can.sup.view = button + can.onimport._width(can, can._tree[""]) can.onmotion.clear(can, can.draw.svg) + + can.draw.svg.Val(chat.WIDTH, can._tree[""].width+2*can.margin) + can.draw.svg.Value("font-family", "monospace") + can.height = 0, can.onaction._draw_vertical(can, can._tree[""], can.margin, can.margin+can.size) + can.draw.svg.Val(chat.HEIGHT, can.height+can.margin) + }, + _draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y + var color = tree.meta&&tree.meta.color||cli.YELLOW + tree.view = can.draw.onimport.draw({}, can.draw, { + shape: "text", point: [ + {x: x+tree.width/2, y: y} + ], style: { + "stroke-width": 1, "stroke": color, + "fill": color, "text-anchor": "middle", inner: tree.name, + }, + }) + + can.core.ItemCB(can.ondetail, function(key, cb) { + tree.view[key] = function(event) { cb(event, can, tree) } + }) + tree.height = can.size + if (y+tree.height > can.height) { can.height = y+tree.height } + if (tree.hide) { return } + + function line(p0, p1) { + return "M "+p0.x+","+p0.y+" Q "+p0.x+","+(p0.y+(p1.y-p0.y)/3)+" "+(p0.x+p1.x)/2+","+(p0.y+p1.y)/2+" T "+p1.x+","+p1.y + } + + var offset = 0; can.core.List(tree.list, function(item) { + can.draw.onimport.draw({}, can.draw, { + shape: "path", point: [], style: { + "stroke-width": 1, "stroke": cli.CYAN, "fill": html.NONE, d: line( + {x: x+tree.width/2, y: y+tree.height-can.margin/2}, + {x: x+offset+item.width/2, y: y+tree.height+can.margin/2}, + ), + }, + }) + + can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin) + offset += item.width + }) }, _draw: function(can, tree, x, y) { tree.x = x, tree.y = y - var color = tree.meta&&tree.meta.color||"yellow" + var color = tree.meta&&tree.meta.color||cli.YELLOW tree.view = can.draw.onimport.draw({}, can.draw, { shape: "text", point: [ {x: x, y: y+tree.height*can.size/2} @@ -82,7 +142,6 @@ Volcanos("onaction", {help: "用户操作", list: ["编辑", ["view", "横向", can.core.ItemCB(can.ondetail, function(key, cb) { tree.view[key] = function(event) { cb(event, can, tree) } }) - if (tree.hide) { return } function line(p0, p1) { @@ -92,7 +151,7 @@ Volcanos("onaction", {help: "用户操作", list: ["编辑", ["view", "横向", var offset = 0; can.core.List(tree.list, function(item) { can.draw.onimport.draw({}, can.draw, { shape: "path", point: [], style: { - "stroke-width": 1, "stroke": "cyan", "fill": "none", d: line( + "stroke-width": 1, "stroke": cli.CYAN, "fill": html.NONE, d: line( {x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2}, {x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.size/2} ), @@ -111,18 +170,18 @@ Volcanos("ondetail", {help: "用户交互", list: [], {x: tree.x-can.margin/4, y: y-can.size/2}, {x: tree.x+tree.width+can.margin/8, y: y+can.size/2}, ], style: { - "stroke": "red", "stroke-width": 2, "fill": "none", + "stroke": cli.RED, "stroke-width": 2, "fill": html.NONE, }, }), event.stopPropagation(), event.preventDefault() }, onclick: function(event, can, tree) { - if (tree.name.endsWith("/") || tree.tags) { + if (tree.name.endsWith(ice.PS) || tree.tags) { tree.hide = !tree.hide, can.onaction[can.Action("view")](event, can) return } if (tree.name.endsWith(".go") || tree.name.endsWith(".c") || tree.name.endsWith(".h")) { - can.run(event, [can.Option("name"), tree.file], function(msg) { + can.run(event, [can.Option(kit.MDB_NAME), tree.file], function(msg) { msg.Table(function(value) { tree.tags = true tree.list.push({type: "tags", file: value.file, line: value.line, name: value.name, last: tree, list: []}) }) @@ -136,19 +195,19 @@ Volcanos("ondetail", {help: "用户交互", list: [], }, plugin: function(event, can, args) { - can.onappend.plugin(can, {type: chat.PLUGIN, index: "web.code.inner", style: chat.FLOAT, args: args, _action: [cli.CLOSE]}, function(sub) { + can.onappend.plugin(can, {type: chat.FLOAT, index: "web.code.inner", args: args, _action: [cli.CLOSE]}, function(sub) { sub.run = function(event, cmds, cb) { can.run(event, can.misc.Concat([ctx.ACTION, "inner"], cmds), function(msg) { msg.Option(ice.MSG_ACTION, cli.CLOSE) - can.search(event, ["Action.onexport.size"], function(msg, left, top, width, height) { left = left||0 + can.get("Action", "size", function(left, top, width, height) { left = left||0 var top = 120, margin = 20; if (can.user.isMobile) { margin = 0 if (can.user.isLandscape) { - sub.Conf(chat.HEIGHT, window.innerHeight+200), top = 24 + top = 24, sub.Conf(chat.HEIGHT, height-top) } else { - sub.Conf(chat.HEIGHT, window.innerHeight+140), top = 48 + top = 48, sub.Conf(chat.HEIGHT, height-top) } } else { - sub.Conf(chat.HEIGHT, height+120) + sub.Conf(chat.HEIGHT, height-top) } var layout = {position: "fixed", left: left+margin, top: top} @@ -158,7 +217,6 @@ Volcanos("ondetail", {help: "用户交互", list: [], can.base.isFunc(cb) && cb(msg) }) }, true) - } }) }, diff --git a/plugin/story/trend.js b/plugin/story/trend.js index 21103a78..661d1a10 100644 --- a/plugin/story/trend.js +++ b/plugin/story/trend.js @@ -7,11 +7,11 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.Action(chat.HEIGHT, msg.Option(chat.HEIGHT)||can.user.mod.isCmd? "max": can.user.isMobile&&can.user.isLandscape? "200": "400") can.Action("speed", parseInt(msg.Option("speed")||"100")) - can.onappend.plugin(can, {index: "web.wiki.draw", style: chat.OUTPUT}, function(sub) { + can.onappend.plugin(can, {type: chat.OUTPUT, index: "web.wiki.draw"}, function(sub) { sub.run = function(event, cmds, cb) { sub.Action("go", "run") can.base.isFunc(cb) && cb(sub.request()) - can.core.Timer(100, function() { can.draw = sub._outputs[0] + can.core.Timer300ms(function() { can.draw = sub._outputs[0] can.draw.onmotion.hidden(can.draw, can.draw.ui.project) can.onaction[can.Action("view")](event, can) }) diff --git a/proto.js b/proto.js index 75d37519..6272771c 100644 --- a/proto.js +++ b/proto.js @@ -17,7 +17,7 @@ var kit = { MDB_LIST: "list", } var ice = { - SP: " ", PS: "/", PT: ".", NL: "\n", + SP: " ", PS: "/", PT: ".", FS: ",", NL: "\n", POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg", OPT: "opt", TRUE: "true", @@ -56,6 +56,9 @@ var cli = { OPEN: "open", CLOSE: "close", START: "start", STOP: "stop", CLEAR: "clear", REFRESH: "refresh", + + YELLOW: "yellow", CYAN: "cyan", + RED: "red", } var web = { SHARE: "share", @@ -77,19 +80,17 @@ var ssh = { SCRIPT: "script", } var nfs = { - DIR: "dir", - PATH: "path", - FILE: "file", - LINE: "line", + PATH: "path", FILE: "file", LINE: "line", + DIR: "dir", CAT: "cat", + DIR_ROOT: "dir_root", } var tcp = { - HOST: "host", + HOST: "host", PORT: "port", } var code = { WEBPACK: "webpack", - INNER: "inner", - FAVOR: "favor", + VIMER: "vimer", INNER: "inner", FAVOR: "favor", } var wiki = { TITLE: "title", BRIEF: "brief", REFER: "refer", SPARK: "spark", @@ -97,34 +98,31 @@ var wiki = { FIELD: "field", SHELL: "shell", LOCAL: "local", PARSE: "parse", } var chat = { - LIB: "lib", PAGE: "page", PANEL: "panel", PLUGIN: "plugin", OUTPUT: "output", - STORY: "story", CARTE: "carte", INPUT: "input", FLOAT: "float", - HEAD: "head", AUTO: "auto", LEFT: "left", MAIN: "main", FOOT: "foot", - SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", - + LIB: "lib", PAGE: "page", PANEL: "panel", PLUGIN: "plugin", STORY: "story", + CARTE: "carte", INPUT: "input", FLOAT: "float", OUTPUT: "output", + HEAD: "head", LEFT: "left", MAIN: "main", AUTO: "auto", FOOT: "foot", LAYOUT: "layout", PROJECT: "project", CONTENT: "content", DISPLAY: "display", PROFILE: "profile", - - PUBLIC: "public", PROTECTED: "protected", PRIVATE: "private", - USER: "user", TOOL: "tool", NODE: "node", + SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", HEADER: "header", FOOTER: "footer", ONMAIN: "onmain", ONSIZE: "onsize", ONLOGIN: "onlogin", ONSEARCH: "onsearch", - RIVER: "river", STORM: "storm", FIELD: "field", TOAST: "toast", - TOPIC: "topic", BLACK: "black", WHITE: "white", PRINT: "print", + TITLE: "title", TOPIC: "topic", BLACK: "black", WHITE: "white", PRINT: "print", + SHARE: "share", RIVER: "river", STORM: "storm", FIELD: "field", TOAST: "toast", + PUBLIC: "public", PROTECTED: "protected", PRIVATE: "private", + USER: "user", TOOL: "tool", NODE: "node", + + AGENT: "agent", CHECK: "check", GRANT: "grant", + STATE: "state", MENUS: "menus", TRANS: "trans", - AGENT: "agent", CHECK: "check", GRANT: "grant", SHARE: "share", - TITLE: "title", STATE: "state", MENUS: "menus", TRANS: "trans", SSO: "sso", CMD_MARGIN: 53, } var team = { - TASK: "task", - PLAN: "plan", + TASK: "task", PLAN: "plan", } var mall = { - ASSET: "asset", - SALARY: "salary", + ASSET: "asset", SALARY: "salary", } var html = { @@ -133,15 +131,9 @@ var html = { INPUT: "input", INPUT_ARGS: ".args", TEXT: "text", TEXTAREA: "textarea", SELECT: "select", BUTTON: "button", SPACE: "space", BLOCK: "block", NONE: "none", - BR: "br", - TABLE: "table", TR: "tr", TH: "th", TD: "td", - DIV: "div", - IMG: "img", - SPAN: "span", - CODE: "code", - LABEL: "label", - VIDEO: "video", + TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br", + DIV: "div", IMG: "img", CODE: "code", SPAN: "span", LABEL: "label", VIDEO: "video", FORM: "form", FILE: "file", LIST: "list", ITEM: "item", MENU: "menu", @@ -218,7 +210,13 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args: set: function(name, key, value) { var msg = can.request({}); msg.Option(key, value) return can.search(msg._event, [can.core.Keys(name, "onimport", key)]) }, - get: function(name, key, cb) { return can.search({}, [can.core.Keys(name, "onexport", key)], cb) }, + get: function(name, key, cb) { + if (can.user.mod.isCmd && name == "Action" && key == "size") { + var msg = can.request({}, {left: 0, top: 0, width: window.innerWidth, height: window.innerHeight}) + return can.core.CallFunc(cb, {msg: msg}) + } + return can.search({}, [can.core.Keys(name, "onexport", key)], cb) + }, search: function(event, cmds, cb) { return can.run && can.run(event, ["_search"].concat(cmds), cb, true) }, Conf: function(key, value) { return can.core.Value(can._conf, key, value) }, _conf: {},