From 91ff63791d6c9b78a678d177158a66a624385bc9 Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 4 May 2020 08:10:51 +0800 Subject: [PATCH] opt order --- demo/favicon.ico | 1 - frame.js | 23 +++-- {old/page => history}/chat.js | 0 {old => history}/frame_old.js | 2 +- {old/page => history}/index.html | 2 +- {old/page => history}/index.js | 3 +- {demo => history}/lib | 0 {old => history}/pane/Action.css | 0 {old => history}/pane/Action.js | 0 {old => history}/pane/Footer.css | 0 {old => history}/pane/Footer.js | 0 {old => history}/pane/Header.css | 0 {old => history}/pane/Header.js | 0 {old => history}/pane/Ocean.css | 0 {old => history}/pane/Ocean.js | 0 {old => history}/pane/River.css | 0 {old => history}/pane/River.js | 0 {old => history}/pane/Source.css | 0 {old => history}/pane/Source.js | 0 {old => history}/pane/Steam.css | 0 {old => history}/pane/Steam.js | 0 {old => history}/pane/Storm.css | 0 {old => history}/pane/Storm.js | 0 {old => history}/pane/Target.css | 0 {old => history}/pane/Target.js | 0 {old => history}/pane/float/Carte.css | 0 {old => history}/pane/float/Carte.js | 0 {old => history}/pane/float/Debug.css | 0 {old => history}/pane/float/Debug.js | 0 {old => history}/pane/float/Favor.css | 0 {old => history}/pane/float/Favor.js | 0 {old => history}/pane/float/Login.css | 0 {old => history}/pane/float/Login.js | 0 {old => history}/pane/float/Toast.css | 0 {old => history}/pane/float/Toast.js | 0 {old => history}/pane/float/Tutor.css | 0 {old => history}/pane/float/Tutor.js | 0 {old => history}/plugin/chrome/chrome.html | 0 {old => history}/plugin/chrome/chrome.js | 0 {old => history}/plugin/chrome/config.js | 0 {old => history}/plugin/chrome/popup.html | 0 {old => history}/plugin/chrome/popup.js | 0 {old => history}/plugin/inner.js | 0 {old => history}/plugin/input.js | 0 {old => history}/plugin/input/city.js | 0 {old => history}/plugin/input/date.js | 0 {old => history}/plugin/input/key.js | 0 {old => history}/plugin/input/province.js | 0 {old => history}/plugin/input/upload.js | 0 {old => history}/plugin/local/mall/input.js | 0 {old => history}/plugin/local/team/plan.css | 0 {old => history}/plugin/local/team/plan.js | 0 {old => history}/plugin/local/wiki/data.js | 0 {old => history}/plugin/local/wiki/draw.css | 0 {old => history}/plugin/local/wiki/draw.js | 0 .../plugin/local/wiki/draw/heart.js | 0 {old => history}/plugin/local/wiki/feel.js | 0 {old => history}/plugin/local/wiki/walk.js | 0 {old => history}/plugin/local/wiki/word.css | 0 {old => history}/plugin/local/wiki/word.js | 0 {old => history}/plugin/state.js | 0 {old => history}/plugin/story/trend.js | 0 {old => history}/plugin/table.js | 0 {old => history}/proto_old.js | 0 {old/page => history}/share.html | 0 {old/page => history}/share.js | 0 {old => history}/style_old.css | 0 {old/page => history}/topic/black.css | 0 {old/page => history}/topic/gray.css | 0 {old/page => history}/topic/miss.css | 0 {old/page => history}/topic/miss.svg | 0 index.js | 11 ++- lib/misc.js | 7 +- old/page/demo.html | 14 --- old/page/demo.js | 9 -- old/page/frame_old.js | 1 - old/page/lib | 1 - old/page/open.sh | 6 -- old/page/page | 1 - old/page/pane | 1 - old/page/plugin | 1 - old/page/proto_old.js | 1 - old/page/style_old.css | 1 - old/plugin/github.com/shylinux/echarts | 1 - pane/Action.css | 25 ++++-- pane/Action.js | 5 +- pane/Header.js | 17 ++-- pane/River.css | 2 + pane/River.js | 5 +- pane/Storm.css | 2 + pane/Storm.js | 5 +- plugin/input/city.js | 13 +++ plugin/input/date.js | 73 +++++++++++++++ plugin/input/key.js | 12 +++ plugin/input/province.js | 18 ++++ plugin/input/upload.js | 38 ++++++++ plugin/table.js | 11 ++- proto.js | 7 +- publish/order.js | 88 +++++++++++-------- style.css | 3 + 100 files changed, 299 insertions(+), 111 deletions(-) delete mode 120000 demo/favicon.ico rename {old/page => history}/chat.js (100%) rename {old => history}/frame_old.js (99%) rename {old/page => history}/index.html (90%) rename {old/page => history}/index.js (98%) rename {demo => history}/lib (100%) rename {old => history}/pane/Action.css (100%) rename {old => history}/pane/Action.js (100%) rename {old => history}/pane/Footer.css (100%) rename {old => history}/pane/Footer.js (100%) rename {old => history}/pane/Header.css (100%) rename {old => history}/pane/Header.js (100%) rename {old => history}/pane/Ocean.css (100%) rename {old => history}/pane/Ocean.js (100%) rename {old => history}/pane/River.css (100%) rename {old => history}/pane/River.js (100%) rename {old => history}/pane/Source.css (100%) rename {old => history}/pane/Source.js (100%) rename {old => history}/pane/Steam.css (100%) rename {old => history}/pane/Steam.js (100%) rename {old => history}/pane/Storm.css (100%) rename {old => history}/pane/Storm.js (100%) rename {old => history}/pane/Target.css (100%) rename {old => history}/pane/Target.js (100%) rename {old => history}/pane/float/Carte.css (100%) rename {old => history}/pane/float/Carte.js (100%) rename {old => history}/pane/float/Debug.css (100%) rename {old => history}/pane/float/Debug.js (100%) rename {old => history}/pane/float/Favor.css (100%) rename {old => history}/pane/float/Favor.js (100%) rename {old => history}/pane/float/Login.css (100%) rename {old => history}/pane/float/Login.js (100%) rename {old => history}/pane/float/Toast.css (100%) rename {old => history}/pane/float/Toast.js (100%) rename {old => history}/pane/float/Tutor.css (100%) rename {old => history}/pane/float/Tutor.js (100%) rename {old => history}/plugin/chrome/chrome.html (100%) rename {old => history}/plugin/chrome/chrome.js (100%) rename {old => history}/plugin/chrome/config.js (100%) rename {old => history}/plugin/chrome/popup.html (100%) rename {old => history}/plugin/chrome/popup.js (100%) rename {old => history}/plugin/inner.js (100%) rename {old => history}/plugin/input.js (100%) rename {old => history}/plugin/input/city.js (100%) rename {old => history}/plugin/input/date.js (100%) rename {old => history}/plugin/input/key.js (100%) rename {old => history}/plugin/input/province.js (100%) rename {old => history}/plugin/input/upload.js (100%) rename {old => history}/plugin/local/mall/input.js (100%) rename {old => history}/plugin/local/team/plan.css (100%) rename {old => history}/plugin/local/team/plan.js (100%) rename {old => history}/plugin/local/wiki/data.js (100%) rename {old => history}/plugin/local/wiki/draw.css (100%) rename {old => history}/plugin/local/wiki/draw.js (100%) rename {old => history}/plugin/local/wiki/draw/heart.js (100%) rename {old => history}/plugin/local/wiki/feel.js (100%) rename {old => history}/plugin/local/wiki/walk.js (100%) rename {old => history}/plugin/local/wiki/word.css (100%) rename {old => history}/plugin/local/wiki/word.js (100%) rename {old => history}/plugin/state.js (100%) rename {old => history}/plugin/story/trend.js (100%) rename {old => history}/plugin/table.js (100%) rename {old => history}/proto_old.js (100%) rename {old/page => history}/share.html (100%) rename {old/page => history}/share.js (100%) rename {old => history}/style_old.css (100%) rename {old/page => history}/topic/black.css (100%) rename {old/page => history}/topic/gray.css (100%) rename {old/page => history}/topic/miss.css (100%) rename {old/page => history}/topic/miss.svg (100%) delete mode 100644 old/page/demo.html delete mode 100644 old/page/demo.js delete mode 120000 old/page/frame_old.js delete mode 120000 old/page/lib delete mode 100644 old/page/open.sh delete mode 120000 old/page/page delete mode 120000 old/page/pane delete mode 120000 old/page/plugin delete mode 120000 old/page/proto_old.js delete mode 120000 old/page/style_old.css delete mode 160000 old/plugin/github.com/shylinux/echarts create mode 100644 plugin/input/city.js create mode 100644 plugin/input/date.js create mode 100644 plugin/input/key.js create mode 100644 plugin/input/province.js create mode 100644 plugin/input/upload.js diff --git a/demo/favicon.ico b/demo/favicon.ico deleted file mode 120000 index cf3a36c6..00000000 --- a/demo/favicon.ico +++ /dev/null @@ -1 +0,0 @@ -../favicon.ico \ No newline at end of file diff --git a/frame.js b/frame.js index 3a992d85..fe1586d0 100644 --- a/frame.js +++ b/frame.js @@ -3,7 +3,8 @@ Volcanos("onimport", { if (Volcanos.meta.follow[can._root]) { debugger } can.core.Next(meta.panes, function(item, next) { can.onappend._init(can, item, Config.libs.concat(item.list), function(pane) { - pane.run = function(event, cmds, cb) { var msg = pane.request(event); + // 插件回调 + pane.Conf(item), pane.run = function(event, cmds, cb) { var msg = pane.request(event); if (can.onaction[cmds[0]]) { can.onaction[cmds[0]](event, can, msg, pane, cmds, cb); } else { @@ -31,11 +32,15 @@ Volcanos("onaction", { }, sub._target) }, remote: function(event, can, msg, pane, cmds, cb) { + if (Volcanos.meta.follow[can._root]) { debugger } if (can.onengine && can.onengine.remote(event, can, msg, pane, cmds, cb)) { return } + if (location.protocol == "file:") { + typeof cb == "function" && cb(msg) + return + } - if (Volcanos.meta.follow[can._root]) { debugger } Volcanos.meta.debug[can._root] && console.log(can._root, pane._name, "remote", msg._name, "detail", cmds); can.misc.Run(event, can, {names: pane._name}, cmds, function(msg) { typeof cb == "function" && cb(msg); @@ -44,7 +49,7 @@ Volcanos("onaction", { }) Volcanos("onappend", { _init: function(can, meta, list, cb, target) { - var field = can.onappend.field(can, target, meta.type, meta); + var field = can.onappend.field(can, target, meta.type||"plugin", meta); var option = can.page.Select(can, field, "form.option")[0]; var action = can.page.Select(can, field, "div.action")[0]; var output = can.page.Select(can, field, "div.output")[0]; @@ -67,7 +72,7 @@ Volcanos("onappend", { input.onimport._init(input, input.Conf(item), item.list||[], function() { }, input._target); - // 事件回调 + // 控件回调 input.run = function(event, cmds, cb, silent) { switch (item.name) { case "返回": @@ -96,6 +101,11 @@ Volcanos("onappend", { }, Config.libs.concat([display]), function(table) { table.onimport._init(table, msg, msg.append||[], function() { }, output) + + // 组件回调 + table.run = function(event, cmds, cb, silent) { + input.run(event, cmds, cb, silent) + } }) }, silent) } @@ -138,7 +148,7 @@ Volcanos("onappend", { item.action = item.action || item.value || ""; item.cb = item.cb || item.value || ""; - var input = {type: "input", name: item.name, data: item}; + var input = {type: "input", name: item.name, data: item, dataset: {}}; switch (item.type = item.type || item._type || item._input || "text") { case "upfile": item.type = "file"; break // case "button": item.value = item.value || item.name || "查看"; break @@ -165,6 +175,7 @@ Volcanos("onappend", { break } + item.value == "auto" && (item.value = "", input.dataset.action = "auto") var target = can.page.Append(can, option, [{view: ["item "+item.type], list: [item.position && {text: item.name+": "}, input]}]).last item.figure && item.figure.indexOf("@") == 0 && (item.figure = item.figure.slice(1)) && can.require(["plugin/input/"+item.figure], function() { target.type != "button" && (target.value = "") @@ -198,7 +209,7 @@ Volcanos("onlayout", { can.page.Select(can, field, "div.output", function(output) { var border = output.offsetHeight - output.clientHeight; - can.page.Modify(can, field, { style: { + can.page.Modify(can, output, { style: { height: height-border*2-20+"px", } }) }) diff --git a/old/page/chat.js b/history/chat.js similarity index 100% rename from old/page/chat.js rename to history/chat.js diff --git a/old/frame_old.js b/history/frame_old.js similarity index 99% rename from old/frame_old.js rename to history/frame_old.js index a528f3de..33f98189 100644 --- a/old/frame_old.js +++ b/history/frame_old.js @@ -33,7 +33,7 @@ var can = Volcanos("chat", { }, run: function(event, option, cmds, cb) {can.misc.Run(event, page, option, cmds, cb)}, - }, Config.libs.concat(["page/"+name, "page/topic/"+topic+".css"]), function(page) { + }, Config.libs.concat([name, "topic/"+topic+".css"]), function(page) { // 加载配置 page.onimport._init && page.onimport._init(page, page.Conf(conf), body) diff --git a/old/page/index.html b/history/index.html similarity index 90% rename from old/page/index.html rename to history/index.html index a9d7642a..28bfeeb9 100644 --- a/old/page/index.html +++ b/history/index.html @@ -8,7 +8,7 @@ - + diff --git a/old/page/index.js b/history/index.js similarity index 98% rename from old/page/index.js rename to history/index.js index dde63d82..45b191a3 100644 --- a/old/page/index.js +++ b/history/index.js @@ -1,7 +1,6 @@ var Config = {iceberg: "/chat/", volcano: "", libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"], - main: "chat", list: [ - "page/chat", + main: "chat", list: ["chat", "pane/float/Toast", "pane/float/Carte", "pane/float/Tutor", "pane/float/Debug", "pane/float/Login", "pane/float/Favor", diff --git a/demo/lib b/history/lib similarity index 100% rename from demo/lib rename to history/lib diff --git a/old/pane/Action.css b/history/pane/Action.css similarity index 100% rename from old/pane/Action.css rename to history/pane/Action.css diff --git a/old/pane/Action.js b/history/pane/Action.js similarity index 100% rename from old/pane/Action.js rename to history/pane/Action.js diff --git a/old/pane/Footer.css b/history/pane/Footer.css similarity index 100% rename from old/pane/Footer.css rename to history/pane/Footer.css diff --git a/old/pane/Footer.js b/history/pane/Footer.js similarity index 100% rename from old/pane/Footer.js rename to history/pane/Footer.js diff --git a/old/pane/Header.css b/history/pane/Header.css similarity index 100% rename from old/pane/Header.css rename to history/pane/Header.css diff --git a/old/pane/Header.js b/history/pane/Header.js similarity index 100% rename from old/pane/Header.js rename to history/pane/Header.js diff --git a/old/pane/Ocean.css b/history/pane/Ocean.css similarity index 100% rename from old/pane/Ocean.css rename to history/pane/Ocean.css diff --git a/old/pane/Ocean.js b/history/pane/Ocean.js similarity index 100% rename from old/pane/Ocean.js rename to history/pane/Ocean.js diff --git a/old/pane/River.css b/history/pane/River.css similarity index 100% rename from old/pane/River.css rename to history/pane/River.css diff --git a/old/pane/River.js b/history/pane/River.js similarity index 100% rename from old/pane/River.js rename to history/pane/River.js diff --git a/old/pane/Source.css b/history/pane/Source.css similarity index 100% rename from old/pane/Source.css rename to history/pane/Source.css diff --git a/old/pane/Source.js b/history/pane/Source.js similarity index 100% rename from old/pane/Source.js rename to history/pane/Source.js diff --git a/old/pane/Steam.css b/history/pane/Steam.css similarity index 100% rename from old/pane/Steam.css rename to history/pane/Steam.css diff --git a/old/pane/Steam.js b/history/pane/Steam.js similarity index 100% rename from old/pane/Steam.js rename to history/pane/Steam.js diff --git a/old/pane/Storm.css b/history/pane/Storm.css similarity index 100% rename from old/pane/Storm.css rename to history/pane/Storm.css diff --git a/old/pane/Storm.js b/history/pane/Storm.js similarity index 100% rename from old/pane/Storm.js rename to history/pane/Storm.js diff --git a/old/pane/Target.css b/history/pane/Target.css similarity index 100% rename from old/pane/Target.css rename to history/pane/Target.css diff --git a/old/pane/Target.js b/history/pane/Target.js similarity index 100% rename from old/pane/Target.js rename to history/pane/Target.js diff --git a/old/pane/float/Carte.css b/history/pane/float/Carte.css similarity index 100% rename from old/pane/float/Carte.css rename to history/pane/float/Carte.css diff --git a/old/pane/float/Carte.js b/history/pane/float/Carte.js similarity index 100% rename from old/pane/float/Carte.js rename to history/pane/float/Carte.js diff --git a/old/pane/float/Debug.css b/history/pane/float/Debug.css similarity index 100% rename from old/pane/float/Debug.css rename to history/pane/float/Debug.css diff --git a/old/pane/float/Debug.js b/history/pane/float/Debug.js similarity index 100% rename from old/pane/float/Debug.js rename to history/pane/float/Debug.js diff --git a/old/pane/float/Favor.css b/history/pane/float/Favor.css similarity index 100% rename from old/pane/float/Favor.css rename to history/pane/float/Favor.css diff --git a/old/pane/float/Favor.js b/history/pane/float/Favor.js similarity index 100% rename from old/pane/float/Favor.js rename to history/pane/float/Favor.js diff --git a/old/pane/float/Login.css b/history/pane/float/Login.css similarity index 100% rename from old/pane/float/Login.css rename to history/pane/float/Login.css diff --git a/old/pane/float/Login.js b/history/pane/float/Login.js similarity index 100% rename from old/pane/float/Login.js rename to history/pane/float/Login.js diff --git a/old/pane/float/Toast.css b/history/pane/float/Toast.css similarity index 100% rename from old/pane/float/Toast.css rename to history/pane/float/Toast.css diff --git a/old/pane/float/Toast.js b/history/pane/float/Toast.js similarity index 100% rename from old/pane/float/Toast.js rename to history/pane/float/Toast.js diff --git a/old/pane/float/Tutor.css b/history/pane/float/Tutor.css similarity index 100% rename from old/pane/float/Tutor.css rename to history/pane/float/Tutor.css diff --git a/old/pane/float/Tutor.js b/history/pane/float/Tutor.js similarity index 100% rename from old/pane/float/Tutor.js rename to history/pane/float/Tutor.js diff --git a/old/plugin/chrome/chrome.html b/history/plugin/chrome/chrome.html similarity index 100% rename from old/plugin/chrome/chrome.html rename to history/plugin/chrome/chrome.html diff --git a/old/plugin/chrome/chrome.js b/history/plugin/chrome/chrome.js similarity index 100% rename from old/plugin/chrome/chrome.js rename to history/plugin/chrome/chrome.js diff --git a/old/plugin/chrome/config.js b/history/plugin/chrome/config.js similarity index 100% rename from old/plugin/chrome/config.js rename to history/plugin/chrome/config.js diff --git a/old/plugin/chrome/popup.html b/history/plugin/chrome/popup.html similarity index 100% rename from old/plugin/chrome/popup.html rename to history/plugin/chrome/popup.html diff --git a/old/plugin/chrome/popup.js b/history/plugin/chrome/popup.js similarity index 100% rename from old/plugin/chrome/popup.js rename to history/plugin/chrome/popup.js diff --git a/old/plugin/inner.js b/history/plugin/inner.js similarity index 100% rename from old/plugin/inner.js rename to history/plugin/inner.js diff --git a/old/plugin/input.js b/history/plugin/input.js similarity index 100% rename from old/plugin/input.js rename to history/plugin/input.js diff --git a/old/plugin/input/city.js b/history/plugin/input/city.js similarity index 100% rename from old/plugin/input/city.js rename to history/plugin/input/city.js diff --git a/old/plugin/input/date.js b/history/plugin/input/date.js similarity index 100% rename from old/plugin/input/date.js rename to history/plugin/input/date.js diff --git a/old/plugin/input/key.js b/history/plugin/input/key.js similarity index 100% rename from old/plugin/input/key.js rename to history/plugin/input/key.js diff --git a/old/plugin/input/province.js b/history/plugin/input/province.js similarity index 100% rename from old/plugin/input/province.js rename to history/plugin/input/province.js diff --git a/old/plugin/input/upload.js b/history/plugin/input/upload.js similarity index 100% rename from old/plugin/input/upload.js rename to history/plugin/input/upload.js diff --git a/old/plugin/local/mall/input.js b/history/plugin/local/mall/input.js similarity index 100% rename from old/plugin/local/mall/input.js rename to history/plugin/local/mall/input.js diff --git a/old/plugin/local/team/plan.css b/history/plugin/local/team/plan.css similarity index 100% rename from old/plugin/local/team/plan.css rename to history/plugin/local/team/plan.css diff --git a/old/plugin/local/team/plan.js b/history/plugin/local/team/plan.js similarity index 100% rename from old/plugin/local/team/plan.js rename to history/plugin/local/team/plan.js diff --git a/old/plugin/local/wiki/data.js b/history/plugin/local/wiki/data.js similarity index 100% rename from old/plugin/local/wiki/data.js rename to history/plugin/local/wiki/data.js diff --git a/old/plugin/local/wiki/draw.css b/history/plugin/local/wiki/draw.css similarity index 100% rename from old/plugin/local/wiki/draw.css rename to history/plugin/local/wiki/draw.css diff --git a/old/plugin/local/wiki/draw.js b/history/plugin/local/wiki/draw.js similarity index 100% rename from old/plugin/local/wiki/draw.js rename to history/plugin/local/wiki/draw.js diff --git a/old/plugin/local/wiki/draw/heart.js b/history/plugin/local/wiki/draw/heart.js similarity index 100% rename from old/plugin/local/wiki/draw/heart.js rename to history/plugin/local/wiki/draw/heart.js diff --git a/old/plugin/local/wiki/feel.js b/history/plugin/local/wiki/feel.js similarity index 100% rename from old/plugin/local/wiki/feel.js rename to history/plugin/local/wiki/feel.js diff --git a/old/plugin/local/wiki/walk.js b/history/plugin/local/wiki/walk.js similarity index 100% rename from old/plugin/local/wiki/walk.js rename to history/plugin/local/wiki/walk.js diff --git a/old/plugin/local/wiki/word.css b/history/plugin/local/wiki/word.css similarity index 100% rename from old/plugin/local/wiki/word.css rename to history/plugin/local/wiki/word.css diff --git a/old/plugin/local/wiki/word.js b/history/plugin/local/wiki/word.js similarity index 100% rename from old/plugin/local/wiki/word.js rename to history/plugin/local/wiki/word.js diff --git a/old/plugin/state.js b/history/plugin/state.js similarity index 100% rename from old/plugin/state.js rename to history/plugin/state.js diff --git a/old/plugin/story/trend.js b/history/plugin/story/trend.js similarity index 100% rename from old/plugin/story/trend.js rename to history/plugin/story/trend.js diff --git a/old/plugin/table.js b/history/plugin/table.js similarity index 100% rename from old/plugin/table.js rename to history/plugin/table.js diff --git a/old/proto_old.js b/history/proto_old.js similarity index 100% rename from old/proto_old.js rename to history/proto_old.js diff --git a/old/page/share.html b/history/share.html similarity index 100% rename from old/page/share.html rename to history/share.html diff --git a/old/page/share.js b/history/share.js similarity index 100% rename from old/page/share.js rename to history/share.js diff --git a/old/style_old.css b/history/style_old.css similarity index 100% rename from old/style_old.css rename to history/style_old.css diff --git a/old/page/topic/black.css b/history/topic/black.css similarity index 100% rename from old/page/topic/black.css rename to history/topic/black.css diff --git a/old/page/topic/gray.css b/history/topic/gray.css similarity index 100% rename from old/page/topic/gray.css rename to history/topic/gray.css diff --git a/old/page/topic/miss.css b/history/topic/miss.css similarity index 100% rename from old/page/topic/miss.css rename to history/topic/miss.css diff --git a/old/page/topic/miss.svg b/history/topic/miss.svg similarity index 100% rename from old/page/topic/miss.svg rename to history/topic/miss.svg diff --git a/index.js b/index.js index ec83c1be..10157c9f 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,19 @@ var Config = {name: "demo", volcano: "frame.js", iceberg: "/chat/", intshell: "plug.sh", libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"], panes: [ - {type: "pane", name: "Header", help: "标题栏", pos: "head", list: ["pane/Header.js", "pane/Header.css"], state: ["time"]}, + {type: "pane", name: "Header", help: "标题栏", pos: "head", list: ["pane/Header.js", "pane/Header.css"], state: [ + "time", "username", + ]}, {type: "pane", name: "River", help: "群聊组", pos: "left", list: ["pane/River.js", "pane/River.css"]}, {type: "pane", name: "Storm", help: "应用流", pos: "right", list: ["pane/Storm.js", "pane/Storm.css"]}, {type: "pane", name: "Action", help: "工作台", pos: "middle", list: ["pane/Action.js", "pane/Action.css"]}, {type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["pane/Footer.js", "pane/Footer.css"]}, ], main: {name: "Header", engine: "remote", list: []}, - list: ["plugin/state.js", "plugin/input.js", "plugin/table.js"], + list: ["plugin/state.js", "plugin/input.js", "plugin/table.js", + "plugin/input/key.js", + "plugin/input/date.js", + "plugin/input/upload.js", + "plugin/input/province.js", + ], } var Preload = Config.libs; Config.panes.forEach(function(pane) { diff --git a/lib/misc.js b/lib/misc.js index 257ff778..8b990f27 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -44,7 +44,12 @@ Volcanos("misc", {help: "工具模块", ++arguments.callee.meta.order xhr.setRequestHeader("Accept", "application/json") xhr.responseType = msg.responseType || "" - xhr.send(data) + try { + xhr.send(data) + } catch(e) { + console.error(e) + cb == "function" && cb(msg); + } msg._xhr = xhr }), Run: shy("请求后端", {order: 0}, function(event, can, dataset, cmd, cb) { diff --git a/old/page/demo.html b/old/page/demo.html deleted file mode 100644 index 6edff827..00000000 --- a/old/page/demo.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - volcanos - - - - - - - - - diff --git a/old/page/demo.js b/old/page/demo.js deleted file mode 100644 index 73c7b330..00000000 --- a/old/page/demo.js +++ /dev/null @@ -1,9 +0,0 @@ -Volcanos("demo", {head: document.head, body: document.body, target: document.body, - -}, ["lib/core.js", "lib/page.js", "plugin/table.js", "plugin/local/team/plan.js", "plugin/local/team/plan.css"], function(can) { - can.target.style.background = "black" - console.log(can) - can.page.AppendField(can, can.target, "item", {name: "demo", help: "demo", inputs: [ - {_input: "text", name: "help"}, - ]}) -}) diff --git a/old/page/frame_old.js b/old/page/frame_old.js deleted file mode 120000 index f8b9cc53..00000000 --- a/old/page/frame_old.js +++ /dev/null @@ -1 +0,0 @@ -../frame_old.js \ No newline at end of file diff --git a/old/page/lib b/old/page/lib deleted file mode 120000 index 58677ddb..00000000 --- a/old/page/lib +++ /dev/null @@ -1 +0,0 @@ -../../lib \ No newline at end of file diff --git a/old/page/open.sh b/old/page/open.sh deleted file mode 100644 index f4564b47..00000000 --- a/old/page/open.sh +++ /dev/null @@ -1,6 +0,0 @@ - -ish_ctx_dev_can_pwd=$PWD - -ish_ctx_dev_can() { - open $ish_ctx_dev_can_pwd/$1.html -} diff --git a/old/page/page b/old/page/page deleted file mode 120000 index ee335c20..00000000 --- a/old/page/page +++ /dev/null @@ -1 +0,0 @@ -../page \ No newline at end of file diff --git a/old/page/pane b/old/page/pane deleted file mode 120000 index cabd17f1..00000000 --- a/old/page/pane +++ /dev/null @@ -1 +0,0 @@ -../pane \ No newline at end of file diff --git a/old/page/plugin b/old/page/plugin deleted file mode 120000 index 041aad1a..00000000 --- a/old/page/plugin +++ /dev/null @@ -1 +0,0 @@ -../plugin \ No newline at end of file diff --git a/old/page/proto_old.js b/old/page/proto_old.js deleted file mode 120000 index 1e3a533c..00000000 --- a/old/page/proto_old.js +++ /dev/null @@ -1 +0,0 @@ -../proto_old.js \ No newline at end of file diff --git a/old/page/style_old.css b/old/page/style_old.css deleted file mode 120000 index 81f38473..00000000 --- a/old/page/style_old.css +++ /dev/null @@ -1 +0,0 @@ -../style_old.css \ No newline at end of file diff --git a/old/plugin/github.com/shylinux/echarts b/old/plugin/github.com/shylinux/echarts deleted file mode 160000 index 7a692891..00000000 --- a/old/plugin/github.com/shylinux/echarts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7a6928917468fdc44c879de55baeaf933c052fc5 diff --git a/pane/Action.css b/pane/Action.css index 24920f53..e9769e85 100644 --- a/pane/Action.css +++ b/pane/Action.css @@ -1,10 +1,25 @@ fieldset.Action { min-width:160px; min-height:160px; - padding-left:10px; - padding-right:10px; -} -fieldset.Action>div.output>div.item:hover { - background-color:lightblue; } +fieldset.Action fieldset.plugin { + margin:5px; +} +fieldset.Action fieldset.plugin legend { + border:ridge 2px cyan; + margin-top:5px; +} +fieldset.Action fieldset.plugin form.option div.item { + margin:5px; +} +fieldset.Action fieldset.plugin div.output { + margin:5px; + color:white; +} +fieldset.Action fieldset.plugin div.output tr { + background:green; +} + + + diff --git a/pane/Action.js b/pane/Action.js index 897ae038..6a240f10 100644 --- a/pane/Action.js +++ b/pane/Action.js @@ -19,13 +19,12 @@ Volcanos("onexport", {help: "导出数据", list: [], if (can.Conf(key, msg.Option(key, can.Cache(river+"."+storm, can._output)))) { typeof cb == "function" && cb(msg); return } - - can.run(msg._event, [river, storm], function(msg) { can._output.innerHTML = ""; + msg = can.request({}, {}), can.run(msg._event, [river, storm], function(msg) { can._output.innerHTML = ""; if (Volcanos.meta.follow[can._root]) { debugger } msg.Table(function(value, index, array) { // 添加列表 - // can.onappend._init(can, value, Config.libs.concat(["plugin/state.js"]), function(sub) { + // 插件回调 sub.run = function(event, cmds, cb, silent) { can.run(event, [river, storm, index].concat(cmds), cb, silent) } diff --git a/pane/Header.js b/pane/Header.js index 9521f1b2..2db860e4 100644 --- a/pane/Header.js +++ b/pane/Header.js @@ -12,15 +12,17 @@ Volcanos("onaction", {help: "交互数据", list: [], }, title: function(event, can, key) { }, - time: function(event, can, key) { - can.ui[key].innerHTML = can.base.Time().split(" ")[1] + username: function(event, can, key) { + // can.ui[key].innerHTML = can.base.Time().split(" ")[1] }, }) Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg, list, cb, target) { can._output.innerHTML = ""; can.run(msg._event, [], function(msg) { - console.log(can._root, can._name, "show", msg.result) - can.core.List(msg.result, function(title) { + if (Volcanos.meta.follow["debug"]) { debugger } + can.Conf("username", msg.Option("user.nick")||msg.Option("user.name")) + + can.core.List(msg.result||["github.com/shylinux/contexts"], function(title) { can.page.Append(can, can._output, [{view: ["title", "div", title], click: function(event) {can.onaction["title"](event, can, "title")}, }]) @@ -28,12 +30,15 @@ Volcanos("onexport", {help: "导出数据", list: [], console.log(can._root, can._name, "show", can.Conf("state")) can.ui = can.page.Append(can, can._output, [{view: "state", list: can.core.List(can.Conf("state"), function(item) { - return {text: can.Conf(item)||"", className: item, click: function(event) {can.onaction[item](event, can, item)}}; + return {name: item, view: ["item", "div", can.Conf(item)||""], click: function(event) {can.onaction[item](event, can, item)}}; })}]) can.timer = can.Timer({interval: 1000, length: -1}, function(event) { - can.onaction.time(event, can, "time") + can.onexport.time(event, can, "time") }) }) }, + time: function(event, can, key) { + can.ui[key].innerHTML = can.base.Time().split(" ")[1] + }, }) diff --git a/pane/River.css b/pane/River.css index 49111b54..29bd6f43 100644 --- a/pane/River.css +++ b/pane/River.css @@ -1,6 +1,8 @@ fieldset.River { min-width:80px; + max-width:160px; min-height:160px; + overflow:auto; float:left; } fieldset.River>div.output { diff --git a/pane/River.js b/pane/River.js index d8915b25..b8053b97 100644 --- a/pane/River.js +++ b/pane/River.js @@ -14,7 +14,7 @@ Volcanos("onexport", {help: "导出数据", list: [], typeof cb == "function" && cb (msg); return } - can.run(msg._event, [], function(msg) { can._output.innerHTML = ""; + msg = can.request({}, {}), can.run(msg._event, [], function(msg) { can._output.innerHTML = ""; if (Volcanos.meta.follow[can._root]) { debugger } var select; msg.Table(function(value, index, array) { // 添加列表 @@ -27,9 +27,10 @@ Volcanos("onexport", {help: "导出数据", list: [], // 右键点击 }); if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) { + msg.Option("river", value.key) select = view } - }); select.click(); + }); select && select.click(); typeof cb == "function" && cb(msg) }) }, diff --git a/pane/Storm.css b/pane/Storm.css index df64ac18..fc7eac82 100644 --- a/pane/Storm.css +++ b/pane/Storm.css @@ -1,6 +1,8 @@ fieldset.Storm { min-width:80px; + max-width:160px; min-height:160px; + overflow:auto; float:right; } fieldset.Storm>div.output { diff --git a/pane/Storm.js b/pane/Storm.js index aed0854f..25e33fb6 100644 --- a/pane/Storm.js +++ b/pane/Storm.js @@ -19,7 +19,7 @@ Volcanos("onexport", {help: "导出数据", list: [], typeof cb == "function" && cb (msg); return } - can.run(msg._event, [river], function(msg) { can._output.innerHTML = ""; + msg = can.request({}, {}), can.run(msg._event, [river], function(msg) { can._output.innerHTML = ""; if (Volcanos.meta.follow[can._root]) { debugger } var select; msg.Table(function(value, index, array) { // 添加列表 @@ -31,9 +31,10 @@ Volcanos("onexport", {help: "导出数据", list: [], // 右键点击 }); if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) { + msg.Option("storm", value.key) select = view } - }); select.click(); + }); select && select.click(); typeof cb == "function" && cb(msg) }) }) diff --git a/plugin/input/city.js b/plugin/input/city.js new file mode 100644 index 00000000..0201fccf --- /dev/null +++ b/plugin/input/city.js @@ -0,0 +1,13 @@ +Volcanos("onfigure", {help: "控件详情", list: [], + city: {click: function(event, can, value, cmd, target, figure) { + function run() {figure.output.innerHTML = "" + can.Run(event, ["action", "input", can.item.name, target.value], function(msg) { + can.page.AppendTable(can, figure.output, msg, msg.append, function(event, value, key, index, tr, td) { + target.value = value; msg.Option("_refresh") && run() + }) + }, true) + } + run() + }}, +}) + diff --git a/plugin/input/date.js b/plugin/input/date.js new file mode 100644 index 00000000..f3618719 --- /dev/null +++ b/plugin/input/date.js @@ -0,0 +1,73 @@ +Volcanos("onfigure", {help: "控件详情", list: [], + date: {click: function(event, can, value, cmd, target, figure) { + // 设置输入 + target.style.width = "120px" + function set(now) { + target.value = can.base.Time(now); + can.item.action == "auto" && can.run({}); + } + + // 添加插件 + figure.table = can.page.Append(can, figure.output, [{type: "table"}]).first + + // 添加控件 + can.now = target.value? new Date(target.value): new Date(); + var control = can.page.AppendAction(can, figure.action, ["今天", "随机", + ["hour"].concat(can.core.List(24)), ["minute"].concat(can.core.List(0, 60, 5)), ["second"].concat(can.core.List(0, 60, 5)), {view: ["", "br"]}, + {type: "hr", style: {margin: 0}}, {type: "br"}, + "上一月", ["year"].concat(can.core.List(can.now.getFullYear() - 20, can.now.getFullYear() + 20)), + ["month"].concat(can.core.List(1, 13)), "下一月", {view: ["", "br"]}, + ], function(event, value, cmd) {can.stick = true; + // 设置时间 + switch (cmd) { + case "year": can.now.setFullYear(parseInt(value)); show(can.now); return; + case "month": can.now.setMonth(parseInt(value)-1); show(can.now); return; + case "hour": can.now.setHours(parseInt(value)); set(show(can.now)); return; + case "minute": can.now.setMinutes(parseInt(value)); set(show(can.now)); return; + case "second": can.now.setSeconds(parseInt(value)); set(show(can.now)); return; + } + + // 设置日期 + switch (value) { + case "今天": can.now = new Date(); set(show(can.now)); break; + case "随机": can.now.setDate((Math.random() * 100 - 50) + can.now.getDate()); set(show(can.now)); break; + case "关闭": can.page.Remove(can, figure.first); delete(can.figure); + case "前一年": can.now.setFullYear(can.now.getFullYear()-1); show(can.now); break; + case "后一年": can.now.setFullYear(can.now.getFullYear()+1); show(can.now); break; + case "上一月": can.now.setMonth(can.now.getMonth()-1); show(can.now); break; + case "下一月": can.now.setMonth(can.now.getMonth()+1); show(can.now); break; + } + }) + + function show(now) { + // 设置控件 + control.month.value = now.getMonth()+1; + control.year.value = now.getFullYear(); + control.hour.value = now.getHours(); + control.minute.value = parseInt(now.getMinutes()/5)*5; + control.second.value = parseInt(now.getSeconds()/5)*5; + + // 设置组件 + can.page.Appends(can, figure.table, [{type: "tr", list: can.core.List(["日", "一", "二", "三", "四", "五", "六"], function(day) {return {text: [day, "th"]}})}]) + var tr; function add(day, type) {if (day.getDay() == 0) {tr = can.page.Append(can, figure.table, [{type: "tr"}]).tr} + can.page.Append(can, tr, [{text: [day.getDate(), "td", can.base.Time(day).split(" ")[0] == can.base.Time(now).split(" ")[0]? "select": type], + dataset: {date: day.getTime()}, click: function(event) {set(can.now = new Date(parseInt(event.target.dataset.date)))}, + }]) + } + + // 时间区间 + var one = new Date(now); one.setDate(1); + var end = new Date(now); end.setMonth(now.getMonth()+1); end.setDate(1); + var head = new Date(one); head.setDate(one.getDate()-one.getDay()); + var tail = new Date(end); tail.setDate(end.getDate()+7-end.getDay()); + + // 时间序列 + for (var day = new Date(head); day < one; day.setDate(day.getDate()+1)) {add(day, "last")} + for (var day = new Date(one); day < end; day.setDate(day.getDate()+1)) {add(day, "main")} + for (var day = new Date(end); end.getDay() != 0 && day < tail; day.setDate(day.getDate()+1)) {add(day, "next")} + return now + } + + set(show(can.now)); + }}, +}) diff --git a/plugin/input/key.js b/plugin/input/key.js new file mode 100644 index 00000000..6aaf6de0 --- /dev/null +++ b/plugin/input/key.js @@ -0,0 +1,12 @@ +Volcanos("onfigure", {help: "控件详情", list: [], + key: {click: function(event, can, value, cmd, target, figure) { + function run() {figure.output.innerHTML = "" + can.Run(event, ["action", "input", can.item.name, target.value], function(msg) { + can.page.AppendTable(can, figure.output, msg, msg.append, function(event, value, key, index, tr, td) { + target.value = value; msg.Option("_refresh") && run() + }) + }, true) + } + run() + }}, +}) diff --git a/plugin/input/province.js b/plugin/input/province.js new file mode 100644 index 00000000..89215f15 --- /dev/null +++ b/plugin/input/province.js @@ -0,0 +1,18 @@ +Volcanos("onfigure", {help: "控件详情", list: [], + province: {click: function(event, can, value, cmd, target, figure) { + figure.fieldset.style.left = "20px" + figure.fieldset.style.top = "200px" + + var china_chart = echarts.init(can.page.Append(can, figure.output, [{type: "div", style: {width: "600px", height: "400px"}}]).last); + + var option = {geo: {map: 'china'}}; + china_chart.setOption(option); + + china_chart.on('click', function (params) { + target.value = params.name; + }); + }}, +}, [ + "plugin/github.com/shylinux/echarts/echarts.js", + "plugin/github.com/shylinux/echarts/china.js", +]) diff --git a/plugin/input/upload.js b/plugin/input/upload.js new file mode 100644 index 00000000..b0dd7822 --- /dev/null +++ b/plugin/input/upload.js @@ -0,0 +1,38 @@ +Volcanos("onfigure", {help: "控件详情", list: [], + upload: {click: function(event, can, value, cmd, target, figure) {figure.stick = true + var begin = new Date(); + function show(event, value, total, loaded) { + var now = new Date(); can.page.Appends(can, figure.output, [ + {view: ["progress"], style: {height: "10px", border: "solid 2px red"}, list: [{ + view: ["progress"], style: {height: "10px", width: value + "%", background: "red"}, + }]}, + {text: [value+"%", "div"], style: {"float": "right"}}, + {text: [can.base.Duration(now - begin), "div"], style: {"float": "left"}}, + {text: [can.base.Size(loaded)+"/"+can.base.Size(total), "div"], style: {"text-align": "center"}}, + ]); + } + + var action = can.page.AppendAction(can, figure.action, [ + {type: "input", data: {name: "upload", type: "file", onchange: function(event) { + var file = action.upload.files[0] + console.log(file) + show(event, 0, file.size, 0) + }}, style: {width: "200px"}}, "上传", "关闭"], function(event, value, cmd) { + if (action.upload.files.length == 0) {return action.upload.focus()} + if (value == "关闭") {figure.stick = false; return} + + var msg = can.Event(event); + can.page.Select(can, can._plugin.option, "input", function(item) { + item.name && item.value && msg.Option(item.name, item.value) + }) + + // 上传文件 + begin = new Date(); + msg._progress = show + msg.upload = action.upload.files[0]; + can.run(event, ["action", "upload"], function(msg) { + can.user.toast("上传成功") + }, true); + }) + }}, +}) diff --git a/plugin/table.js b/plugin/table.js index f76c9cb2..dc6403ad 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -1,12 +1,15 @@ Volcanos("onimport", {help: "导入数据", list: [], - _init: function(can, msg, list, cb, output, action, option, field) { output.innerHTML = ""; - var table = can.page.AppendTable(can, output, msg, msg.append, function(event, value, key, index, tr, td) { - can.page.Select(can, option, "input.args", function(input) { if (input.name == key) { + _init: function(can, msg, list, cb, target) { can._output.innerHTML = ""; + var table = can.page.AppendTable(can, can._output, msg, msg.append, function(event, value, key, index, tr, td) { + can.page.Select(can, can._option, "input.args", function(input) { if (input.name == key) { var data = input.dataset || {} input.value = value + if (data.action == "auto") { + can.run(event, [], function(msg) {}) + } } }) }, function(event, value, key, index, tr, td) { }); - msg.result && can.page.AppendBoard(can, output, msg.result.join("")) + msg.result && can.page.AppendBoard(can, can._output, msg.result.join("")) }, }) Volcanos("onaction", {help: "控件交互", list: [], diff --git a/proto.js b/proto.js index d825aa75..2d188c0f 100644 --- a/proto.js +++ b/proto.js @@ -19,7 +19,8 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: { require: true, cache: false, frame: false, request: true, search: true, }, follow: { - volcano: false, debug: true, + // volcano: false, debug: true, + volcano: true, debug: true, }}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list; var conf = {}, conf_cb = {}, sync = {}, cache = {}; @@ -80,9 +81,9 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: { return val }, Copy: function(res) { if (!res) { return msg } - res.result && (msg.result = res.result) + res.result && (msg.result = (msg.result||[]).concat(res.result)) res.append && (msg.append = res.append) && res.append.forEach(function(item) { - res[item] && (msg[item] = res[item]) + res[item] && (msg[item] = (msg[item]||[]).concat(res[item])) }) res.option && (msg.option = res.option) && res.option.forEach(function(item) { res[item] && (msg[item] = res[item]) diff --git a/publish/order.js b/publish/order.js index bcfcd856..2b3d33d8 100644 --- a/publish/order.js +++ b/publish/order.js @@ -1,49 +1,67 @@ Volcanos("onengine", { river: { - one: {name: "some", storm: { - one: {name: "some", action: [ - {name: "show", help: "some"}, + "two": {name: "two", storm: { + "one": {name: "one", action: [ + {name: "some", help: "some", inputs: [ + {type: "text", name: "one"}, + {type: "button", name: "one"}, + ], engine: function(event, can, msg, pane, cmds, cb) { + msg.Echo("hello world") + typeof cb == "function" && cb(msg) + }}, + ]}, + "two": {name: "two", action: [ + {name: "some", help: "some", inputs: [ + {type: "text", name: "one"}, + {type: "button", name: "one"}, + ], engine: function(event, can, msg, pane, cmds, cb) { + msg.Echo("hello world") + typeof cb == "function" && cb(msg) + }}, + {name: "miss", help: "some", inputs: [ + {type: "text", name: "one"}, + {type: "button", name: "one"}, + ], engine: function(event, can, msg, pane, cmds, cb) { + msg.Echo("hello miss world") + typeof cb == "function" && cb(msg) + }}, ]}, - two: {name: "some"}, }}, - two: {name: "some", storm: { - one: {name: "some"}, - two: {name: "two", action: { - show: {name: "show", help: "some", inputs: [ - {type: "text", name: "arg"}, - ]}, - }}, - }}, - three: {name: "some"}, }, - - remote: function(event, can, msg, pane, cmds, cb) { var meta = can.onengine; - return false - var river = meta.river[msg.Option("river")] - var storm = river && river.storm[msg.Option("storm")] - - msg.Clear("append"); switch (pane._name) { + remote: function(event, can, msg, pane, cmds, cb) { + switch (pane._name) { case "River": - can.core.Item(meta.river, function(key, value) { - msg.Push("key", key) - msg.Push("name", value.name) - }) + if (cmds.length == 0) { + can.core.Item(can.onengine.river, function(key, value) { + msg.Push("key", key) + msg.Push("name", value.name) + }) + } break case "Storm": - river && can.core.Item(river.storm, function(key, value) { + var river = can.onengine.river[cmds[0]] + if (!river) { break } + can.core.Item(river.storm, function(key, value) { msg.Push("key", key) msg.Push("name", value.name) }) - break + typeof cb == "function" && cb(msg) + return true case "Action": - storm && can.core.List(storm.action, function(value) { - msg.Push("name", value.name) - msg.Push("help", value.help) - }) - break + var river = can.onengine.river[cmds[0]] + var storm = river && river.storm[cmds[1]] + if (!storm) { break } if (cmds.length == 2) { + can.core.List(storm.action, function(value) { + msg.Push("name", value.name||"") + msg.Push("help", value.help||"") + msg.Push("inputs", JSON.stringify(value.inputs||[])) + }) + typeof cb == "function" && cb(msg) + } else { + storm.action[cmds[2]].engine(event, can, msg, pane, cmds, cb) + } + return true } - typeof cb == "function" && cb(msg); - return true + return false; }, -}, [], function(can) { }) - +}, [], function(can) {}) diff --git a/style.css b/style.css index aceec56f..01641ce9 100644 --- a/style.css +++ b/style.css @@ -108,6 +108,9 @@ fieldset table tr.over { fieldset table tr.select { background-color:#0fbd45; } +fieldset table th { + background-color:#0fbd45; +} fieldset table th { font-family:monospace; background-color:#0fbd45;