mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt index.js
This commit is contained in:
parent
cf95a9ca79
commit
86badb0c38
13
frame.js
13
frame.js
@ -1,12 +1,12 @@
|
||||
Volcanos("onaction", { _init: function(can, meta, list, cb, target) {
|
||||
can.core.Next(meta.panes, function(item, next) {
|
||||
can.onappend._init(can, item, Config.libs.concat(item.list), function(pane) {
|
||||
can.onappend._init(can, item, meta.libs.concat(item.list), function(pane) {
|
||||
pane.Conf(item), pane.run = function(event, cmds, cb) {
|
||||
(can.onaction[cmds[0]]||can.onaction[meta.main.engine])(event, can, pane.request(event), pane, cmds, cb);
|
||||
}, can[item.name] = pane, next();
|
||||
}, can._target);
|
||||
}, function() { can.onlayout._init(can, meta, list, function() {
|
||||
can.require(["/publish/order.js"], function(can) {
|
||||
can.require(meta.main.list, function(can) {
|
||||
function getAction() {}
|
||||
function getStorm(storm) { can.core.Item(storm, function(key, value) {
|
||||
value._link? can.require([value._link], function(can) {
|
||||
@ -100,7 +100,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
||||
var sub = Volcanos(meta.name, { _help: meta.name, _target: field,
|
||||
_option: option, _action: action, _output: output, _history: [],
|
||||
_follow: can._follow+"."+meta.name,
|
||||
}, [Config.volcano].concat(list), function(sub) {
|
||||
}, [Volcanos.meta.volcano].concat(list), function(sub) {
|
||||
meta.feature = can.base.Obj(meta.feature, {})
|
||||
meta.detail = meta.feature["detail"] || {}
|
||||
sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field);
|
||||
@ -112,7 +112,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
||||
_target: can.onappend.input(sub, option, item.type, item, args[index]),
|
||||
_option: option, _action: action, _output: output,
|
||||
_follow: can._follow+"."+meta.name+"."+item.name,
|
||||
}, Config.libs.concat([item.display||"/plugin/input.js"]), function(input) {
|
||||
}, Volcanos.meta.libs.concat([item.display||"/plugin/input.js"]), function(input) {
|
||||
input.onimport._init(input, input.Conf(item), item.list||[], function() {}, input._target);
|
||||
|
||||
input.run = function(event, cmds, cb, silent) {
|
||||
@ -144,7 +144,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
||||
sub[display] = Volcanos(display, { _target: output,
|
||||
_option: option, _action: action, _output: output,
|
||||
_follow: can._follow+"."+meta.name+"."+display,
|
||||
}, Config.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf())
|
||||
}, Volcanos.meta.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf())
|
||||
table.onimport._init(table, msg, msg.append||[], function() {}, output)
|
||||
|
||||
table.run = function(event, cmds, cb, silent) {
|
||||
@ -233,7 +233,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
||||
|
||||
item.type == "textarea" && can.page.Append(can, option, [{type: "br"}]);
|
||||
item.type == "text" && !target.placeholder && (target.placeholder = item.name || "");
|
||||
item.type != "button" && !target.title && (target.title = item.placeholder);
|
||||
item.type != "button" && !target.title && (target.title = target.placeholder);
|
||||
// item.type == "button" && item.action == "auto" && can.run && can.run({});
|
||||
item.type == "select" && (target.value = item.value || item.values[item.index||0]);
|
||||
return target;
|
||||
@ -354,7 +354,6 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
||||
}, [], function(can) {})
|
||||
Volcanos("onlayout", { _init: function(can, meta, list, cb, target) {
|
||||
var width = can._width, height = can._height;
|
||||
if (Volcanos.meta.follow[can._root]) { debugger }
|
||||
|
||||
can.page.Select(can, target, "fieldset.head", function(field) {
|
||||
height -= field.offsetHeight;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="/proto.js"></script>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||
</head>
|
||||
<body style="min-height:400px">
|
||||
<script src="/proto.js"></script>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>volcanos</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="/static/volcanos/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/volcanos/index.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="/static/volcanos/page/share.js"></script>
|
||||
|
@ -3,8 +3,8 @@
|
||||
<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">
|
||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="/proto.js"></script>
|
||||
|
23
index.js
23
index.js
@ -1,4 +1,4 @@
|
||||
var Config = {name: "demo", volcano: "/frame.js", iceberg: "/chat/", intshell: "plug.sh",
|
||||
Volcanos({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", "username",
|
||||
@ -9,26 +9,13 @@ var Config = {name: "demo", volcano: "/frame.js", iceberg: "/chat/", intshell: "
|
||||
{type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["/pane/Footer.js", "/pane/Footer.css"], state: [
|
||||
"ncmd",
|
||||
]},
|
||||
], main: {name: "Header", engine: "remote", list: []},
|
||||
list: ["/plugin/state.js", "/plugin/input.js", "/plugin/table.js",
|
||||
], main: {name: "Header", engine: "remote", list: ["/publish/order.js"]}, plugin: [
|
||||
"/plugin/state.js",
|
||||
"/plugin/input.js",
|
||||
"/plugin/table.js",
|
||||
"/plugin/input/key",
|
||||
"/plugin/input/date",
|
||||
"/plugin/input/upload",
|
||||
"/plugin/input/province",
|
||||
],
|
||||
}
|
||||
|
||||
var Preload = Config.libs; Config.panes.forEach(function(pane) {
|
||||
Preload = Preload.concat(pane.list);
|
||||
}); Preload = Preload.concat(Config.list)
|
||||
|
||||
Volcanos(Config.name, { _target: document.body, _follow: "demo",
|
||||
_head: document.head, _body: document.body,
|
||||
_width: window.innerWidth, _height: window.innerHeight,
|
||||
}, Preload.concat(Config.volcano), function(can) { // 程序入口
|
||||
can.onaction._init(can, can.Conf(Config), [], function(msg) {
|
||||
console.log(can._root, can._name, "start", can, msg);
|
||||
can.Footer.onaction._init(can.Footer, msg);
|
||||
}, can._target)
|
||||
})
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>volcanos</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||
<link rel="stylesheet" type="text/css" href="/page/share.css">
|
||||
</head>
|
||||
<body>
|
||||
|
@ -27,9 +27,12 @@ Volcanos("onexport", {help: "导出数据", list: [],
|
||||
if (position) { can._output.scrollTo(0, position-1); return }
|
||||
|
||||
msg.Clear("option"), can.run(msg._event, [river, storm], function(sup) { can._output.innerHTML = ""; sup.Table(function(value, index, array) {
|
||||
value.inputs = can.base.Obj(value.inputs, [])
|
||||
value.inputs.length == 0 && (value.inputs = [{type: "text"}, {type: "button", name: "查看"}])
|
||||
can.onappend._init(can, value, Config.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||
value.inputs = can.base.Obj(value.inputs, []), value.inputs.length == 0 && (value.inputs = [
|
||||
{type: "text", name: "name", action: "auto"},
|
||||
{type: "button", name: "查看", action: "auto"},
|
||||
{type: "button", name: "返回"},
|
||||
]);
|
||||
can.onappend._init(can, value, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event, {_msg: sup});
|
||||
// 插件回调
|
||||
can.run(event, [river, storm, index].concat(cmds), function(msg) {
|
||||
|
50
proto.js
50
proto.js
@ -9,7 +9,7 @@ function shy(help, meta, list, cb) {
|
||||
}
|
||||
|
||||
var cb = arguments[arguments.length-1] || function() {};
|
||||
cb.help = next("string") || "还没有写";
|
||||
cb.help = next("string") || cb.name;
|
||||
cb.meta = next("object") || {};
|
||||
cb.list = next("object") || [];
|
||||
return cb;
|
||||
@ -18,23 +18,31 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
||||
volcano: false, config: true,
|
||||
require: true, cache: false, frame: false,
|
||||
request: true, search: true,
|
||||
}, follow: {
|
||||
volcano: false, debug: true,
|
||||
// volcano: true, debug: true,
|
||||
}}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
|
||||
}, libs: []}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
|
||||
if (typeof name == "object") { var Config = name;
|
||||
meta.volcano = Config.volcano, meta.libs = Config.libs;
|
||||
var Preload = Config.libs; Config.panes.forEach(function(pane) {
|
||||
Preload = Preload.concat(pane.list);
|
||||
}); Preload = Preload.concat(Config.plugin)
|
||||
|
||||
var conf = {}, conf_cb = {}, sync = {}, cache = {};
|
||||
meta.debug[can._root] && console.debug(can._root, name, "create");
|
||||
can = can || {}, list.push(can) && (can.__proto__ = { _name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) {
|
||||
name = Config.name, can = { _target: document.body, _follow: Config.name,
|
||||
_head: document.head, _body: document.body,
|
||||
_width: window.innerWidth, _height: window.innerHeight,
|
||||
}, libs = Preload.concat(Config.volcano), cb = function(can) {
|
||||
can.onaction._init(can, can.Conf(Config), [], function(msg) {
|
||||
}, can._target)
|
||||
}
|
||||
}
|
||||
|
||||
var conf = {}, conf_cb = {}, cache = {};
|
||||
can = can || {}, list.push(can) && (can.__proto__ = {_name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) {
|
||||
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
|
||||
if (list[meta.index] == can) {continue}
|
||||
meta.debug["cache"] && console.debug("cache", name, "load", meta.index, list[meta.index]);
|
||||
if (list[meta.index] == can) { continue }
|
||||
cache.push(list[meta.index]);
|
||||
// 加载缓存
|
||||
}
|
||||
|
||||
for (var i = 0; i < cache.length; i++) {
|
||||
meta.debug["frame"] && console.debug("frame", can._name, "load", i, cache[i]);
|
||||
typeof cb == "function" && cb(can, name, cache[i]) || (can[cache[i]._name] = cache[i]);
|
||||
// 加载索引
|
||||
}
|
||||
@ -159,16 +167,6 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
||||
}
|
||||
return conf[key] || ""
|
||||
}),
|
||||
Timer: shy("定时器, value, [1,2,3,4], {value, length}", function(interval, cb, cbs) { interval = typeof interval == "object"? interval || []: [interval];
|
||||
var timer = {stop: false};
|
||||
function loop(event, i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(event, interval)}
|
||||
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
|
||||
typeof cbs == "function" && cbs(event, interval):
|
||||
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1]);
|
||||
}
|
||||
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0]);
|
||||
return timer;
|
||||
}),
|
||||
Cache: shy("缓存器", function(name, output, data) {
|
||||
if (data) { if (output.children.length == 0) { return }
|
||||
// 写缓存
|
||||
@ -196,6 +194,16 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
||||
delete(cache[name]);
|
||||
return list.data;
|
||||
}),
|
||||
Timer: shy("定时器, value, [1,2,3,4], {value, length}", function(interval, cb, cbs) { interval = typeof interval == "object"? interval || []: [interval];
|
||||
var timer = {stop: false};
|
||||
function loop(event, i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(event, interval)}
|
||||
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
|
||||
typeof cbs == "function" && cbs(event, interval):
|
||||
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1]);
|
||||
}
|
||||
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0]);
|
||||
return timer;
|
||||
}),
|
||||
});
|
||||
|
||||
return can.require(libs, cb), can
|
||||
|
Loading…
x
Reference in New Issue
Block a user