Volcanos("onimport", {help: "导入数据", list: [], init: function(can, msg, cb, output, action, option) {output.innerHTML = ""; if (msg.append && msg.append.length > 0) { var table = can.page.AppendTable(can, output, msg, msg.append); var prefix = can.page.Append(can, output, [{view: ["prefix"], list: msg.Table(function(item) { var items = item.path.split(".") switch (items[items.length-1]) { case "JPG": return {img: "/share/local/"+item.path, width: "200"} case "MOV": return {type: "video", width: "200", data: {controls: "controls", autoplay: false, loop: true, src: "/share/local/"+item.path}} default: return } })}]); table.onclick = function(event) {switch (event.target.tagName) { case "TD": can.onimport.which(event, table, msg.append, function(index, key) { var name = event.target.innerHTML.trim() if (name.endsWith("/")) { can.Option("name", name) can.run(event, [name], function(msg) {}) } }) break case "TH": break case "TR": case "TABLE": }} 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-1, "")} can.page.Select(can, tr, "th,td", function(td, order) { if (event.target == td) {return cb(index-1, list[order])} }) }) }, }) Volcanos("onaction", {help: "组件菜单", list: ["保存", ], "保存": function(event, can, msg, cmd, target) { can.run(event, ["action", cmd, can.Option("name"), can.page.Select(can, target, "tr", function(tr) {return can.page.Select(can, tr, "th,td", function(td) {return td.innerHTML}).join(",")}).join("\n")], function() { can.user.toast("保存成功") }, true) }, }) Volcanos("onchoice", {help: "组件交互", list: ["保存", "清空", ["rect", "rect", "line", "circle"]], "清空": function(event, can, msg, cmd, target) { console.log("choice", cmd) }, }) Volcanos("ondetail", {help: "组件详情", list: ["编辑", "删除"], "编辑": function(event, can, msg, index, key, cmd, target) { can.user.prompt("文字", function(text) { if (target.tagName == "text") {return target.innerHTML = text} var data = {"text-anchor": "middle", "dominant-baseline": "middle"} var figure = can.onfigure[target.tagName] figure.text(event, can, data, target) var p = can.onaction.push(event, can, data, "text", can.svg) p.innerHTML = text; target.Text && can.page.Remove(can, target.Text) && delete(target.Text) target.Text = p }, target.Text && target.Text.innerText || "") }, "复制": function(event, can, msg, index, key, cmd, target) { var figure = can.onfigure[target.tagName] figure.copy(event, can, target) }, "删除": function(event, can, msg, index, key, cmd, target) { can.page.Remove(can, target) }, }) Volcanos("onstatus", {help: "组件状态", list: ["begin", "width", "point", "which"], "begin": function(event, can, value, cmd, target) {target.innerHTML = value? value.x+","+value.y: ""}, "width": function(event, can, value, cmd, target) {target.innerHTML = value? value.width+","+value.height: ""}, "point": function(event, can, value, cmd, target) {target.innerHTML = value.x+","+value.y}, "which": function(event, can, value, cmd, target) {var figure = can.onfigure[value.tagName]; target.innerHTML = figure? figure.show(event, can, value, target): value.tagName; }, }) Volcanos("onexport", {help: "导出数据", list: []})