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

opt table.js

This commit is contained in:
shylinux 2020-02-24 05:39:56 +08:00
parent 3d72304818
commit 8695a556f9
8 changed files with 36 additions and 73 deletions

View File

@ -13,7 +13,7 @@ var can = Volcanos("chat", {
can.core.Item(page._panes, function(index, item) { can.core.Item(page._panes, function(index, item) {
if (key == "favor") {var msg = value; if (key == "favor") {var msg = value;
var cmds = msg.detail, cmd = cmds[0]; var cmds = msg.detail, cmd = cmds[0];
if (cmd == item._name || cmd == item.name()) {cmd = cmds[1], cmds = cmds.slice(1)} if (cmd == item._name || cmd == item.Name()) {cmd = cmds[1], cmds = cmds.slice(1)}
var cb = item.onchoice[cmd]; var cb = item.onchoice[cmd];
if (typeof cb == "function") { if (typeof cb == "function") {
@ -224,8 +224,7 @@ var can = Volcanos("chat", {
for (var i = args.length-1; i >= 0; i--) {if (args[i] == "") {args = args.slice(0, i)} else {break}} 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(can.base.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)} run(event, args, function(msg) {if (silent) {return typeof cb == "function" && cb(msg)}
plugin.msg = msg plugin.msg = msg, plugin.Show(feature.display || "table", msg, cb)
plugin.Show(feature.display || "table", msg, cb)
show = false, plugin.user.toast(); show = false, plugin.user.toast();
}) })
}, },

View File

@ -201,7 +201,7 @@ Volcanos("page", {help: "网页模块",
return field.Meta = item, field; return field.Meta = item, field;
}), }),
AppendTable: shy("添加表格", function(can, target, msg, list, cb, cbs) { AppendTable: shy("添加表格", function(can, target, msg, list, cb, cbs) {
if (!msg.append || msg.append.length == 0) {return {}} if (!msg.append || msg.append.length == 0) {return}
var table = can.page.Append(can, target, "table"); var table = can.page.Append(can, target, "table");
var tr = can.page.Append(can, table, "tr"); var tr = can.page.Append(can, table, "tr");

View File

@ -41,7 +41,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
}, },
favor: function(event, can, msg, cmd, field) {if (msg._hand) {return} favor: function(event, can, msg, cmd, field) {if (msg._hand) {return}
var cmds = msg.detail, key = cmds[0]; var cmds = msg.detail, key = cmds[0];
if (key == can.name()) {key = cmds[1], cmds = cmds.slice(1)} if (key == can.Name()) {key = cmds[1], cmds = cmds.slice(1)}
// 下发数据 // 下发数据
can.core.Item(can._local, function(river, list) { can.core.Item(can._local, function(river, list) {
@ -190,7 +190,7 @@ Volcanos("onchoice", {help: "组件菜单", list: ["共享", "保存", "刷新"]
var msg = can.Event(event); var msg = can.Event(event);
msg.Option("name", meta.name) msg.Option("name", meta.name)
msg.Option("text", meta.key) msg.Option("text", meta.key)
cmd == "提交" && can.Export(event, can.name(), "share") cmd == "提交" && can.Export(event, can.Name(), "share")
return true return true
}) })
}, },

View File

@ -1,7 +1,7 @@
Volcanos("onimport", {help: "导入数据", list: [], Volcanos("onimport", {help: "导入数据", list: [],
init: function(event, can, msg, cmd, field) {can.output.innerHTML = ""; init: function(event, can, msg, cmd, field) {can.output.innerHTML = "";
can.page.AppendItem(can, can.output, msg.Table(), can.user.Search(can, can.name()), function(event, line, item) { can.page.AppendItem(can, can.output, msg.Table(), can.user.Search(can, can.Name()), function(event, line, item) {
can.Export(event, line.key, can.name()) can.Export(event, line.key, can.Name())
}) })
}, },
river: function(event, can, value, cmd, field) {if (value == "update") { river: function(event, can, value, cmd, field) {if (value == "update") {
@ -11,7 +11,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
}}, }},
favor: function(event, can, msg, cmd, field) {if (msg._hand) {return} favor: function(event, can, msg, cmd, field) {if (msg._hand) {return}
var cmds = msg.detail, key = cmds[0]; var cmds = msg.detail, key = cmds[0];
if (key == can.name()) {key = cmds[1], cmds = cmds.slice(1)} if (key == can.Name()) {key = cmds[1], cmds = cmds.slice(1)}
can.page.Select(can, field, "div.item>span", function(item) { can.page.Select(can, field, "div.item>span", function(item) {
if (item.innerText == key) { if (item.innerText == key) {
@ -26,7 +26,7 @@ Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
can.Export(event, "create", "ocean") can.Export(event, "create", "ocean")
}, },
"刷新": function(event, can, meta, cmd, field) { "刷新": function(event, can, meta, cmd, field) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}, },
}) })
Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"], Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"],
@ -60,18 +60,18 @@ Volcanos("ondetail", {help: "组件详情", list: ["共享", "重命名", "删
var msg = can.Event(event); var msg = can.Event(event);
msg.Option("name", line.name) msg.Option("name", line.name)
msg.Option("text", line.key) msg.Option("text", line.key)
can.Export(event, can.name(), "share") can.Export(event, can.Name(), "share")
}, },
"重命名": function(event, can, line, value, cmd, item) { "重命名": function(event, can, line, value, cmd, item) {
can.user.prompt("输入新名:", function(name) { can.user.prompt("输入新名:", function(name) {
can.run(event, [value, "rename", name], function(msg) { can.run(event, [value, "rename", name], function(msg) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}) })
}, line.name) }, line.name)
}, },
"删除": function(event, can, line, value, cmd, item) { "删除": function(event, can, line, value, cmd, item) {
can.run(event, [value, "remove"], function(msg) { can.run(event, [value, "remove"], function(msg) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}) })
}, },
}) })

View File

@ -1,7 +1,7 @@
Volcanos("onimport", {help: "导入数据", list: [], Volcanos("onimport", {help: "导入数据", list: [],
init: function(event, can, msg, cmd, field) {can.output.innerHTML = ""; init: function(event, can, msg, cmd, field) {can.output.innerHTML = "";
can.page.AppendItem(can, can.output, msg.Table(), can.user.Search(can, can.name()), function(event, line, item) { can.page.AppendItem(can, can.output, msg.Table(), can.user.Search(can, can.Name()), function(event, line, item) {
can.Export(event, line.key, can.name()) can.Export(event, line.key, can.Name())
}) })
}, },
river: function(event, can, value, cmd, field) {if (value == "update") {return} river: function(event, can, value, cmd, field) {if (value == "update") {return}
@ -15,7 +15,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
can.onimport.init(event, can, msg, cmd, field) can.onimport.init(event, can, msg, cmd, field)
}) })
} else { } else {
can.Conf(can.name(), value) can.Conf(can.Name(), value)
} }
}, },
favor: function(event, can, msg, cmd, field) {if (msg._hand) {return} favor: function(event, can, msg, cmd, field) {if (msg._hand) {return}
@ -35,7 +35,7 @@ Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
can.Export(event, "create", "steam") can.Export(event, "create", "steam")
}, },
"刷新": function(event, can, meta, cmd, field) { "刷新": function(event, can, meta, cmd, field) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}, },
}) })
Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"], Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"],
@ -69,18 +69,18 @@ Volcanos("ondetail", {help: "组件详情", list: ["共享", "重命名", "删
var msg = can.Event(event); var msg = can.Event(event);
msg.Option("name", line.name) msg.Option("name", line.name)
msg.Option("text", line.key) msg.Option("text", line.key)
can.Export(event, can.name(), "share") can.Export(event, can.Name(), "share")
}, },
"重命名": function(event, can, line, value, cmd, item) { "重命名": function(event, can, line, value, cmd, item) {
can.user.prompt("输入新名:", function(name) { can.user.prompt("输入新名:", function(name) {
can.run(event, [can.Conf("river"), value, "rename", name], function(msg) { can.run(event, [can.Conf("river"), value, "rename", name], function(msg) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}) })
}, line.name) }, line.name)
}, },
"删除": function(event, can, line, value, cmd, item) { "删除": function(event, can, line, value, cmd, item) {
can.run(event, [can.Conf("river"), value, "remove"], function(msg) { can.run(event, [can.Conf("river"), value, "remove"], function(msg) {
can.Import(event, "update", can.name()) can.Import(event, "update", can.Name())
}) })
}, },
}) })

