From f421970515c4a3ef8d971e9d19615ec9f146b76a Mon Sep 17 00:00:00 2001 From: shaoying Date: Fri, 25 Sep 2020 19:49:09 +0800 Subject: [PATCH] opt data --- index.css | 7 +++-- lib/user.js | 9 ++++--- plugin/input/scan.js | 4 +++ plugin/local/wiki/data.js | 22 ++++++++------- plugin/local/wiki/feel.js | 56 +++++++++++++-------------------------- 5 files changed, 45 insertions(+), 53 deletions(-) create mode 100644 plugin/input/scan.js diff --git a/index.css b/index.css index d327b5fd..b34c935a 100644 --- a/index.css +++ b/index.css @@ -182,7 +182,7 @@ div.code { div.toast { color:yellow; - background:black; + background:#0e3369b3; border:solid 2px red; position:fixed; padding:5px; @@ -190,7 +190,7 @@ div.toast { } div.toast div.title { font-size:14px; - color:gray; + color:#cae850; } div.toast div.content { text-align:center; @@ -407,6 +407,9 @@ body.white fieldset.plugin table tr { body.white fieldset.plugin table tr:hover { background-color:#99CCFF; } +body.white fieldset.plugin table tr.select { + background-color:#0fbd45; +} body.white fieldset.plugin table th { padding:4px; background-color:#99CCFF; diff --git a/lib/user.js b/lib/user.js index e25ec9fe..189a7d0a 100644 --- a/lib/user.js +++ b/lib/user.js @@ -32,9 +32,9 @@ var user = Volcanos("user", {help: "用户模块", // TODO }) }, - toast: function(can, text, title, duration) { - var meta = typeof text == "object"? text: {text: text, title: title||can._help, duration: duration, progress: 0} - var width = meta.width||200, height = meta.height||100 + toast: function(can, text, title, duration, progress) { + var meta = typeof text == "object"? text: {text: text, title: title||can._help, duration: duration, progress: progress} + var width = meta.width||400, height = meta.height||100 var ui = can.page.Append(can, document.body, [{view: "toast", style: { width: width, bottom: 100, left: document.body.clientWidth/2-width/2, @@ -46,7 +46,7 @@ var user = Volcanos("user", {help: "用户模块", meta.progress > 0 && {text: ["", "div", "progress"], style: {width: width}, list: [ {text: ["", "div", "current"], style: {width: meta.progress/100*width}}, ]}, - ]}]) + ], ondblclick: function(event) { ui.Close() }}]) var timer = can.Timer({value: 100, length: (meta.duration||1000)/100}, function(event, interval, index) { if (index > 20) { ui.duration.innerHTML = parseInt(index/10)+"."+(index%10)+"s..." } @@ -176,6 +176,7 @@ var user = Volcanos("user", {help: "用户模块", begin = new Date() msg._progress = show msg.upload = action.upload.files[0] + msg.Option("_upload", "file") can.run(event, ["action", "upload"], function(msg) { can.user.toast(can, "上传成功") }, true) diff --git a/plugin/input/scan.js b/plugin/input/scan.js new file mode 100644 index 00000000..bfceaa72 --- /dev/null +++ b/plugin/input/scan.js @@ -0,0 +1,4 @@ +Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, list, cb, target) { + }, +}) + diff --git a/plugin/local/wiki/data.js b/plugin/local/wiki/data.js index d1f6da7a..6754916c 100644 --- a/plugin/local/wiki/data.js +++ b/plugin/local/wiki/data.js @@ -1,5 +1,5 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb) { - can._target.innerHTML = "", can.ui = can.page.Append(can, can._target, [ + can.ui = can.page.Appends(can, can._target, [ {view: "content"}, {view: "display"}, ]) can.table = can.onappend.table(can, can.ui.content, "table", msg, function(value, key, index, line) { @@ -15,6 +15,8 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, } }} }) + can.onexport.list = msg.append + typeof cb == "function" && cb() }, }) Volcanos("onfigure", {help: "组件菜单", list: [], @@ -36,11 +38,10 @@ Volcanos("onfigure", {help: "组件菜单", list: [], } }, }) -Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "正常", "块选", "反选", "多选", "拖动", "编辑"], "求和", "最大", "最小", "平均"], +Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "全选", "块选", "反选", "多选", "拖动", "编辑"], "求和", "最大", "最小", "平均"], _engine: function(event, can, cmd) { - var mul = "tr" + (can.Action("mode") == "正常"? "": ".select") - var method = can.onfigure[cmd] - var res = {} + var mul = "tr" + (can.Action("mode") == "全选"? "": ".select") + var method = can.onfigure[cmd], res = {} can.page.Select(can, can.ui.content, mul, function(tr, nrow, rows) { @@ -48,9 +49,10 @@ Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "正常", method && method(event, can, res, td, ncol, cols, rows, nrow) }) }) - can.page.Append(can, can.ui.display, [{type: "table", list: [{type: "tr", list: can.core.Item(res, function(key, value) { - return {text: [value, "td"]} - }).concat([{text: [cmd, "td"]}]) }] }]) + + can.core.Item(res, function(key, value) { + can.Status(can._msg.append[key], value||"") + }) }, "保存": function(event, can, cmd) { @@ -58,7 +60,7 @@ Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "正常", can.user.toast(can, "保存成功") }, true) }, - "正常": function(event, can, cmd) { + "全选": function(event, can, cmd) { cmd && can.Action("mode", cmd) can.page.Select(can, can.ui.content, "tr", function(item) { can.page.ClassList.del(can, item, "over") @@ -94,7 +96,7 @@ Volcanos("onaction", {help: "组件菜单", list: ["保存", ["mode", "正常", }) }, "拖动": function(event, can, cmd) { - can.onaction["正常"](event, can, cmd) + can.onaction["全选"](event, can, cmd) can.page.Select(can, can.ui.content, "tr", function(item) { item.setAttribute("draggable", true) item.ondragstart = function(event) { can.drag = item } diff --git a/plugin/local/wiki/feel.js b/plugin/local/wiki/feel.js index 1f557961..b27319bd 100644 --- a/plugin/local/wiki/feel.js +++ b/plugin/local/wiki/feel.js @@ -1,34 +1,29 @@ -Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { can._target.innerHTML = "" - can.ui = can.page.Append(can, can._target, [ - {view: "project"}, - {view: "profile", style: {clear: "both"}}, +Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { + can.ui = can.page.Appends(can, can._target, [ + {view: "project"}, {view: "profile", style: {clear: "both"}}, ]) - can._msg = msg can.path = can.request({}), can.list = [] - msg.Table(function(value) { - if (value.path.startsWith("/local")) { return } + msg.Table(function(value) { if (value.path.startsWith("/local")) { return } value.path.endsWith("/")? can.path.Push(value): can.list.push(value) }) + can.onappend.table(can, can.ui.project, "table", can.path, function(value, key, index, line, array) { return {type: "td", inner: value, click: function(event) { - // can.Option(key, value) && can.run(event) - can.sup.onaction.change(event, can.sup, key, value, function(msg) { - can.run(event) - }) + can.sup.onaction.change(event, can.sup, key, value, function(msg) { + can.run(event) + }) }} }) + var feature = can.Conf("feature") || {} can.page.Modify(can, can._action, {style: {display: "none"}}) typeof cb == "function" && cb() - var feature = can.Conf("feature") || {} - - can.begin = 0 can.Action("倍速", can.rate = 1) - can.Action("数量", can.limit = parseInt(feature["limit"]||msg.Option("limit"))||6) - can.Action("高度", can.height = parseInt(feature["height"]||msg.Option("height"))||100) - can.Option("path") != "最近/" && can.onimport.page(can, can.list, can.begin, can.limit) + can.Action("数量", can.limit = parseInt(msg.Option("limit"))||feature["limit"]||6) + can.Action("高度", can.height = parseInt(msg.Option("height"))||feature["height"]||100) + can.Option("path") != "最近/" && can.onimport.page(can, can.list, can.begin = 0, can.limit) }, page: function(can, list, begin, limit) { can.ui.profile.innerHTML = "" if (!list || list.length == 0) { return } @@ -59,7 +54,7 @@ Volcanos("onfigure", {help: "组件菜单", list: [], can.page.Remove(can, event.target) }, }]) }, onmouseover: function(event) { - // can.Status("文件", path) + can.user.toast(can, path, "image") }, _init: function(target) { can.Status("文件", path) } @@ -90,30 +85,17 @@ Volcanos("onaction", {help: "组件菜单", list: [ ["倍速", 0.1, 0.2, 0.5, 1, 2, 3, 5, 10], ], "上传": function(event, can) { can.user.upload(event, can) }, - "下载": function(event, can) { can.user.download(can, can.Status("文件")) }, - "收藏": function(event, can) { - chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { - chrome.tabs.sendMessage(tabs[0].id, { action: "copy" }, function (response) { - can.onimport.file(can, response.src) - var msg = can.request(event); msg.Option(can.Option()) - can.run(event, ["action", "spide", "mp4", response.title, response.src, "poster", response.poster], function(msg) { - - }, true) - }) - }) - }, - "清空": function(event, can) { - can._target.innerHTML = "" - }, - "参数": function(event, can) { - can.page.Modify(can, can._action, {style: {display: can._action.style.display=="none"? "block": "none"}}) - }, "上一页": function(event, can, key, value) { can.begin > 0 && (can.begin -= can.limit, can.onimport.page(can, can.list, can.begin, can.limit)) }, "下一页": function(event, can, key, value) { can.begin + can.limit < can.list.length && (can.begin += can.limit, can.onimport.page(can, can.list, can.begin, can.limit)) }, + "下载": function(event, can) { can.user.download(can, can.Status("文件")) }, + + "参数": function(event, can) { + can.page.Modify(can, can._action, {style: {display: can._action.style.display=="none"? "block": "none"}}) + }, "数量": function(event, can, key, value) { can.limit = parseInt(value), can.onimport.page(can, can.list, can.begin, can.limit) }, @@ -124,7 +106,7 @@ Volcanos("onaction", {help: "组件菜单", list: [ can.rate = parseInt(value), can.onimport.page(can, can.list, can.begin, can.limit) }, }) -Volcanos("onexport", {help: "导出数据", list: ["total", "begin", "limit", "position", "文件"], +Volcanos("onexport", {help: "导出数据", list: ["begin", "limit", "total", "position", "文件"], position: function(can, index, total) { total = total || can.max return parseInt((index+1)*100/total)+"%"+" = "+(parseInt(index)+1)+"/"+parseInt(total) },