1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-26 01:04:06 +08:00

opt order

This commit is contained in:
shaoying 2020-05-04 08:10:51 +08:00
parent 601c5d2d1c
commit 91ff63791d
100 changed files with 299 additions and 111 deletions

View File

@ -1 +0,0 @@
../favicon.ico

View File

@ -3,7 +3,8 @@ Volcanos("onimport", {
if (Volcanos.meta.follow[can._root]) { debugger } if (Volcanos.meta.follow[can._root]) { debugger }
can.core.Next(meta.panes, function(item, next) { 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, 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]]) { if (can.onaction[cmds[0]]) {
can.onaction[cmds[0]](event, can, msg, pane, cmds, cb); can.onaction[cmds[0]](event, can, msg, pane, cmds, cb);
} else { } else {
@ -31,11 +32,15 @@ Volcanos("onaction", {
}, sub._target) }, sub._target)
}, },
remote: function(event, can, msg, pane, cmds, cb) { 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)) { if (can.onengine && can.onengine.remote(event, can, msg, pane, cmds, cb)) {
return 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); 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) { can.misc.Run(event, can, {names: pane._name}, cmds, function(msg) {
typeof cb == "function" && cb(msg); typeof cb == "function" && cb(msg);
@ -44,7 +49,7 @@ Volcanos("onaction", {
}) })
Volcanos("onappend", { Volcanos("onappend", {
_init: function(can, meta, list, cb, target) { _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 option = can.page.Select(can, field, "form.option")[0];
var action = can.page.Select(can, field, "div.action")[0]; var action = can.page.Select(can, field, "div.action")[0];
var output = can.page.Select(can, field, "div.output")[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.onimport._init(input, input.Conf(item), item.list||[], function() {
}, input._target); }, input._target);
// 件回调 // 件回调
input.run = function(event, cmds, cb, silent) { input.run = function(event, cmds, cb, silent) {
switch (item.name) { switch (item.name) {
case "返回": case "返回":
@ -96,6 +101,11 @@ Volcanos("onappend", {
}, Config.libs.concat([display]), function(table) { }, Config.libs.concat([display]), function(table) {
table.onimport._init(table, msg, msg.append||[], function() { table.onimport._init(table, msg, msg.append||[], function() {
}, output) }, output)
// 组件回调
table.run = function(event, cmds, cb, silent) {
input.run(event, cmds, cb, silent)
}
}) })
}, silent) }, silent)
} }
@ -138,7 +148,7 @@ Volcanos("onappend", {
item.action = item.action || item.value || ""; item.action = item.action || item.value || "";
item.cb = item.cb || 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") { switch (item.type = item.type || item._type || item._input || "text") {
case "upfile": item.type = "file"; break case "upfile": item.type = "file"; break
// case "button": item.value = item.value || item.name || "查看"; break // case "button": item.value = item.value || item.name || "查看"; break
@ -165,6 +175,7 @@ Volcanos("onappend", {
break 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 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() { item.figure && item.figure.indexOf("@") == 0 && (item.figure = item.figure.slice(1)) && can.require(["plugin/input/"+item.figure], function() {
target.type != "button" && (target.value = "") target.type != "button" && (target.value = "")
@ -198,7 +209,7 @@ Volcanos("onlayout", {
can.page.Select(can, field, "div.output", function(output) { can.page.Select(can, field, "div.output", function(output) {
var border = output.offsetHeight - output.clientHeight; var border = output.offsetHeight - output.clientHeight;
can.page.Modify(can, field, { style: { can.page.Modify(can, output, { style: {
height: height-border*2-20+"px", height: height-border*2-20+"px",
} }) } })
}) })

View File

@ -33,7 +33,7 @@ var can = Volcanos("chat", {
}, },
run: function(event, option, cmds, cb) {can.misc.Run(event, page, option, cmds, cb)}, 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) page.onimport._init && page.onimport._init(page, page.Conf(conf), body)

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="style_old.css"> <link rel="stylesheet" type="text/css" href="style_old.css">
</head> </head>
<body> <body>
<script src="page/index.js"></script> <script src="index.js"></script>
<script src="proto_old.js"></script> <script src="proto_old.js"></script>
<script src="frame_old.js"></script> <script src="frame_old.js"></script>
</body> </body>

View File

@ -1,7 +1,6 @@
var Config = {iceberg: "/chat/", volcano: "", var Config = {iceberg: "/chat/", volcano: "",
libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"], libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"],
main: "chat", list: [ main: "chat", list: ["chat",
"page/chat",
"pane/float/Toast", "pane/float/Carte", "pane/float/Toast", "pane/float/Carte",
"pane/float/Tutor", "pane/float/Debug", "pane/float/Tutor", "pane/float/Debug",
"pane/float/Login", "pane/float/Favor", "pane/float/Login", "pane/float/Favor",

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1,12 +1,19 @@
var Config = {name: "demo", volcano: "frame.js", iceberg: "/chat/", intshell: "plug.sh", var Config = {name: "demo", volcano: "frame.js", iceberg: "/chat/", intshell: "plug.sh",
libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"], panes: [ 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: "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: "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: "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"]}, {type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["pane/Footer.js", "pane/Footer.css"]},
], main: {name: "Header", engine: "remote", list: []}, ], 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) { var Preload = Config.libs; Config.panes.forEach(function(pane) {

View File

@ -44,7 +44,12 @@ Volcanos("misc", {help: "工具模块",
++arguments.callee.meta.order ++arguments.callee.meta.order
xhr.setRequestHeader("Accept", "application/json") xhr.setRequestHeader("Accept", "application/json")
xhr.responseType = msg.responseType || "" xhr.responseType = msg.responseType || ""
try {
xhr.send(data) xhr.send(data)
} catch(e) {
console.error(e)
cb == "function" && cb(msg);
}
msg._xhr = xhr msg._xhr = xhr
}), }),
Run: shy("请求后端", {order: 0}, function(event, can, dataset, cmd, cb) { Run: shy("请求后端", {order: 0}, function(event, can, dataset, cmd, cb) {

View File

@ -1,14 +0,0 @@
<!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="demo.js"></script>
</body>

View File

@ -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"},
]})
})

View File

@ -1 +0,0 @@
../frame_old.js

View File

@ -1 +0,0 @@
../../lib

View File

@ -1,6 +0,0 @@
ish_ctx_dev_can_pwd=$PWD
ish_ctx_dev_can() {
open $ish_ctx_dev_can_pwd/$1.html
}

View File

@ -1 +0,0 @@
../page

View File

@ -1 +0,0 @@
../pane

View File

@ -1 +0,0 @@
../plugin

View File

@ -1 +0,0 @@
../proto_old.js

View File

@ -1 +0,0 @@
../style_old.css

@ -1 +0,0 @@
Subproject commit 7a6928917468fdc44c879de55baeaf933c052fc5

View File

@ -1,10 +1,25 @@
fieldset.Action { fieldset.Action {
min-width:160px; min-width:160px;
min-height: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;
}

View File

@ -19,13 +19,12 @@ Volcanos("onexport", {help: "导出数据", list: [],
if (can.Conf(key, msg.Option(key, can.Cache(river+"."+storm, can._output)))) { if (can.Conf(key, msg.Option(key, can.Cache(river+"."+storm, can._output)))) {
typeof cb == "function" && cb(msg); return typeof cb == "function" && cb(msg); return
} }
msg = can.request({}, {}), can.run(msg._event, [river, storm], function(msg) { can._output.innerHTML = "";
can.run(msg._event, [river, storm], function(msg) { can._output.innerHTML = "";
if (Volcanos.meta.follow[can._root]) { debugger } if (Volcanos.meta.follow[can._root]) { debugger }
msg.Table(function(value, index, array) { msg.Table(function(value, index, array) {
// 添加列表 // 添加列表
//
can.onappend._init(can, value, Config.libs.concat(["plugin/state.js"]), function(sub) { can.onappend._init(can, value, Config.libs.concat(["plugin/state.js"]), function(sub) {
// 插件回调
sub.run = function(event, cmds, cb, silent) { sub.run = function(event, cmds, cb, silent) {
can.run(event, [river, storm, index].concat(cmds), cb, silent) can.run(event, [river, storm, index].concat(cmds), cb, silent)
} }

View File

@ -12,15 +12,17 @@ Volcanos("onaction", {help: "交互数据", list: [],
}, },
title: function(event, can, key) { title: function(event, can, key) {
}, },
time: function(event, can, key) { username: function(event, can, key) {
can.ui[key].innerHTML = can.base.Time().split(" ")[1] // can.ui[key].innerHTML = can.base.Time().split(" ")[1]
}, },
}) })
Volcanos("onexport", {help: "导出数据", list: [], Volcanos("onexport", {help: "导出数据", list: [],
_init: function(can, msg, list, cb, target) { can._output.innerHTML = ""; _init: function(can, msg, list, cb, target) { can._output.innerHTML = "";
can.run(msg._event, [], function(msg) { can.run(msg._event, [], function(msg) {
console.log(can._root, can._name, "show", msg.result) if (Volcanos.meta.follow["debug"]) { debugger }
can.core.List(msg.result, function(title) { 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], can.page.Append(can, can._output, [{view: ["title", "div", title],
click: function(event) {can.onaction["title"](event, can, "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")) 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) { 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.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]
},
}) })

View File

@ -1,6 +1,8 @@
fieldset.River { fieldset.River {
min-width:80px; min-width:80px;
max-width:160px;
min-height:160px; min-height:160px;
overflow:auto;
float:left; float:left;
} }
fieldset.River>div.output { fieldset.River>div.output {

View File

@ -14,7 +14,7 @@ Volcanos("onexport", {help: "导出数据", list: [],
typeof cb == "function" && cb (msg); return 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 } if (Volcanos.meta.follow[can._root]) { debugger }
var select; msg.Table(function(value, index, array) { 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) { if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) {
msg.Option("river", value.key)
select = view select = view
} }
}); select.click(); }); select && select.click();
typeof cb == "function" && cb(msg) typeof cb == "function" && cb(msg)
}) })
}, },

View File

@ -1,6 +1,8 @@
fieldset.Storm { fieldset.Storm {
min-width:80px; min-width:80px;
max-width:160px;
min-height:160px; min-height:160px;
overflow:auto;
float:right; float:right;
} }
fieldset.Storm>div.output { fieldset.Storm>div.output {

View File

@ -19,7 +19,7 @@ Volcanos("onexport", {help: "导出数据", list: [],
typeof cb == "function" && cb (msg); return 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 } if (Volcanos.meta.follow[can._root]) { debugger }
var select; msg.Table(function(value, index, array) { 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) { if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) {
msg.Option("storm", value.key)
select = view select = view
} }
}); select.click(); }); select && select.click();
typeof cb == "function" && cb(msg) typeof cb == "function" && cb(msg)
}) })
}) })

13
plugin/input/city.js Normal file
View File

@ -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()
}},
})

73
plugin/input/date.js Normal file
View File

@ -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));
}},
})

12
plugin/input/key.js Normal file
View File

@ -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()
}},
})

