diff --git a/page/favicon.ico b/demo/favicon.ico similarity index 100% rename from page/favicon.ico rename to demo/favicon.ico diff --git a/demo/frame.js b/demo/frame.js new file mode 100644 index 00000000..a472d71b --- /dev/null +++ b/demo/frame.js @@ -0,0 +1,14 @@ +Volcanos("onappend", { + init: function(can, type, item, list, cb, target) { + var sub = Volcanos(item.name, { + _target: can.page.AppendField(can, target, type, item), + }, list, function(sub) { cb(sub) }) + }, +}, [], function(can) {}) +Volcanos("onremove", {}, [], function(can) {}) + +Volcanos("onimport", {}, [], function(can) {}) +Volcanos("onexport", {}, [], function(can) {}) + +Volcanos("onaction", {}, [], function(can) {}) +Volcanos("ondetail", {}, [], function(can) {}) diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 00000000..657607a7 --- /dev/null +++ b/demo/index.html @@ -0,0 +1,15 @@ + + + + + volcanos + + + + + + + + + + diff --git a/demo/lib b/demo/lib new file mode 120000 index 00000000..dc598c56 --- /dev/null +++ b/demo/lib @@ -0,0 +1 @@ +../lib \ No newline at end of file diff --git a/demo/order.js b/demo/order.js new file mode 100644 index 00000000..e20c2b9b --- /dev/null +++ b/demo/order.js @@ -0,0 +1,17 @@ +Volcanos("demo", { + _head: document.head, _body: document.body, _target: document.body, +}, ["lib/core.js", "lib/page.js", "frame.js"], function(can) { + can._body.style.background = "black" + can._body.style.color = "cyan" + console.log("", "demo", can); + + can.core.Next([ + {type: "item", name: "Header", help: "head", list: ["pane/Header.js", "pane/Header.css"]}, + {type: "item", name: "Footer", help: "foot", list: ["pane/Footer.js", "pane/Footer.css"]}, + ], function(item, next) { + can.onappend.init(can, item.type, item, item.list, function(sub) { + can[item.name] = sub, next() + }, can._target); + }) +}) + diff --git a/demo/pane b/demo/pane new file mode 120000 index 00000000..cabd17f1 --- /dev/null +++ b/demo/pane @@ -0,0 +1 @@ +../pane \ No newline at end of file diff --git a/demo/proto.js b/demo/proto.js new file mode 100644 index 00000000..b682d078 --- /dev/null +++ b/demo/proto.js @@ -0,0 +1,80 @@ +// volcanos: 前端 火山架 我看不行 +// FMS: a fieldset manager system + +function shy(help, meta, list, cb) { + var index = -1, value = "", type = "string", args = arguments; + function next(check) { + if (++index >= args.length) {return false} + if (check && check != typeof args[index]) {index--; return false} + return value = args[index], type = typeof value, value; + } + + var cb = arguments[arguments.length-1] || function() {}; + cb.help = next("string") || "还没有写"; + cb.meta = next("object") || {}; + cb.list = next("object") || {}; + cb.runs = function() {}; + return cb; +} +function Volcanos(name, can, libs, cb) { + // 全局缓存 + var list = arguments.callee.list || [], meta = arguments.callee.meta || {index: 1, cache: {}}; + arguments.callee.list = list, arguments.callee.meta = meta; + + // 定义原型 + can = can || {}, list.push(can) && (can.__proto__ = {_name: name, _load: function(name) { + if (meta.cache[name]) {var cache = meta.cache[name]; + // 加载索引 + for (var i = 0; i < cache.length; i++) {var sub = cache[i]; + can[sub._name] = sub; + } + return can + } + + // 加载缓存 + meta.cache[name] = [] + for (var i = meta.index; i < list.length; i++) {var sub = list[i]; + can[sub._name] = sub; + meta.cache[name].push(sub); + } + meta.index = i; + return can + }, + require: function(libs, cb) { + if (!libs || libs.length == 0) { + // 加载完成 + typeof cb == "function" && setTimeout(function() {cb(can)}, 10); + + } else if (can[libs[0]]) { + // 已经加载 + can.require(libs.slice(1), cb) + + } else if (meta.cache[libs[0]]) { + // 缓存加载 + can._load(libs[0]), can.require(libs.slice(1), cb) + + } else { + // 加载脚本 + var target = libs[0].endsWith(".css")? (can._head||document.head): (can._body||document.body); + var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0] + + if (source.endsWith(".js")) { var script = document.createElement("script"); + script.src = source, script.onload = function() { + can._load(libs[0]), can.require(libs.slice(1), cb); + } + target.appendChild(script); + + } else if (source.endsWith(".css")) { var style = document.createElement("link"); + style.rel = "stylesheet", style.type = "text/css"; + style.href = source; style.onload = function() { + can._load(libs[0]), can.require(libs.slice(1), cb); + }; + target.appendChild(style); + } + } + }, + }); + + return can.require(libs, cb), can +} + diff --git a/demo/style.css b/demo/style.css new file mode 100644 index 00000000..a0534f7f --- /dev/null +++ b/demo/style.css @@ -0,0 +1,2 @@ +* { +} diff --git a/frame.js b/frame_old.js similarity index 100% rename from frame.js rename to frame_old.js diff --git a/page/demo.js b/page/demo.js index 6dfc9f2e..73c7b330 100644 --- a/page/demo.js +++ b/page/demo.js @@ -1,5 +1,9 @@ Volcanos("demo", {head: document.head, body: document.body, target: document.body, -}, ["plugin/table.js"], function(can) { + +}, ["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/page/index.html b/page/index.html index e214103c..a9d7642a 100644 --- a/page/index.html +++ b/page/index.html @@ -5,12 +5,12 @@ volcanos - + - - + + diff --git a/page/open.sh b/page/open.sh new file mode 100644 index 00000000..f4564b47 --- /dev/null +++ b/page/open.sh @@ -0,0 +1,6 @@ + +ish_ctx_dev_can_pwd=$PWD + +ish_ctx_dev_can() { + open $ish_ctx_dev_can_pwd/$1.html +} diff --git a/page/proto.js b/page/proto.js deleted file mode 120000 index 4ec67a2a..00000000 --- a/page/proto.js +++ /dev/null @@ -1 +0,0 @@ -../proto.js \ No newline at end of file diff --git a/page/style.css b/page/style.css deleted file mode 120000 index 5191bf75..00000000 --- a/page/style.css +++ /dev/null @@ -1 +0,0 @@ -../style.css \ No newline at end of file diff --git a/proto.js b/proto_old.js similarity index 100% rename from proto.js rename to proto_old.js diff --git a/style.css b/style_old.css similarity index 100% rename from style.css rename to style_old.css