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) {
if (key == "favor") {var msg = value;
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];
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}}
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)
plugin.msg = msg, plugin.Show(feature.display || "table", msg, cb)
show = false, plugin.user.toast();
})
},

View File

@ -201,7 +201,7 @@ Volcanos("page", {help: "网页模块",
return field.Meta = item, field;
}),
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 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}
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) {
@ -190,7 +190,7 @@ Volcanos("onchoice", {help: "组件菜单", list: ["共享", "保存", "刷新"]
var msg = can.Event(event);
msg.Option("name", meta.name)
msg.Option("text", meta.key)
cmd == "提交" && can.Export(event, can.name(), "share")
cmd == "提交" && can.Export(event, can.Name(), "share")
return true
})
},

View File

@ -1,7 +1,7 @@
Volcanos("onimport", {help: "导入数据", list: [],
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.Export(event, line.key, can.name())
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())
})
},
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}
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) {
if (item.innerText == key) {
@ -26,7 +26,7 @@ Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
can.Export(event, "create", "ocean")
},
"刷新": function(event, can, meta, cmd, field) {
can.Import(event, "update", can.name())
can.Import(event, "update", can.Name())
},
})
Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"],
@ -60,18 +60,18 @@ Volcanos("ondetail", {help: "组件详情", list: ["共享", "重命名", "删
var msg = can.Event(event);
msg.Option("name", line.name)
msg.Option("text", line.key)
can.Export(event, can.name(), "share")
can.Export(event, can.Name(), "share")
},
"重命名": function(event, can, line, value, cmd, item) {
can.user.prompt("输入新名:", function(name) {
can.run(event, [value, "rename", name], function(msg) {
can.Import(event, "update", can.name())
can.Import(event, "update", can.Name())
})
}, line.name)
},
"删除": function(event, can, line, value, cmd, item) {
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: [],
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.Export(event, line.key, can.name())
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())
})
},
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)
})
} else {
can.Conf(can.name(), value)
can.Conf(can.Name(), value)
}
},
favor: function(event, can, msg, cmd, field) {if (msg._hand) {return}
@ -35,7 +35,7 @@ Volcanos("onaction", {help: "组件交互", list: ["创建", "刷新"],
can.Export(event, "create", "steam")
},
"刷新": function(event, can, meta, cmd, field) {
can.Import(event, "update", can.name())
can.Import(event, "update", can.Name())
},
})
Volcanos("onchoice", {help: "组件菜单", list: ["创建", "刷新", "宽度"],
@ -69,18 +69,18 @@ Volcanos("ondetail", {help: "组件详情", list: ["共享", "重命名", "删
var msg = can.Event(event);
msg.Option("name", line.name)
msg.Option("text", line.key)
can.Export(event, can.name(), "share")
can.Export(event, can.Name(), "share")
},
"重命名": function(event, can, line, value, cmd, item) {
can.user.prompt("输入新名:", function(name) {
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)
},
"删除": function(event, can, line, value, cmd, item) {
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");
break
case "textarea":
var half = parseFloat(item.half||"1")||1;
input.type = "textarea", item.style = {
// width: parseInt(((500-35)/half))+"px",
// height: (item.height||50)+"px",
}
input.type = "textarea"
// no break
case "password":
// no break
@ -27,11 +23,6 @@ Volcanos("onimport", {help: "导入数据", list: [],
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];
!target.placeholder && (target.placeholder = item.name || "");
item.type != "button" && !target.title && (target.title = item.placeholder || item.name || "");

View File

@ -1,52 +1,25 @@
Volcanos("onimport", {help: "导入数据", list: [],
init: function(can, msg, cb, output, action, option) {output.innerHTML = "";
var table = can.page.AppendTable(can, output, msg, msg.append);
table.onclick = function(event) {switch (event.target.tagName) {
case "TD":
can.onimport.which(event, table, msg.append, function(index, key) {
can.ondetail["复制"](event, can, msg, event.target.innerHTML, index, key, event.target);
can.Export(event, event.target.innerHTML.trim(), key, index)
})
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())})
var table = can.page.AppendTable(can, output, msg, msg.append, function(event, value, key, index, tr, td) {
can.ondetail["复制"](event, can, msg, value, index, key, td);
can.Export(event, value.trim(), key, index)
}, function(event, value, key, index, tr, td) {
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):
can.run(event, ["action", typeof cb == "string"? cb: cmd, key, target.innerHTML.trim(), msg.Ids(index)], function(msg) {
can.user.toast(msg.Result())
// can.onimport.init(can, msg, cb, output, option)
}, true)
}))
})
event.stopPropagation()
event.preventDefault()
break
case "TH":
case "TR":
case "TABLE":
}
}
typeof cb == "function"? cb(event, can, msg, index, key, cmd, td):
can.run(event, ["action", typeof cb == "string"? cb: cmd, key, value.trim(), msg.Ids(index)], function(msg) {
can.user.toast(msg.Result())
}, true)
}))
event.stopPropagation()
event.preventDefault()
});
msg.result && can.page.Append(can, output, [{view: ["code", "div", can.page.Display(msg.Result())]}]).code;
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("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);
})
},
name: function() {return can._name.toLowerCase()},
Name: function() {return can._name.toLowerCase()},
ID: shy("生成器", function() {return id++}),
Log: shy("日志器", function() {console.log(arguments)}),