18
plugin/input/province.js Normal file
View File

@ -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",
])

38
plugin/input/upload.js Normal file
View File

@ -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);
})
}},
})

View File

@ -1,12 +1,15 @@
Volcanos("onimport", {help: "导入数据", list: [], Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, msg, list, cb, output, action, option, field) { output.innerHTML = ""; _init: function(can, msg, list, cb, target) { can._output.innerHTML = "";
var table = can.page.AppendTable(can, output, msg, msg.append, function(event, value, key, index, tr, td) { var table = can.page.AppendTable(can, 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) { can.page.Select(can, can._option, "input.args", function(input) { if (input.name == key) { var data = input.dataset || {}
input.value = value input.value = value
if (data.action == "auto") {
can.run(event, [], function(msg) {})
}
} }) } })
}, function(event, value, key, index, tr, td) { }, 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: [], Volcanos("onaction", {help: "控件交互", list: [],

View File

@ -19,7 +19,8 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
require: true, cache: false, frame: false, require: true, cache: false, frame: false,
request: true, search: true, request: true, search: true,
}, follow: { }, 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; }}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
var conf = {}, conf_cb = {}, sync = {}, cache = {}; var conf = {}, conf_cb = {}, sync = {}, cache = {};
@ -80,9 +81,9 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
return val return val
}, },
Copy: function(res) { if (!res) { return msg } 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.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.option && (msg.option = res.option) && res.option.forEach(function(item) {
res[item] && (msg[item] = res[item]) res[item] && (msg[item] = res[item])

View File

@ -1,49 +1,67 @@
Volcanos("onengine", { Volcanos("onengine", {
river: { river: {
one: {name: "some", storm: { "two": {name: "two", storm: {
one: {name: "some", action: [ "one": {name: "one", action: [
{name: "show", help: "some"}, {name: "some", help: "some", inputs: [
]}, {type: "text", name: "one"},
two: {name: "some"}, {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", 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) {
remote: function(event, can, msg, pane, cmds, cb) { var meta = can.onengine; switch (pane._name) {
return false
var river = meta.river[msg.Option("river")]
var storm = river && river.storm[msg.Option("storm")]
msg.Clear("append"); switch (pane._name) {
case "River": case "River":
can.core.Item(meta.river, function(key, value) { if (cmds.length == 0) {
can.core.Item(can.onengine.river, function(key, value) {
msg.Push("key", key) msg.Push("key", key)
msg.Push("name", value.name) msg.Push("name", value.name)
}) })
}
break break
case "Storm": 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("key", key)
msg.Push("name", value.name) msg.Push("name", value.name)
}) })
break typeof cb == "function" && cb(msg)
case "Action":
storm && can.core.List(storm.action, function(value) {
msg.Push("name", value.name)
msg.Push("help", value.help)
})
break
}
typeof cb == "function" && cb(msg);
return true return true
case "Action":
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
}
return false;
}, },
}, [], function(can) { }) }, [], function(can) {})

View File

@ -108,6 +108,9 @@ fieldset table tr.over {
fieldset table tr.select { fieldset table tr.select {
background-color:#0fbd45; background-color:#0fbd45;
} }
fieldset table th {
background-color:#0fbd45;
}
fieldset table th { fieldset table th {
font-family:monospace; font-family:monospace;
background-color:#0fbd45; background-color:#0fbd45;