mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 00:38:05 +08:00
add Favor
This commit is contained in:
parent
275005283a
commit
ff6b987c2d
80
frame.js
80
frame.js
@ -1,19 +1,24 @@
|
||||
var can = Volcanos("chat", {
|
||||
Page: shy("构造网页", function(can, name, conf, cb, body) {
|
||||
var page = Volcanos(name, {type: "local",
|
||||
var page = Volcanos(name, {_type: "local",
|
||||
Plugin: can.Plugin, Inputs: can.Inputs, Output: can.Output,
|
||||
|
||||
Report: function(event, value, key) {
|
||||
kit.Item(page, function(index, item) {
|
||||
page.Import && page.Import(event, value, key)
|
||||
can.core.Item(page.panes, function(index, item) {
|
||||
item.Import && item.Import(event, value, key)
|
||||
})
|
||||
},
|
||||
Import: function(event, value, key) {var cb = page.onimport[key];
|
||||
typeof cb == "function" && cb(event, page, value, key, body);
|
||||
},
|
||||
|
||||
run: function(event, option, cmds, cb) {ctx.Run(event, option, cmds, cb)},
|
||||
}, Config.libs.concat(["page/"+name]), function(page) {
|
||||
}, Config.libs.concat(["page/"+name]), function(page) {page.Conf(conf);
|
||||
page.onimport._init && page.onimport._init(page, conf, body)
|
||||
can.core.Next(conf.pane, function(item, cb) {
|
||||
page[item.pos] = page[item.name] = can.Pane(page, item.name, item, cb, can.page.Select(can, body, "fieldset."+item.name)[0] ||
|
||||
can.core.Next(conf.pane, function(item, cb) {page.panes = page.panes || {};
|
||||
page.panes[item.name] = page[item.pos] = page[item.name] = can.Pane(page, item.name, item, cb,
|
||||
can.page.Select(can, body, "fieldset."+item.name)[0] ||
|
||||
can.page.AppendField(can, body, item.name+" dialog", item))
|
||||
}, function() {typeof cb == "function" && cb(page)})
|
||||
}, conf)
|
||||
@ -22,7 +27,7 @@ var can = Volcanos("chat", {
|
||||
Pane: shy("构造面板", function(can, name, meta, cb, field) {
|
||||
var river = "", storm = "";
|
||||
|
||||
var pane = Volcanos(name, {type: "local",
|
||||
var pane = Volcanos(name, {_type: "local",
|
||||
option: field.querySelector("form.option"),
|
||||
action: field.querySelector("div.action"),
|
||||
output: field.querySelector("div.output"),
|
||||
@ -34,27 +39,28 @@ var can = Volcanos("chat", {
|
||||
},
|
||||
|
||||
Size: function(event, width, height) {var cb = pane.onimport["size"];
|
||||
if (width > 0) {
|
||||
field.style.display = width === 0 || height === 0? "none": "block";
|
||||
if (width > 0) {
|
||||
field.style.width = width + "px"
|
||||
} else if (width == -1) {
|
||||
field.style.width = document.body.offsetWidth + "px"
|
||||
} else if (width == -2) {
|
||||
field.style.width = ""
|
||||
}
|
||||
|
||||
if (height > 0) {
|
||||
field.style.height = height + "px"
|
||||
} else if (height == -1) {
|
||||
field.style.height = document.body.offsetHeight + "px"
|
||||
} else if (width == -2) {
|
||||
field.style.width = ""
|
||||
}
|
||||
|
||||
typeof cb == "function" && cb(event, pane, {width: width, height: height}, "size", pane.output)
|
||||
},
|
||||
|
||||
Show: function(width, height) {field.style.display = "block";
|
||||
if (width < 0) {field.style.left = -width / 2 + "px";
|
||||
field.style.width = (document.body.offsetWidth + width) / 2 + "px";
|
||||
}
|
||||
if (height < 0) {field.style.top = -height / 2 + "px";
|
||||
field.style.height = (document.body.offsetHeight + height) / 2 + "px";
|
||||
field.style.width = (document.body.offsetWidth + width) + "px";
|
||||
}
|
||||
if (width > 0) {field.style.width = width + "px";
|
||||
field.style.left = (document.body.offsetWidth - width) / 2 + "px";
|
||||
@ -62,17 +68,21 @@ var can = Volcanos("chat", {
|
||||
if (height > 0) {field.style.height = height + "px";
|
||||
field.style.top = (document.body.offsetHeight - height) / 2 + "px";
|
||||
}
|
||||
if (height < 0) {field.style.top = -height / 2 + "px";
|
||||
field.style.height = (document.body.offsetHeight + height) + "px";
|
||||
}
|
||||
return field;
|
||||
},
|
||||
Hide: function() {field.style.display = "none"},
|
||||
|
||||
run: function(event, cmds, cb) {var msg = pane.Event(event)
|
||||
can.page.Select(can, pane.action, "input", function(item, index) {
|
||||
msg.Option(name, item.value)
|
||||
msg.Option(item.name, item.value)
|
||||
})
|
||||
can.run(event, pane.option.dataset, cmds, cb)
|
||||
},
|
||||
}, Config.libs.concat(["pane/"+name]), function(pane) {
|
||||
pane.onimport._init && pane.onimport._init(pane, pane.output, pane.action, pane.option, field)
|
||||
pane.onimport._init && pane.onimport._init(pane, pane.Conf(meta), pane.output, pane.action, pane.option, field)
|
||||
|
||||
function deal(event, value) {
|
||||
typeof pane.onaction[value] == "function" && pane.onaction[value](event, pane, meta, value, pane.output)
|
||||
@ -95,9 +105,15 @@ var can = Volcanos("chat", {
|
||||
var args = meta.args || [];
|
||||
var feature = JSON.parse(meta.feature||'{}');
|
||||
var exports = JSON.parse(meta.exports||'{}');
|
||||
var plugin = Volcanos(name, {type: "local",
|
||||
var plugin = Volcanos(name, {_type: "local",
|
||||
option: field.querySelector("form.option"),
|
||||
action: field.querySelector("div.action"),
|
||||
output: field.querySelector("div.output"),
|
||||
Inputs: can.Inputs, Output: can.Output,
|
||||
|
||||
Remove: function(event) {var list = can.page.Select(can, option, "input.temp")
|
||||
list.length > 0 && list[list.length-1].parentNode.removeChild(list[list.length-1])
|
||||
},
|
||||
Append: function(item, cb) {item = item || {type: "text", name: "", className: "args temp"};
|
||||
var name = item.name || item.value || "args"+plugin.page.Select(can, option, "input.args.temp").length;
|
||||
var count = plugin.page.Select(can, option, ".args").length, value = "";
|
||||
@ -107,6 +123,7 @@ var can = Volcanos("chat", {
|
||||
Select: function(event, target, focus) {
|
||||
can.plugin = field, can.input = target || option.querySelectorAll("input")[1];
|
||||
focus && can.input.focus();
|
||||
return true
|
||||
},
|
||||
Option: function(key, value) {
|
||||
value != undefined && option[key] && (option[key].value = value)
|
||||
@ -115,9 +132,14 @@ var can = Volcanos("chat", {
|
||||
},
|
||||
Report: function(event, value, key, index) {
|
||||
for (var i = 0; i < exports.length; i += 3) {
|
||||
if (exports[i+1] == key) {key = exports[i]}
|
||||
if (exports[i+1] == key) {key = exports[i]
|
||||
if (exports[i+2]) {var cb = plugin.onexport[exports[i+2]], res;
|
||||
value = typeof cb == "function" && ((res = cb(event, plugin, plugin.msg, value, key, index)) != undefined) && res || value;
|
||||
}
|
||||
key && can.Import(event, value, key)
|
||||
}
|
||||
}
|
||||
plugin[key] && plugin[key].target && plugin[key].Import(event, value, key, index)
|
||||
key && plugin[key] && plugin[key].target && plugin[key].Import(event, value, key, index)
|
||||
},
|
||||
Check: function(event, target, cb) {
|
||||
plugin.page.Select(can, option, ".args", function(item, index, list) {
|
||||
@ -134,18 +156,25 @@ var can = Volcanos("chat", {
|
||||
history.push(plugin.page.Select(can, option, ".args", function(item, index, list) {
|
||||
return {target: item, value: item.value}
|
||||
}))
|
||||
can.Export(event, 1, "ncmd")
|
||||
|
||||
for (var i = args.length-1; i >= 0; i--) {if (args[i] == "") {args = args.slice(0, i)} else {break}}
|
||||
show && plugin.Timer(1000, function() {show && plugin.user.toast(kit.Format(args||["running..."]), meta.name, -1)});
|
||||
show && plugin.Timer(1000, function() {show && plugin.user.toast(can.base.Format(args||["running..."]), meta.name, -1)});
|
||||
run(event, args, function(msg) {if (silent) {return typeof cb == "function" && cb(msg)}
|
||||
plugin.msg = msg
|
||||
plugin.Show(feature.display || "table", msg, cb)
|
||||
show = false, plugin.user.toast();
|
||||
})
|
||||
},
|
||||
Show: function(type, msg, cb) {msg._plugin_name = name;
|
||||
Show: function(type, msg, cb) {plugin.msg = msg, msg._plugin_name = name;
|
||||
return plugin[type] = can.Output(plugin, type, msg, cb, output, option)
|
||||
},
|
||||
}, Config.libs.concat(["plugin/"+(meta.type||"state")]), function(plugin) {
|
||||
Clone: function(event) {meta.nick = meta.name + can.ID()
|
||||
can.Plugin(can, meta.nick, meta, run,
|
||||
can.page.AppendField(can, field.parentNode, "item "+meta.group+" "+meta.nick, meta))
|
||||
},
|
||||
Delete: function(event) {field.parentNode.removeChild(field)},
|
||||
}, Config.libs.concat(["plugin/"+(meta.type||"state")]), function(plugin) {plugin.Conf(meta);
|
||||
can.core.Next(JSON.parse(meta.inputs||"[]"), plugin.Append)
|
||||
}, meta)
|
||||
return plugin.target = field, field.Plugin = plugin
|
||||
@ -153,7 +182,9 @@ var can = Volcanos("chat", {
|
||||
Inputs: shy("构造控件", function(can, item, type, name, value, cb, option) {
|
||||
var input = Volcanos(name, {type: "local", item: item,
|
||||
Select: function(event) {can.Select(event, input.target, true)},
|
||||
Import: function(event, value, key, index) {input.target.value = value;
|
||||
Import: function(event, value, key, index) {var cb = input.onimport[item.imports];
|
||||
value = typeof cb == "function" && cb(event, input, value, key, input.target) || value
|
||||
input.target.value = value;
|
||||
item.action == "auto"? can.Runs(event): can.Check(event, input.target);
|
||||
},
|
||||
run: function(event, cmd, cb, silent) {
|
||||
@ -172,7 +203,7 @@ var can = Volcanos("chat", {
|
||||
if (type == "inner" && (!msg.result || msg.result.length == 0)) {
|
||||
type = "table"
|
||||
}
|
||||
var output = Volcanos(type, {type: "local",
|
||||
var output = Volcanos(type, {_type: "local", msg: msg,
|
||||
Export: function(event, value, key, index) {can.Report(event, value, key, index)},
|
||||
run: function(event, cmd, cb, silent) {
|
||||
(output[cmd[1]] || can[cmd[1]] || can.Run)(event, cmd, cb, silent);
|
||||
@ -185,9 +216,8 @@ var can = Volcanos("chat", {
|
||||
}, Config.libs.concat(Config.list), function(can) {
|
||||
if (ctx.Search("feature") != "") {
|
||||
can[Config.main] = can.Page(can, Config.main, Config, function(chat) {
|
||||
// can.user.carte = page.carte.Pane.Show;
|
||||
// can.user.toast = page.toast.Pane.Show;
|
||||
chat.River.Import(event||{}, "shy", "username")
|
||||
chat.Login.Import(event||{}, "", "login")
|
||||
can.user.Search(can, "layout") && chat.Login.Export(event||{}, can.user.Search(can, "layout"), "layout")
|
||||
}, document.body)
|
||||
}
|
||||
})
|
||||
|
@ -2,6 +2,7 @@ Volcanos("base", {help: "基础模块",
|
||||
isNone: function(c) {return c === undefined || c === null},
|
||||
isSpace: function(c) {return c == " " || c == "Enter"},
|
||||
|
||||
Int: function(value) {return parseInt(value)||0},
|
||||
Duration: function(n) {var res = "", h = 0;
|
||||
h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000;
|
||||
h = parseInt(n/60000), h > 0 && (res += h+"m"), n = n % 60000;
|
||||
|
108
lib/page.js
108
lib/page.js
@ -87,18 +87,24 @@ Volcanos("page", {help: "网页模块",
|
||||
item.list = list[0].slice(1).map(function(value) {
|
||||
return {type: "option", value: value, inner: value};
|
||||
})
|
||||
data.className = list[0][0] || ""
|
||||
data.className = list[0][0] || "";
|
||||
|
||||
} else if (item.input) {var list = can.core.List(item.input);
|
||||
type = "input", name = name || list[0];
|
||||
type = "input", name = name || list[0] || "";
|
||||
data.name = data.name || name;
|
||||
data.className = data.className || data.name;
|
||||
data.placeholder = data.placeholder || data.name;
|
||||
data.title = data.title || data.placeholder;
|
||||
|
||||
data.onkeydown = function(event) {
|
||||
typeof list[1] == "function" && list[1](event);
|
||||
}
|
||||
data.onkeyup = function(event) {
|
||||
typeof list[2] == "function" && list[2](event);
|
||||
}
|
||||
} else if (item.row) {type = "tr"
|
||||
item.list = item.row.map(function(text) {return {text: [text, item.sub||"td"]}})
|
||||
|
||||
} else if (item.row) {type = "tr";
|
||||
item.list = item.row.map(function(text) {return {text: [text, item.sub||"td"]}});
|
||||
}
|
||||
|
||||
|
||||
@ -117,16 +123,16 @@ Volcanos("page", {help: "网页模块",
|
||||
|
||||
AppendItem: shy("添加插件", function(can, target, list, click, cb, cbs) {
|
||||
can.core.List(list, function(line, index) {
|
||||
var item = can.page.Append(can, target, [{view: ["item "+line.key], list: [{text: [line.nick||line.key]}], click: function(event) {
|
||||
var item = can.page.Append(can, target, [{view: ["item k"+line.key], list: [{text: [line.nick||line.key]}], click: function(event) {
|
||||
typeof cb == "function" && cb(event, line, item)
|
||||
can.page.Select(can, target, "div.item.select", function(item) {
|
||||
can.page.ClassList.del(can, item, "select")
|
||||
})
|
||||
can.page.ClassList.add(can, item, "select")
|
||||
}, data: {oncontextmenu: function(event) {
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, value, meta) {var cb = meta[value];
|
||||
typeof cb == "function"? cb(event, can, line, value, item, target):
|
||||
can.run(event, [typeof cb == "string"? cb: value, item], null, true)
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, key, meta) {var cb = meta[key];
|
||||
typeof cb == "function"? cb(event, can, line, line.key, key, item):
|
||||
can.run(event, [typeof cb == "string"? cb: key, item], null, true)
|
||||
}))
|
||||
|
||||
event.stopPropagation()
|
||||
@ -136,15 +142,16 @@ Volcanos("page", {help: "网页模块",
|
||||
|
||||
if (click === false) {return}
|
||||
if (click != "") {
|
||||
var list = can.page.Select(can, target, "div.item."+click)
|
||||
var list = can.page.Select(can, target, "div.item.k"+click)
|
||||
if (list.length>0) {list[0].click(); return}
|
||||
}
|
||||
can.page.Select(can, target, "div.item")[0].click()
|
||||
}),
|
||||
AppendField: shy("添加插件", function(can, target, type, item) {
|
||||
var dataset = {}; item && item.name && (dataset.names = item.name); item && item.group && (dataset.group = item.group);
|
||||
var field = can.page.Append(can, target, [{view: [type, "fieldset"], list: [
|
||||
{text: [item.name+item.help, "legend"]},
|
||||
{view: ["option", "form"], list: [{type: "input", style: {display: "none"}}]},
|
||||
{text: [(item.nick||item.name||"")+"("+(item.help||"")+")", "legend"]},
|
||||
{view: ["option", "form"], dataset: dataset, list: [{type: "input", style: {display: "none"}}]},
|
||||
{view: ["action"]},
|
||||
{view: ["output"]},
|
||||
]}]).first;
|
||||
@ -188,5 +195,84 @@ Volcanos("page", {help: "网页模块",
|
||||
text:'<a href="'+URL.createObjectURL(new Blob([value]))+'" target="_blank" download="'+name+'">'+name+'</a>',
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
DelText: function(target, start, count) {
|
||||
target.value = target.value.substring(0, start)+target.value.substring(start+(count||target.value.length), target.value.length)
|
||||
target.setSelectionRange(start, start)
|
||||
},
|
||||
oninput: function(event, can, local) {var target = event.target
|
||||
if (event.ctrlKey) {
|
||||
if (typeof local == "function" && local(event)) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
return true
|
||||
}
|
||||
|
||||
var his = target.History || []
|
||||
var pos = target.Current || -1
|
||||
switch (event.key) {
|
||||
case "p":
|
||||
pos = (pos-1+his.length+1) % (his.length+1)
|
||||
target.value = pos < his.length? his[pos]: ""
|
||||
target.Current = pos
|
||||
break
|
||||
case "n":
|
||||
pos = (pos+1) % (his.length+1)
|
||||
target.value = pos < his.length? his[pos]: ""
|
||||
target.Current = pos
|
||||
break
|
||||
case "a":
|
||||
case "e":
|
||||
case "f":
|
||||
case "b":
|
||||
break
|
||||
case "h":
|
||||
can.page.DelText(target, target.selectionStart-1, target.selectionStart)
|
||||
break
|
||||
case "d":
|
||||
can.page.DelText(target, 0, target.selectionStart)
|
||||
break
|
||||
case "k":
|
||||
can.page.DelText(target, target.selectionStart)
|
||||
break
|
||||
case "u":
|
||||
can.page.DelText(target, 0, target.selectionEnd)
|
||||
break
|
||||
case "w":
|
||||
var start = target.selectionStart-2
|
||||
var end = target.selectionEnd-1
|
||||
for (var i = start; i >= 0; i--) {
|
||||
if (target.value[end] == " " && target.value[i] != " ") {
|
||||
break
|
||||
}
|
||||
if (target.value[end] != " " && target.value[i] == " ") {
|
||||
break
|
||||
}
|
||||
}
|
||||
can.page.DelText(target, i+1, end-i)
|
||||
break
|
||||
default:
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
switch (event.key) {
|
||||
case " ":
|
||||
event.stopPropagation()
|
||||
return true
|
||||
default:
|
||||
if (target.value.endsWith("j") && event.key == "k") {
|
||||
can.page.DelText(target, target.selectionStart-1, 2)
|
||||
target.blur()
|
||||
break
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
return true
|
||||
},
|
||||
})
|
||||
|
||||
|
31
order.js
31
order.js
@ -1,13 +1,14 @@
|
||||
var Config = {
|
||||
main: "chat", list: ["page/chat",
|
||||
"pane/Toast", "pane/Carte", "pane/Debug", "pane/Login",
|
||||
"pane/Toast", "pane/Carte", "pane/Debug",
|
||||
"pane/Tutor", "pane/Favor", "pane/Login",
|
||||
|
||||
"pane/Header",
|
||||
"pane/Ocean", "pane/River", "pane/Storm", "pane/Steam",
|
||||
"pane/Target", "pane/Source", "pane/Action",
|
||||
"pane/Footer",
|
||||
|
||||
"plugin/state", "plugin/input", "plugin/table", "plugin/inner",
|
||||
"plugin/state", "plugin/input", "plugin/table", "plugin/inner", "plugin/media",
|
||||
],
|
||||
libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"],
|
||||
pane: [
|
||||
@ -15,19 +16,31 @@ var Config = {
|
||||
{group: "index", name: "Carte", pos: "float"},
|
||||
{group: "index", name: "Debug", pos: "float"},
|
||||
{group: "index", name: "Login", pos: "float"},
|
||||
{group: "index", name: "Favor", pos: "float"},
|
||||
{group: "index", name: "Tutor", pos: "float"},
|
||||
|
||||
{group: "index", name: "Header", pos: "head"},
|
||||
{group: "index", name: "Ocean", pos: "float"},
|
||||
{group: "index", name: "Header", pos: "head",
|
||||
title: "github.com/shylinux/context",
|
||||
state: ["time", "user", "link"],
|
||||
},
|
||||
{group: "index", name: "Ocean", pos: "float", def_name: "meet"},
|
||||
{group: "index", name: "River", pos: "left"},
|
||||
{group: "index", name: "Storm", pos: "right"},
|
||||
{group: "index", name: "Steam", pos: "float"},
|
||||
{group: "index", name: "Steam", pos: "float", def_name: "miss"},
|
||||
|
||||
{group: "index", name: "Target", pos: "top"},
|
||||
{group: "index", name: "Source", pos: "center"},
|
||||
{group: "index", name: "Action", pos: "bottom"},
|
||||
{group: "index", name: "Footer", pos: "foot"},
|
||||
],
|
||||
layout: {
|
||||
border: 4,
|
||||
{group: "index", name: "Footer", pos: "foot",
|
||||
title: '<a href="mailto:shylinux@163.com">shylinux@163.com</a>',
|
||||
state: ["ntxt", "ncmd"],
|
||||
},
|
||||
|
||||
], layout: {list: ["工作", "办公", "聊天"], size: {
|
||||
"工作": {head: 30, foot: 30, left: 0, right: 100, bottom: -1, center: 0, top: 0},
|
||||
"办公": {head: 30, foot: 30, left: 100, right: 100, bottom: -1, center: 0, top: 0},
|
||||
"聊天": {head: 30, foot: 30, left: 100, right: 100, bottom: 300, center: 40, top: -2},
|
||||
"全屏": {head: 0, foot: 0, left: 0, right: 0, bottom: -1, center: 0, top: 0},
|
||||
}, border: 4,
|
||||
},
|
||||
}
|
||||
|
20
page/chat.js
20
page/chat.js
@ -3,9 +3,26 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
window.onresize = function(event) {
|
||||
can.onlayout["刷新"](event, can, conf, null, body)
|
||||
}
|
||||
},
|
||||
layout: function(event, can, value, key, body) {var conf = can.Conf()
|
||||
can.onlayout["刷新"](event, can, conf, conf.layout.size[value], body)
|
||||
}
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onaction", {help: "组件交互", list: [],
|
||||
onkeydown: function(event, can) {
|
||||
switch (event.key) {
|
||||
case " ":
|
||||
if (can.Favor) {
|
||||
can.page.Select(can, can.Favor.Show(400, 200), "input.cmd", function(item) {
|
||||
item.focus()
|
||||
})
|
||||
}
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
}
|
||||
},
|
||||
})
|
||||
Volcanos("onlayout", {help: "组件布局", list: ["刷新"],
|
||||
"刷新": function(event, can, conf, layout, body) {layout = layout || {};
|
||||
var height = body.clientHeight-conf.layout.border;
|
||||
@ -35,7 +52,6 @@ Volcanos("onlayout", {help: "组件布局", list: ["刷新"],
|
||||
height -= layout.top==0? height: can.center.target.offsetHeight+can.bottom.target.offsetHeight
|
||||
can.top.Size(event, width, height)
|
||||
},
|
||||
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["刷新", "登出"],
|
||||
"刷新": function(event, can, conf, key, body) {
|
||||
|
@ -1,75 +1,81 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
init: function(event, can, msg, key, output) {output.innerHTML = "";
|
||||
init: function(event, can, msg, cmd, output) {output.innerHTML = "";
|
||||
msg.Table(function(item, index) {if (!item.name) {return}
|
||||
can[item.name] = can.Plugin(can, item.name, item, function(event, cmds, cbs) {
|
||||
can.run(event, [item.river, item.storm, item.action].concat(cmds), cbs)
|
||||
}, can.page.AppendField(can, output, "item "+item.group+" "+item.name, item))
|
||||
})
|
||||
},
|
||||
size: function(event, can, value, key, output) {
|
||||
size: function(event, can, value, cmd, output) {
|
||||
},
|
||||
river: function(event, can, value, key, output) {
|
||||
river: function(event, can, value, cmd, output) {
|
||||
if (value == "update") {return}
|
||||
can.Conf("temp_river", value)
|
||||
},
|
||||
storm: function(event, can, value, key, output) {
|
||||
storm: function(event, can, value, cmd, output) {
|
||||
can.Cache(can.Conf("river")+"."+can.Conf("storm"), output, "some");
|
||||
|
||||
can.Conf("river", can.Conf("temp_river"))
|
||||
can.Conf("storm", value)
|
||||
if (!can.Cache(can.Conf("river")+"."+can.Conf("storm"), output)) {
|
||||
can.run(event, [can.Conf("river"), can.Conf("storm")], function(msg) {
|
||||
can.onimport.init(event, can, msg, key, output)
|
||||
can.onimport.init(event, can, msg, cmd, output)
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: [],
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
|
||||
"返回": function(event, can, msg, value, target) {
|
||||
can.run(event, ["", "Last"])
|
||||
pod: function(event, can, value, cmd, output) {
|
||||
can.page.Select(can, can.action, "input."+cmd, function(item) {
|
||||
item.value = value
|
||||
})
|
||||
},
|
||||
"清空": function(event, can, msg, value, target) {
|
||||
can.target.innerHTML = "";
|
||||
you: function(event, can, value, cmd, output) {
|
||||
can.page.Select(can, can.action, "input."+cmd, function(item) {
|
||||
item.value = value
|
||||
})
|
||||
},
|
||||
"复制": function(event, can, msg, value, target) {
|
||||
var list = can.onexport.Format(can, msg, "data");
|
||||
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
|
||||
layout: function(event, can, value, cmd, output) {can.layout = value;
|
||||
can.page.Select(can, can.action, "select.layout", function(item) {
|
||||
item.value = value
|
||||
})
|
||||
},
|
||||
"下载": function(event, can, msg, value, target) {
|
||||
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
|
||||
can.page.Download(can, list[0]+list[1], list[2]);
|
||||
favor: function(event, can, msg, cmd, output) {
|
||||
var p = can[msg.detail[0]];
|
||||
p.Select && p.Select(event, null, true) && (msg._hand = true)
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
|
||||
"选择": "select",
|
||||
"删除": "delete",
|
||||
"修改": function(event, can, msg, value, index, key, td) {
|
||||
var text = td.innerHTML;
|
||||
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
||||
if (event.key != "Enter") {return}
|
||||
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
|
||||
td.innerHTML = event.target.value;
|
||||
can.user.toast("修改成功")
|
||||
}, true)
|
||||
}}}])
|
||||
Volcanos("onaction", {help: "组件交互", list: [["layout", "工作", "办公", "聊天"], "清屏", "刷新", "串行", "并行",
|
||||
{input: "pod"}, {input: "you"}],
|
||||
"工作": function(event, can, msg, cmd, output) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
"复制": function(event, can, msg, value, index, key, td) {
|
||||
can.user.toast(can.page.CopyText(can, td.innerHTML), "复制成功")
|
||||
"办公": function(event, can, msg, cmd, output) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
"下载": function(event, can, msg, value, index, key, td) {
|
||||
can.page.Download(can, key, td.innerHTML);
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: [],
|
||||
Format: function(can, msg, name) {
|
||||
var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) {
|
||||
return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",")
|
||||
}).join("\n");
|
||||
|
||||
!txt && (ext = ".txt", txt = msg.result && msg.result.join("") || "");
|
||||
return [name, ext, txt]
|
||||
"聊天": function(event, can, msg, cmd, output) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
"清屏": function(event, can, msg, cmd, output) {
|
||||
can.page.Select(can, output, "fieldset.item>div.output", function(item) {
|
||||
item.innerHTML = "";
|
||||
})
|
||||
},
|
||||
"刷新": function(event, can, msg, cmd, output) {
|
||||
can.page.Select(can, output, "fieldset.item>div.output", function(item) {
|
||||
item.innerHTML = "";
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: [["layout", "工作", "办公", "聊天"]],
|
||||
"工作": function(event, can, msg, cmd, target) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
"办公": function(event, can, msg, cmd, target) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
"聊天": function(event, can, msg, cmd, target) {
|
||||
can.Export(event, cmd, "layout")
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
@ -1,23 +1,30 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
})
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
can.user.carte = function(event, cb, src) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.Append(can, output, can.core.List(cb.list, function(item) {
|
||||
return {view: ["item"], list: [typeof item == "string"? {text: [item], click: function(event) {
|
||||
typeof cb == "function" && cb(event, item, cb.meta)
|
||||
}}: {select: [item, function(event) {
|
||||
typeof cb == "function" && cb(event, event.target.value, cb.meta)
|
||||
}], value: src[item[0]]||""}]}
|
||||
}))
|
||||
can.page.Select(can, output, "select", function(item) {
|
||||
item.value = src[item.className]||""
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
@ -1,5 +1,10 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
}})
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
},
|
||||
favor: function(event, can, value, cmd, output) {
|
||||
console.log(can.base.Time(), value)
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
47
pane/Favor.js
Normal file
47
pane/Favor.js
Normal file
@ -0,0 +1,47 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
can.page.Append(can, option, [{input: ["cmd", function(event) {
|
||||
function run(cmd) {
|
||||
var msg = can.Event(event);
|
||||
msg.detail = [cmd]
|
||||
msg._time = can.base.Time()
|
||||
msg._source = can
|
||||
can.Export(event, msg, "favor")
|
||||
if (msg._hand) {
|
||||
event.target.value = ""
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
||||
if (can.page.oninput(event, can, function(event) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
return true
|
||||
})) {return}
|
||||
|
||||
switch (event.key) {
|
||||
case "Enter":
|
||||
var msg = run(event.target.value.trim())
|
||||
output.innerHTML = msg.Result()
|
||||
break
|
||||
case "Escape":
|
||||
can.Hide()
|
||||
break
|
||||
}
|
||||
}, function(event) {
|
||||
if (event.ctrlKey) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
return true
|
||||
}
|
||||
|
||||
}]}])
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
||||
|
@ -1,23 +1,22 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {output.innerHTML = "";
|
||||
conf.title && can.page.Append(can, output, [{view: "title", list: [{text: conf.title, className: "title"}]}])
|
||||
can.ui = can.page.Append(can, output, [{view: "state", list: can.core.List(conf.state, function(item) {
|
||||
return {text: conf[item]||"", className: item, click: function(event) {var cb = can.onexport[item];
|
||||
typeof cb == "function" && cb(event, can, item, item, output)
|
||||
}};
|
||||
})}])
|
||||
},
|
||||
email: function(event, can, value, cmd, output) {
|
||||
can.ui[cmd].innerHTML = value
|
||||
},
|
||||
ntxt: function(event, can, value, cmd, output) {var state = can.Conf(cmd);
|
||||
can.ui[cmd].innerHTML = cmd+":"+ can.Conf(cmd, can.base.Int(value)+can.base.Int(state))
|
||||
},
|
||||
ncmd: function(event, can, value, cmd, output) {var state = can.Conf(cmd);
|
||||
can.ui[cmd].innerHTML = cmd+":"+ can.Conf(cmd, can.base.Int(value)+can.base.Int(state))
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
@ -1,25 +1,51 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {output.innerHTML = "";
|
||||
conf.title && can.page.Append(can, output, [{view: "title",
|
||||
list: [{text: conf.title, className: "title"}], click: function(event) {can.onexport.title(event, can)}}])
|
||||
can.ui = can.page.Append(can, output, [{view: "state", list: can.core.List(conf.state, function(item) {
|
||||
return {text: conf[item]||"", className: item, click: function(event) {var cb = can.onexport[item];
|
||||
typeof cb == "function" && cb(event, can, item, item, output)
|
||||
}};
|
||||
})}])
|
||||
can.timer = can.Timer({interval: 1000, length: -1}, function() {
|
||||
can.ui.time.innerHTML = can.base.Time().split(" ")[1]
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
},
|
||||
title: function(event, can, value, cmd, output) {
|
||||
can.ui[cmd].innerHTML = value
|
||||
},
|
||||
username: function(event, can, value, cmd, output) {
|
||||
can.ui["user"].innerHTML = value
|
||||
},
|
||||
time: function(event, can, value, cmd, output) {
|
||||
can.ui[cmd].innerHTML = value
|
||||
},
|
||||
link: function(event, can, value, cmd, output) {
|
||||
can.ui[cmd].innerHTML = value
|
||||
},
|
||||
river: function(event, can, value, cmd, output) {if (value == "update") {return}
|
||||
can.Conf("river", value)
|
||||
},
|
||||
storm: function(event, can, value, cmd, output) {if (value == "update") {return}
|
||||
can.Conf("storm", value)
|
||||
},
|
||||
layout: function(event, can, value, cmd, output) {if (value == "update") {return}
|
||||
can.Conf("layout", value)
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: [],
|
||||
title: function(event, can, value, cmd, output) {
|
||||
can.user.Search(can, {
|
||||
river: can.Conf("river"),
|
||||
storm: can.Conf("storm"),
|
||||
layout: can.Conf("layout"),
|
||||
})
|
||||
},
|
||||
link: function(event, can, value, cmd, output) {
|
||||
can.ui[cmd].innerHTML = value
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -1,23 +1,13 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
login: function(event, can, value, cmd, output) {
|
||||
if (!can.user.Cookie("sessid")) {can.Show(); return}
|
||||
|
||||
can.run(event||{}, [], function(msg) {
|
||||
msg.nickname && msg.nickname.length > 0?
|
||||
can.Export(event, msg.nickname[0], "username"): can.Show()
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
@ -1,7 +1,7 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, output, action, option, field) {output.innerHTML = "";
|
||||
_init: function(can, conf, output, action, option, field) {output.innerHTML = "";
|
||||
var ui = can.page.Append(can, field, [{view: ["create"], list: [
|
||||
{input: ["name"], title: "群聊名称"},
|
||||
{input: "name", value: can.Conf("def_name"), title: "群聊名称"},
|
||||
{button: ["创建群聊", function(event) {
|
||||
if (!ui.name.value) {ui.name.focus(); can.user.toast("请输入群名"); return}
|
||||
|
||||
|
@ -16,6 +16,14 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
})
|
||||
}
|
||||
},
|
||||
favor: function(event, can, msg, cmd, output) {
|
||||
can.page.Select(can, output, "div.item>span", function(item) {
|
||||
if (item.innerText == msg.detail[0]) {
|
||||
msg.Echo("storm", msg.detail[0])
|
||||
item.click(), msg._hand = true;
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
|
||||
"创建": function(event, can, meta, key, output) {
|
||||
|
@ -1,23 +1,7 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
@ -1,8 +1,8 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, output, action, option, field) {output.innerHTML = "";
|
||||
_init: function(can, conf, output, action, option, field) {output.innerHTML = "";
|
||||
var device = can.page.Append(can, field, [{"view": ["device", "table"]}]).last
|
||||
var ui = can.page.Append(can, field, [{view: ["create"], list: [
|
||||
{title: "应用名称", input: ["name"]}, {button: ["创建应用", function(event) {
|
||||
{input: "name", value: can.Conf("def_name"), title: "应用名称"}, {button: ["创建应用", function(event) {
|
||||
if (!ui.name.value) {ui.name.focus(); can.user.toast("请输入群名"); return}
|
||||
|
||||
var list = []
|
||||
@ -21,7 +21,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
can.device = device
|
||||
can.ui = ui
|
||||
},
|
||||
init: function(event, can, msg, key, output) {output.innerHTML = ""; can.Show();
|
||||
init: function(event, can, msg, key, output) {output.innerHTML = ""; can.Show(-100, -100);
|
||||
var table = can.page.Append(can, output, "table")
|
||||
|
||||
can.page.Append(can, table, [{text: ["1. 选择用户节点 ->", "caption"]}])
|
||||
@ -32,7 +32,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
|
||||
var node = msg.node[index];
|
||||
can.run(event, [can.Conf("river"), msg.user[index], node], function(com) {
|
||||
can.page.Append(can, can.device, [{text: ["2. 选择模块命令 ->", "caption"]}])
|
||||
can.page.Appends(can, can.device, [{text: ["2. 选择模块命令 ->", "caption"]}])
|
||||
can.page.AppendTable(can, can.device, com, ["key", "index", "name", "help"], function(event, value, key, index, tr, td) {
|
||||
|
||||
var last = can.page.Append(can, can.ui.list, [{
|
||||
@ -43,7 +43,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
|
||||
}, function(event, value, key, index, tr, td) {
|
||||
can.user.carte(event, shy(can.ondetail, can.ondetail.list, function(event, key, meta) {
|
||||
meta[key](event, can, msg, key, td)
|
||||
meta[key](event, can, com, value, key, index, td)
|
||||
}))
|
||||
})
|
||||
})
|
||||
@ -79,8 +79,13 @@ Volcanos("onchoice", {help: "组件菜单", list: ["关闭", "刷新"],
|
||||
can.onaction[key](event, can, key, can.output)
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["共享"],
|
||||
"共享": function(event, can, line, value, target) {
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["创建", "删除", "共享"],
|
||||
"创建": function(event, can, msg, value, key, index, td) {
|
||||
can.run(event, [can.Conf("river"), "spawn", msg.key[index]], function(msg) {
|
||||
can.Hide(), can.Export(event, "update", "storm");
|
||||
})
|
||||
},
|
||||
"共享": function(event, can, msg, value, key, index, td) {
|
||||
can.user.toast(can.user.Share(can, {storm: line.key}), "共享链接", 10000)
|
||||
},
|
||||
})
|
||||
|
@ -1,65 +1,63 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
init: function(event, can, msg, key, output) {output.innerHTML = "";
|
||||
init: function(event, can, msg, cmd, output) {output.innerHTML = "";
|
||||
can.page.AppendItem(can, output, msg.Table(), can.user.Search(can, "storm"), function(event, line, item) {
|
||||
can.Export(event, line.key, "storm")
|
||||
})
|
||||
},
|
||||
river: function(event, can, value, key, output) {
|
||||
river: function(event, can, value, cmd, output) {
|
||||
if (value == "update") {return}
|
||||
|
||||
can.run(event, [value], function(msg) {
|
||||
can.onimport.init(event, can, msg, key, output)
|
||||
can.run(event, [can.Conf("river", value)], function(msg) {
|
||||
can.onimport.init(event, can, msg, cmd, output)
|
||||
})
|
||||
},
|
||||
storm: function(event, can, value, cmd, output) {
|
||||
if (value == "update") {
|
||||
can.run(event, [can.Conf("river")], function(msg) {
|
||||
can.onimport.init(event, can, msg, cmd, output)
|
||||
})
|
||||
}
|
||||
},
|
||||
favor: function(event, can, msg, cmd, output) {
|
||||
can.page.Select(can, output, "div.item.k"+msg.detail[0], function(item) {
|
||||
msg.Echo("storm", msg.detail[0])
|
||||
item.click(), msg._hand = true;
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
|
||||
"创建": function(event, can, meta, key, output) {
|
||||
"创建": function(event, can, meta, cmd, output) {
|
||||
can.Export(event, "create", "steam")
|
||||
},
|
||||
"刷新": function(event, can, meta, key, output) {
|
||||
can.run(event, [], function(msg) {
|
||||
can.onimport.init(event, can, msg, key, output)
|
||||
"刷新": function(event, can, meta, cmd, output) {
|
||||
can.run(event, [can.Conf("river")], function(msg) {
|
||||
can.onimport.init(event, can, msg, cmd, output)
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
|
||||
"返回": function(event, can, msg, key, target) {
|
||||
"返回": function(event, can, msg, cmd, target) {
|
||||
can.run(event, ["", "Last"])
|
||||
},
|
||||
"清空": function(event, can, msg, key, target) {
|
||||
"清空": function(event, can, msg, cmd, target) {
|
||||
can.target.innerHTML = "";
|
||||
},
|
||||
"复制": function(event, can, msg, key, target) {
|
||||
"复制": function(event, can, msg, cmd, target) {
|
||||
var list = can.onexport.Format(can, msg, "data");
|
||||
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, key, target) {
|
||||
"下载": function(event, can, msg, cmd, target) {
|
||||
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
|
||||
can.page.Download(can, list[0]+list[1], list[2]);
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
|
||||
"选择": "select",
|
||||
"删除": "delete",
|
||||
"修改": function(event, can, msg, value, index, key, td) {
|
||||
var text = td.innerHTML;
|
||||
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
||||
if (event.key != "Enter") {return}
|
||||
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
|
||||
td.innerHTML = event.target.value;
|
||||
can.user.toast("修改成功")
|
||||
}, true)
|
||||
}}}])
|
||||
},
|
||||
"复制": function(event, can, msg, value, index, key, target) {
|
||||
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, value, index, key, target) {
|
||||
can.page.Download(can, key, target.innerHTML);
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["保存", "恢复", "删除"],
|
||||
"删除": function(event, can, line, value, cmd, item) {
|
||||
can.run(event, [can.Conf("river"), "delete", value], function(msg) {
|
||||
can.run(event, [can.Conf("river")], function(msg) {
|
||||
can.onimport.init(event, can, msg, cmd, can.output)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,23 +1,7 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output, action, option, field) {
|
||||
can.user.carte = function(event, cb) {if (!cb || !cb.list || cb.list.length == 0) {return}
|
||||
output.innerHTML = "", can.page.AppendItem(can, output, can.core.List(cb.list, function(item) {
|
||||
return {key: item};
|
||||
}), false, function(event, line, item) {
|
||||
typeof cb == "function" && cb(event, line.key, cb.meta)
|
||||
})
|
||||
|
||||
var pos = {display: "block", left: event.x, top: event.y}
|
||||
if (document.body.clientWidth - event.x < 60) {
|
||||
var pos = {display: "block", right: event.x, top: event.y}
|
||||
}
|
||||
pos.left += "px"; pos.top += "px";
|
||||
can.page.Modify(can, field, {style: pos})
|
||||
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
can.Show()
|
||||
}
|
||||
}})
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
@ -1,31 +1,34 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, output) {
|
||||
can.user.toast = function(text, title, duration, list) {if (!text) {return can.Hide()}
|
||||
text = typeof text == "object"? text: {list: list, text: text, title: title||"", duration: duration||3000}
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output) {
|
||||
can.user.toast = function(text, title, duration, list) {if (!text) {return can.Hide()}
|
||||
text = typeof text == "object"? text: {list: list, text: text, title: title||"", duration: duration||3000}
|
||||
|
||||
var list = [{text: [text.title||"", "div", "title"]},
|
||||
{text: [text.text||"", "div", "content"]},
|
||||
{view: ["form"], list: text.list||[{type: "button", inner: "cancel", click: function() {
|
||||
timer.stop = true
|
||||
}}]},
|
||||
{text: [text.tick||"", "div", "tick"]},
|
||||
]
|
||||
var list = [{text: [text.title||"", "div", "title"]},
|
||||
{text: [text.text||"", "div", "content"]},
|
||||
{view: ["form"], list: text.list||[{type: "button", inner: "cancel", click: function() {
|
||||
timer.stop = true
|
||||
}}]},
|
||||
{text: [text.tick||"", "div", "tick"]},
|
||||
]
|
||||
|
||||
var toast = can.page.Appends(can, output, list)
|
||||
var width = text.width||text.text.length*10+10
|
||||
width = width>400?400:width
|
||||
width = width<100?100:width
|
||||
can.Show(width, text.height||80)
|
||||
var toast = can.page.Appends(can, output, list)
|
||||
var width = text.width||text.text.length*10+100
|
||||
width = width>400?400:width
|
||||
can.Show(width, text.height||80)
|
||||
|
||||
var begin = can.base.Time().split(" ")[1]
|
||||
var timer = can.Timer({value: 1000, length: text.duration > 0? text.duration/1000: text.duration}, function(t, i) {
|
||||
console.log(t, i)
|
||||
if (i > 10000) {return true}
|
||||
toast.tick.innerHTML = can.base.Duration(i*t) + " after " + begin
|
||||
}, function() {
|
||||
can.Hide()
|
||||
})
|
||||
}
|
||||
}})
|
||||
var begin = can.base.Time().split(" ")[1]
|
||||
var timer = can.Timer({value: 1000, length: text.duration > 0? text.duration/1000: text.duration}, function(t, i) {
|
||||
if (i < 10) {return}
|
||||
if (i > 10000) {return true}
|
||||
toast.tick.innerHTML = can.base.Duration(i*t) + " after " + begin
|
||||
console.log(t, i)
|
||||
}, function() {
|
||||
can.Hide()
|
||||
})
|
||||
return timer
|
||||
}
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
|
12
pane/Tutor.js
Normal file
12
pane/Tutor.js
Normal file
@ -0,0 +1,12 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output, action, option, field) {
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
||||
|
||||
|
@ -1,64 +1,59 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
init: function(can, msg, cb, output, option) {output.innerHTML = "";
|
||||
output.innerHTML = msg.Result()
|
||||
output.onclick = function(event) {
|
||||
switch (event.target.tagName) {
|
||||
case "text":
|
||||
alert(event.target.innerHTML)
|
||||
break
|
||||
case "rect":
|
||||
break
|
||||
init: function(can, msg, cb, output, option) {output.innerHTML = msg.Result();
|
||||
can.page.Select(can, output, "svg", function(svg) {
|
||||
svg.onclick = function(event) {var item = event.target;
|
||||
switch (event.target.tagName) {
|
||||
case "text":
|
||||
can.user.toast(can.page.CopyText(can, item.innerHTML), "复制成功")
|
||||
break
|
||||
case "rect":
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
svg.oncontextmenu = function(event) {var item = event.target;
|
||||
switch (event.target.tagName) {
|
||||
case "text":
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, key, meta) {cb = meta[key];
|
||||
typeof cb == "function"? cb(event, can, msg, key, item, svg):
|
||||
can.run(event, [typeof cb == "string"? cb: key, item], null, true)
|
||||
}))
|
||||
break
|
||||
case "rect":
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, key, meta) {cb = meta[key];
|
||||
typeof cb == "function"? cb(event, can, msg, key, item, svg):
|
||||
can.run(event, [typeof cb == "string"? cb: key, item], null, true)
|
||||
}))
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: [],
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
|
||||
"返回": function(event, can, msg, value, target) {
|
||||
"返回": function(event, can, msg, key, target) {
|
||||
can.run(event, ["", "Last"])
|
||||
},
|
||||
"清空": function(event, can, msg, value, target) {
|
||||
"清空": function(event, can, msg, key, target) {
|
||||
can.target.innerHTML = "";
|
||||
},
|
||||
"复制": function(event, can, msg, value, target) {
|
||||
"复制": function(event, can, msg, key, target) {
|
||||
var list = can.onexport.Format(can, msg, "data");
|
||||
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, value, target) {
|
||||
"下载": function(event, can, msg, key, target) {
|
||||
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
|
||||
can.page.Download(can, list[0]+list[1], list[2]);
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "复制"],
|
||||
"选择": "select",
|
||||
"删除": "delete",
|
||||
"修改": function(event, can, msg, value, index, key, td) {
|
||||
var text = td.innerHTML;
|
||||
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
||||
if (event.key != "Enter") {return}
|
||||
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
|
||||
td.innerHTML = event.target.value;
|
||||
can.user.toast("修改成功")
|
||||
}, true)
|
||||
}}}])
|
||||
},
|
||||
"复制": function(event, can, msg, value, index, key, target) {
|
||||
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, value, index, key, target) {
|
||||
can.page.Download(can, key, target.innerHTML);
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: [],
|
||||
Format: function(can, msg, name) {
|
||||
var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) {
|
||||
return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",")
|
||||
}).join("\n");
|
||||
|
||||
!txt && (ext = ".txt", txt = msg.result && msg.result.join("") || "");
|
||||
return [name, ext, txt]
|
||||
"复制": function(event, can, msg, key, svg) {
|
||||
can.user.toast(can.page.CopyText(can, svg.innerHTML), "复制成功")
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
||||
|
@ -32,11 +32,16 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
item.type == "button" && item.action == "auto" && can.run && can.run({});
|
||||
return target;
|
||||
}),
|
||||
path: function(event, can, value, cmd, target) {
|
||||
return target.value + (target.value == "" || target.value.endsWith("/")? "": "/") + value
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "控件交互", list: [],
|
||||
onclick: function(event, can) {can.Select(event); can.item.type == "button" && can.run(event)},
|
||||
onkeydown: function(event, can) {
|
||||
if (event.key == "Enter") {return can.run(event, [])};
|
||||
if (event.key == "Enter") {return can.run(event, [])}
|
||||
if (event.key == "Escape") {return event.target.blur()}
|
||||
can.page.oninput(event, can)
|
||||
},
|
||||
})
|
||||
Volcanos("onchoice", {help: "控件菜单", list: ["全选", "复制", "清空"],
|
||||
@ -50,8 +55,6 @@ Volcanos("onchoice", {help: "控件菜单", list: ["全选", "复制", "清空"]
|
||||
can.target.value = "";
|
||||
},
|
||||
})
|
||||
Volcanos("ondetail", {help: "控件详情", list: [],
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: [],
|
||||
})
|
||||
Volcanos("ondetail", {help: "控件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
13
plugin/media.js
Normal file
13
plugin/media.js
Normal file
@ -0,0 +1,13 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, output, action, option, field) {
|
||||
output.innerHTML = msg.Result();
|
||||
},
|
||||
init: function(can, msg, cb, output, option) {output.innerHTML = msg.Result();
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: []})
|
||||
|
||||
|
@ -1,11 +1,27 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: [],
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["copy", "复制", "下载"],
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["copy", "复制", "下载"],
|
||||
Volcanos("onimport", {help: "导入数据", list: []})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: [["display", "表格", "文档", "相册"],
|
||||
"执行", "返回", "加参", "减参", "克隆", "删除"],
|
||||
|
||||
"表格": function(event, can, msg, cmd, field) {can.Show("table", can.msg)},
|
||||
"文档": function(event, can, msg, cmd, field) {can.Show("inner", can.msg)},
|
||||
"相册": function(event, can, msg, cmd, field) {can.Show("media", can.msg)},
|
||||
|
||||
"返回": function(event, can, msg, cmd, field) {can.Last(event)},
|
||||
"执行": function(event, can, msg, cmd, field) {can.Runs(event)},
|
||||
"加参": function(event, can, msg, cmd, field) {can.Append()},
|
||||
"减参": function(event, can, msg, cmd, field) {can.Remove(event)},
|
||||
"克隆": function(event, can, msg, cmd, field) {can.Clone(event)},
|
||||
"删除": function(event, can, msg, cmd, field) {can.Delete(event)},
|
||||
})
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["copy", "复制", "下载"]})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["复制", "下载"],
|
||||
you_status: function(event, can, msg, value, key, index) {
|
||||
var cmd = [can.option.pod.value, msg.you[index]]
|
||||
value == "start" && cmd.push("stop")
|
||||
var timer = can.user.toast(cmd.join(" ")+"...", msg.you[index], 5000)
|
||||
can.Run(event, cmd, function(msg) {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -21,9 +21,9 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
switch (event.target.tagName) {
|
||||
case "TD":
|
||||
can.onimport.which(event, table, msg.append, function(index, key) {
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, value, meta) {var cb = meta[value];
|
||||
typeof cb == "function"? cb(event, can, msg, value, index, key, target):
|
||||
can.run(event, [index, typeof cb == "string"? cb: value, key, target.innerHTML], null, true)
|
||||
can.user.carte(event, shy("", can.ondetail, can.ondetail.list, function(event, cmd, meta) {var cb = meta[cmd];
|
||||
typeof cb == "function"? cb(event, can, msg, index, key, cmd, target):
|
||||
can.run(event, [index, typeof cb == "string"? cb: cmd, key, target.innerHTML], null, true)
|
||||
}))
|
||||
})
|
||||
event.stopPropagation()
|
||||
@ -37,27 +37,27 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
return typeof cb == "function" && cb(msg), table;
|
||||
},
|
||||
which: function(event, table, list, cb) {if (event.target == table) {return cb(-1, "")}
|
||||
can.page.Select(can, table, "tr", function(tr, index) {if (event.target == tr) {return cb(index, "")}
|
||||
can.page.Select(can, table, "tr", function(tr, index) {if (event.target == tr) {return cb(index-1, "")}
|
||||
can.page.Select(can, tr, "th,td", function(td, order) {
|
||||
if (event.target == td) {return cb(index, list[order])}
|
||||
if (event.target == td) {return cb(index-1, list[order])}
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: [],
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
|
||||
"返回": function(event, can, msg, value, target) {
|
||||
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载"],
|
||||
"返回": function(event, can, msg, cmd, target) {
|
||||
can.run(event, ["", "Last"])
|
||||
},
|
||||
"清空": function(event, can, msg, value, target) {
|
||||
"清空": function(event, can, msg, cmd, target) {
|
||||
can.target.innerHTML = "";
|
||||
},
|
||||
"复制": function(event, can, msg, value, target) {
|
||||
"复制": function(event, can, msg, cmd, target) {
|
||||
var list = can.onexport.Format(can, msg, "data");
|
||||
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, value, target) {
|
||||
"下载": function(event, can, msg, cmd, target) {msg = msg || can.msg;
|
||||
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
|
||||
can.page.Download(can, list[0]+list[1], list[2]);
|
||||
},
|
||||
@ -65,7 +65,7 @@ Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制",
|
||||
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
|
||||
"选择": "select",
|
||||
"删除": "delete",
|
||||
"修改": function(event, can, msg, value, index, key, td) {
|
||||
"修改": function(event, can, msg, index, key, cmd, td) {
|
||||
var text = td.innerHTML;
|
||||
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
|
||||
if (event.key != "Enter") {return}
|
||||
@ -75,10 +75,10 @@ Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除",
|
||||
}, true)
|
||||
}}}])
|
||||
},
|
||||
"复制": function(event, can, msg, value, index, key, target) {
|
||||
"复制": function(event, can, msg, index, key, cmd, target) {
|
||||
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
|
||||
},
|
||||
"下载": function(event, can, msg, value, index, key, target) {
|
||||
"下载": function(event, can, msg, index, key, cmd, target) {
|
||||
can.page.Download(can, key, target.innerHTML);
|
||||
},
|
||||
})
|
||||
|
21
proto.js
21
proto.js
@ -20,24 +20,24 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块
|
||||
};
|
||||
|
||||
can = can || {};
|
||||
can.name = name;
|
||||
can._name = name;
|
||||
|
||||
// 定义原型
|
||||
var id = 1, conf = {}, conf_cb = {}, sync = {}, cache = {};
|
||||
can[name] || list.push({name: name, can: can, create_time: new Date()}) && (can.__proto__ = {
|
||||
create_time: new Date(), name: name, path: "", help: "插件模块", load: function(name) {
|
||||
can[name] || list.push({_name: name, can: can, create_time: new Date()}) && (can.__proto__ = {
|
||||
_create_time: new Date(), _name: name, _path: "", _help: "插件模块", load: function(name) {
|
||||
if (meta.cache[name]) {var cache = meta.cache[name];
|
||||
for (var i = 0; i < cache.length; i++) {var item = cache[i];
|
||||
if (item.can.name == can.name) {continue}
|
||||
can[item.name] = item.can;
|
||||
if (item.can._name == can._name) {continue}
|
||||
can[item._name] = item.can;
|
||||
}
|
||||
return can
|
||||
}
|
||||
|
||||
meta.cache[name] = []
|
||||
for (var i = meta.index; i < list.length; i++) {var item = list[i];
|
||||
if (item.can.name == can.name || item.can.type == "local") {continue}
|
||||
can[item.name] = item.can;
|
||||
if (item.can._name == can._name || item.can._type == "local") {continue}
|
||||
can[item._name] = item.can;
|
||||
meta.cache[name].push(item);
|
||||
}
|
||||
meta.index = i;
|
||||
@ -74,8 +74,9 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块
|
||||
setTimeout(function() {loop(0)}, interval.value||interval[0]);
|
||||
return timer;
|
||||
}),
|
||||
Event: shy("触发器", function(event, msg, proto) {
|
||||
Event: shy("触发器", function(event, msg, proto) {event = event || {};
|
||||
msg = event.msg = msg || event.msg || {}, msg.__proto__ = proto || {
|
||||
_create_time: can.base.Time(),
|
||||
Log: shy("输出日志", function() {console.log(arguments)}),
|
||||
Option: function(key, val) {
|
||||
if (val == undefined) {return msg[key]}
|
||||
@ -164,7 +165,7 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块
|
||||
can.user.carte(event, shy("", can.onchoice, can.onchoice.list, function(event, key, meta) {var cb = meta[key];
|
||||
typeof cb == "function"? cb(event, can, msg, key, event.target):
|
||||
can.run(event, [typeof cb == "string"? cb: key, event.target], null, true)
|
||||
}))
|
||||
}), can)
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
}
|
||||
@ -180,7 +181,7 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块
|
||||
} else {
|
||||
// 加载脚本
|
||||
var script = document.createElement("script");
|
||||
script.src = (can.path||meta.path)+libs[0]+".js";
|
||||
script.src = (can._path||meta.path)+libs[0]+".js";
|
||||
script.onload = function() {can.load(libs[0]), next()}
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user