mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add demo
This commit is contained in:
parent
ada5587521
commit
31f659e664
14
demo/frame.js
Normal file
14
demo/frame.js
Normal file
@ -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) {})
|
15
demo/index.html
Normal file
15
demo/index.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=0.7,user-scalable=no">
|
||||||
|
<title>volcanos</title>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script src="proto.js"></script>
|
||||||
|
<script src="order.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
|
17
demo/order.js
Normal file
17
demo/order.js
Normal file
@ -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);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
80
demo/proto.js
Normal file
80
demo/proto.js
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
2
demo/style.css
Normal file
2
demo/style.css
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
* {
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
Volcanos("demo", {head: document.head, body: document.body, target: document.body,
|
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"
|
can.target.style.background = "black"
|
||||||
console.log(can)
|
console.log(can)
|
||||||
|
can.page.AppendField(can, can.target, "item", {name: "demo", help: "demo", inputs: [
|
||||||
|
{_input: "text", name: "help"},
|
||||||
|
]})
|
||||||
})
|
})
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
<title>volcanos</title>
|
<title>volcanos</title>
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
|
<link rel="shortcut icon" type="image/ico" href="favicon.ico">
|
||||||
<link rel="stylesheet" type="text/css" href="style.css">
|
<link rel="stylesheet" type="text/css" href="style_old.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="page/index.js"></script>
|
<script src="page/index.js"></script>
|
||||||
<script src="proto.js"></script>
|
<script src="proto_old.js"></script>
|
||||||
<script src="frame.js"></script>
|
<script src="frame_old.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
||||||
|
6
page/open.sh
Normal file
6
page/open.sh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
ish_ctx_dev_can_pwd=$PWD
|
||||||
|
|
||||||
|
ish_ctx_dev_can() {
|
||||||
|
open $ish_ctx_dev_can_pwd/$1.html
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
../proto.js
|
|
@ -1 +0,0 @@
|
|||||||
../style.css
|
|
Loading…
x
Reference in New Issue
Block a user