View File

@ -12,11 +12,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
item.className || can.page.ClassList.add(can, item, "args"); item.className || can.page.ClassList.add(can, item, "args");
break break
case "textarea": case "textarea":
var half = parseFloat(item.half||"1")||1; input.type = "textarea"
input.type = "textarea", item.style = {
// width: parseInt(((500-35)/half))+"px",
// height: (item.height||50)+"px",
}
// no break // no break
case "password": case "password":
// no break // no break
@ -27,11 +23,6 @@ Volcanos("onimport", {help: "导入数据", list: [],
break break
} }
// can.page.ClassList.add(can, item, item.view);
// can.core.List((item.clist||"").split(" "), function(value) {
// can.page.ClassList.add(can, item, value);
// })
//
var target = can.Dream(option, "input", input)[input.name]; var target = can.Dream(option, "input", input)[input.name];
!target.placeholder && (target.placeholder = item.name || ""); !target.placeholder && (target.placeholder = item.name || "");
item.type != "button" && !target.title && (target.title = item.placeholder || item.name || ""); item.type != "button" && !target.title && (target.title = item.placeholder || item.name || "");

View File

@ -1,52 +1,25 @@
Volcanos("onimport", {help: "导入数据", list: [], Volcanos("onimport", {help: "导入数据", list: [],
init: function(can, msg, cb, output, action, option) {output.innerHTML = ""; init: function(can, msg, cb, output, action, option) {output.innerHTML = "";
var table = can.page.AppendTable(can, output, msg, msg.append); var table = can.page.AppendTable(can, output, msg, msg.append, function(event, value, key, index, tr, td) {
table.onclick = function(event) {switch (event.target.tagName) { can.ondetail["复制"](event, can, msg, value, index, key, td);
case "TD": can.Export(event, value.trim(), key, index)
can.onimport.which(event, table, msg.append, function(index, key) { }, function(event, value, key, index, tr, td) {
can.ondetail["复制"](event, can, msg, event.target.innerHTML, index, key, event.target); can.user.carte(event, shy("上下文菜单", can.ondetail, can.feature.detail || can.ondetail.list, function(event, cmd, meta) {var cb = meta[cmd];
can.Export(event, event.target.innerHTML.trim(), key, index) var sub = can.Event(event);
}) msg.append.forEach(function(key) {sub.Option(key, msg[key][index].trim())})
break
case "TH":
break
case "TR":
case "TABLE":
}}
table.oncontextmenu = function(event) {var target = event.target;
switch (event.target.tagName) {
case "TD":
can.onimport.which(event, table, msg.append, function(index, key) {
can.user.carte(event, shy("", can.ondetail, can.feature.detail || can.ondetail.list, function(event, cmd, meta) {var cb = meta[cmd];
var sub = can.Event(event);
msg.append.forEach(function(key) {sub.Option(key, msg[key][index].trim())})
typeof cb == "function"? cb(event, can, msg, index, key, cmd, target): typeof cb == "function"? cb(event, can, msg, index, key, cmd, td):
can.run(event, ["action", typeof cb == "string"? cb: cmd, key, target.innerHTML.trim(), msg.Ids(index)], function(msg) { can.run(event, ["action", typeof cb == "string"? cb: cmd, key, value.trim(), msg.Ids(index)], function(msg) {
can.user.toast(msg.Result()) can.user.toast(msg.Result())
// can.onimport.init(can, msg, cb, output, option) }, true)
}, true) }))
})) event.stopPropagation()
}) event.preventDefault()
event.stopPropagation() });
event.preventDefault()
break
case "TH":
case "TR":
case "TABLE":
}
}
msg.result && can.page.Append(can, output, [{view: ["code", "div", can.page.Display(msg.Result())]}]).code; msg.result && can.page.Append(can, output, [{view: ["code", "div", can.page.Display(msg.Result())]}]).code;
return typeof cb == "function" && cb(msg); return typeof cb == "function" && cb(msg);
}, },
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(tr.dataset.index, "")}
can.page.Select(can, tr, "th,td", function(td, order) {
if (event.target == td) {return cb(tr.dataset.index, list[order])}
})
})
},
}) })
Volcanos("onaction", {help: "组件交互", list: []}) Volcanos("onaction", {help: "组件交互", list: []})
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载"], Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载"],

View File

@ -75,7 +75,7 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块
can._load(libs[0]), can.require(libs.slice(1), cb); can._load(libs[0]), can.require(libs.slice(1), cb);
}) })
}, },
name: function() {return can._name.toLowerCase()}, Name: function() {return can._name.toLowerCase()},
ID: shy("生成器", function() {return id++}), ID: shy("生成器", function() {return id++}),
Log: shy("日志器", function() {console.log(arguments)}), Log: shy("日志器", function() {console.log(arguments)}),