From 117e3a6d2080a4483ed5db4c7216fd32d8602d0c Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 10 Nov 2023 17:33:59 +0800 Subject: [PATCH] add wx.shy --- const.js | 86 +++++++++++++++++++------------------- frame.js | 31 +++++++++----- index.css | 4 +- lib/base.js | 2 +- lib/misc.js | 8 ++-- lib/page.js | 22 +++++----- panel/footer.js | 2 +- panel/header.js | 6 +-- plugin/local/code/inner.js | 7 +++- plugin/local/wiki/feel.js | 2 +- plugin/local/wiki/word.css | 2 +- plugin/state.js | 4 +- proto.js | 2 +- publish/chrome/contexts.js | 14 +++---- publish/chrome/daemon.js | 2 +- 15 files changed, 107 insertions(+), 87 deletions(-) diff --git a/const.js b/const.js index 4c570776..a0d0db84 100644 --- a/const.js +++ b/const.js @@ -16,7 +16,6 @@ var ice = { HTTP: "http", HELP: "help", MAIN: "main", AUTO: "auto", LIST: "list", BACK: "back", - HOME: "home", COPY: "copy", MODE: "mode", EXEC: "exec", @@ -49,30 +48,32 @@ var ice = { var ctx = { CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature", - INDEX: "index", ARGS: "args", STYLE: "style", DISPLAY: "display", ACTION: "action", RUN: "run", + CMDS: "cmds", INDEX: "index", ARGS: "args", STYLE: "style", DISPLAY: "display", ACTION: "action", RUN: "run", EXTRA_INDEX: "extra.index", EXTRA_ARGS: "extra.args", } var mdb = {FOREACH: "*", RANDOMS: "%", DICT: "dict", META: "meta", HASH: "hash", LIST: "list", - ID: "id", KEY: "key", TIME: "time", ZONE: "zone", TYPE: "type", NAME: "name", TEXT: "text", DATA: "data", VIEW: "view", - LINK: "link", SCAN: "scan", HELP: "help", ICON: "icon", ICONS: "icons", - STATUS: "status", INDEX: "index", VALUE: "value", EXTRA: "extra", ALIAS: "alias", EXPIRE: "expire", - SHORT: "short", FIELD: "field", TOTAL: "total", COUNT: "count", LIMIT: "limit", - - INPUTS: "inputs", CREATE: "create", REMOVE: "remove", INSERT: "insert", DELETE: "delete", MODIFY: "modify", SELECT: "select", + TIME: "time", ZONE: "zone", ID: "id", + TYPE: "type", NAME: "name", TEXT: "text", ICON: "icon", ICONS: "icons", + KEY: "key", VALUE: "value", STATUS: "status", EXPIRE: "expire", EXTRA: "extra", + SHORT: "short", FIELD: "field", COUNT: "count", TOTAL: "total", INDEX: "index", LIMIT: "limit", + DATA: "data", VIEW: "view", + INPUTS: "inputs", CREATE: "create", REMOVE: "remove", UPDATE: "update", + INSERT: "insert", DELETE: "delete", MODIFY: "modify", SELECT: "select", PRUNES: "prunes", EXPORT: "export", IMPORT: "import", SEARCH: "search", ENGINE: "engine", RENDER: "render", PLUGIN: "plugin", DETAIL: "detail", NORMAL: "normal", PRUNE: "prune", - MAIN: "main", PAGE: "page", NEXT: "next", PREV: "prev", LIMIT: "limit", OFFEND: "offend", QS: ice.QS, AT: ice.AT, EQ: ice.EQ, FS: ice.FS, } -var web = {CHAT: "chat", PORTAL: "portal", STUDIO: "studio", SERVICE: "service", DOMAIN: "domain", - SPIDE: "spide", SPACE: "space", ROUTE: "route", DREAM: "dream", - TOKEN: "token", SHARE: "share", COUNT: "count", +var web = {CHAT: "chat", PORTAL: "portal", STUDIO: "studio", SERVICE: "service", + SERVE: "serve", SPACE: "space", ROUTE: "route", DREAM: "dream", + SPIDE: "spide", TOKEN: "token", SHARE: "share", COUNT: "count", WORKER: "worker", SERVER: "server", GATEWAY: "gateway", - OPEN: "open", LINK: "link", HTTP: "http", URL: "url", SHARE_CACHE: "/share/cache/", SHARE_LOCAL: "/share/local/", + ONLINE: "online", OFFLINE: "offline", + OPEN: "open", LINK: "link", HTTP: "http", DOMAIN: "domain", URL: "url", + SHARE_CACHE: "/share/cache/", SHARE_LOCAL: "/share/local/", AT: ice.AT, QS: ice.QS, DRAW: "draw", PLAY: "play", CLEAR: "clear", REFRESH: "refresh", RESIZE: "resize", FILTER: "filter", @@ -97,16 +98,16 @@ var web = {CHAT: "chat", PORTAL: "portal", STUDIO: "studio", SERVICE: "service", MALL_GOODS: "web.mall.goods", } var aaa = { - SECRET: "secret", - LOGIN: "login", LOGOUT: "logout", USER: "user", AUTH: "auth", SESS: "sess", ROLE: "role", - USERNICK: "usernick", USERNAME: "username", PASSWORD: "password", USERROLE: "userrole", USERZONE: "userzone", - EMAIL: "email", AVATAR: "avatar", BACKGROUND: "background", + LOGIN: "login", LOGOUT: "logout", + + BACKGROUND: "background", AVATAR: "avatar", EMAIL: "email", SECRET: "secret", LANGUAGE: "language", ENGLISH: "english", CHINESE: "chinese", + LONGITUDE: "longitude", LATITUDE: "latitude", + PROVINCE: "province", COUNTRY: "country", CITY: "city", + + USERNICK: "usernick", USERNAME: "username", PASSWORD: "password", USERROLE: "userrole", USERZONE: "userzone", VOID: "void", TECH: "tech", ROOT: "root", - PROVINCE: "province", - COUNTRY: "country", - CITY: "city", } var lex = { SPLIT: "split", PARSE: "parse", @@ -125,35 +126,37 @@ var gdb = { var tcp = { CLIENT: "client", SERVER: "server", PROTO: "proto", HOST: "host", PORT: "port", - HOSTNAME: "hostname", - SERVICE: "service", + SERVICE: "service", HOSTNAME: "hostname", } var nfs = { DIR: "dir", CAT: "cat", DEFS: "defs", PACK: "pack", TRASH: "trash", DIR_ROOT: "dir_root", COPY: "copy", EDIT: "edit", SAVE: "save", LOAD: "load", FIND: "find", GREP: "grep", TAGS: "tags", - SUBJECT: "subject", CONTENT: "content", RECENT: "recent", SCRIPT: "script", SOURCE: "source", TARGET: "target", - REPOS: "repos", IMAGE: "image", - MODULE: "module", SCRIPT: "script", - BRANCH: "branch", VERSION: "version", - TEMPLATE: "template", BINARY: "binary", - PUSH: "push", PULL: "pull", PATH: "path", FILE: "file", LINE: "line", SIZE: "size", + REPOS: "repos", MODULE: "module", BRANCH: "branch", VERSION: "version", + BINARY: "binary", SCRIPT: "script", TEMPLATE: "template", REPLACE: "replace", FROM: "from", TO: "to", - SVG: "svg", HTML: "html", CSS: "css", JS: "js", SH: "sh", GO: "go", CSV: "csv", JSON: "json", SHY: "shy", - TXT: "txt", PNG: "png", WEBM: "webm", - _CSS: ".css", _JS: ".js", - PWD: "./", SRC: "src/", USR: "usr/", USR_LOCAL_WORK: "usr/local/work/", SRC_DOCUMENT: "src/document/", SRC_TEMPLATE: "src/template/", - USR_ICONS: "usr/icons/", USR_GEOAREA: "usr/geoarea/", USR_VOLCANOS: "usr/volcanos/", + SUBJECT: "subject", CONTENT: "content", + SOURCE: "source", TARGET: "target", + PUSH: "push", PULL: "pull", + RECENT: "recent", + IMAGE: "image", + SH: "sh", SHY: "shy", GO: "go", JS: "js", CSS: "css", HTML: "html", SVG: "svg", _JS: ".js", _CSS: ".css", + TXT: "txt", CSV: "csv", JSON: "json", + PNG: "png", WEBM: "webm", + PWD: "./", SRC: "src/", SRC_TEMPLATE: "src/template/", SRC_DOCUMENT: "src/document/", + USR: "usr/", USR_LOCAL_WORK: "usr/local/work/", USR_VOLCANOS: "usr/volcanos/", USR_GEOAREA: "usr/geoarea/", USR_ICONS: "usr/icons/", + USR_INTSHELL: "usr/intshell", USR_LEARNING: "usr/learning", + REQUIRE: "/require/", REQUIRE_MODULES: "/require/modules/", + SHARE_LOCAL: "/share/local/", DF: ice.DF, PS: ice.PS, PT: ice.PT, } var cli = { RUNTIME: "runtime", SYSTEM: "system", DAEMON: "daemon", ORDER: "order", BUILD: "build", OPENS: "opens", BEGIN: "begin", END: "end", START: "start", RESTART: "restart", STOP: "stop", OPEN: "open", CLOSE: "close", - COLOR: "color", BLACK: "black", WHITE: "white", BLUE: "blue", RED: "red", GRAY: "gray", CYAN: "cyan", GREEN: "green", PURPLE: "purple", YELLOW: "yellow", + QRCODE: "qrcode", COLOR: "color", BLACK: "black", WHITE: "white", BLUE: "blue", RED: "red", GRAY: "gray", CYAN: "cyan", GREEN: "green", PURPLE: "purple", YELLOW: "yellow", MAGENTA: "magenta", SILVER: "silver", ALICEBLUE: "aliceblue", TRANSPARENT: "transparent", LINUX: "linux", DARWIN: "darwin", WINDOWS: "windows", - DONE: "done", COST: "cost", FROM: "from", - PWD: "pwd", + DONE: "done", COST: "cost", FROM: "from", PWD: "pwd", } var log = { INFO: "info", WARN: "warn", ERROR: "error", DEBUG: "debug", TRACE: "trace", @@ -161,14 +164,12 @@ var log = { var code = { FAVOR: "favor", XTERM: "xterm", INNER: "inner", VIMER: "vimer", - WEBPACK: "webpack", BINPACK: "binpack", AUTOGEN: "autogen", COMPILE: "compile", PUBLISH: "publish", + WEBPACK: "webpack", BINPACK: "binpack", AUTOGEN: "autogen", COMPILE: "compile", PUBLISH: "publish", UPGRADE: "upgrade", TEMPLATE: "template", COMPLETE: "complete", NAVIGATE: "navigate", CURRENT: "current", PULL: "pull", PUSH: "push", COMMENT: "comment", KEYWORD: "keyword", - UPGRADE: "upgrade", PACKAGE: "package", DATATYPE: "datatype", FUNCTION: "function", CONSTANT: "constant", STRING: "string", NUMBER: "number", BOOLEAN: "boolean", OBJECT: "object", ARRAY: "array", UNDEFINED: "undefined", - META: "Meta", ALT: "Alt", CONTROL: "Control", SHIFT: "Shift", TAB: "Tab", ESCAPE: "Escape", ENTER: "Enter", CMD: "Cmd", CTRL: "Ctrl", SPACE: "Space", BACKSPACE: "Backspace", ESC: "Esc", PS: "/", } @@ -231,13 +232,12 @@ var chat = { } var team = { TASK: "task", PLAN: "plan", - BEGIN_TIME: "begin_time", + BEGIN_TIME: "begin_time", END_TIME: "end_time", LONG: "long", YEAR: "year", MONTH: "month", WEEK: "week", DAY: "day", HOUR: "hour", TASK_POD: "task.pod", TASK_ZONE: "task.zone", TASK_ID: "task.id", } var mall = { - PRICE: "price", COUNT: "count", UNITS: "units", AMOUNT: "amount", - GOODS: "goods", + GOODS: "goods", PRICE: "price", COUNT: "count", UNITS: "units", AMOUNT: "amount", ASSET: "asset", SALARY: "salary", } @@ -292,9 +292,11 @@ var html = {PLUGIN_MARGIN: 10, ACTION_HEIGHT: 32, ACTION_MARGIN: 200, DIV_LAYOUT: "div.layout", DIV_LAYOUT_HEAD: "div.layout.head", DIV_LAYOUT_FOOT: "div.layout.foot", DIV_LAYOUT_LEFT: "div.layout.left", DIV_FLOAT: "div.float", DIV_TOAST: "div.toast", DIV_CARTE: "div.carte", DESKTOP: "desktop", DIV_DESKTOP: "div.desktop", DIV_EXPAND: "div.expand", + DIV_ITEM_TEXT: "div.item.text", DIV_ITEM_SELECT: "div.item.select", DIV_TABS_SELECT: "div.tabs.select", DIV_PROFILE: "div.profile", DIV_DISPLAY: "div.display", + VALUE: "value", IMAGE_PNG: "image/png", VIDEO_WEBM: "video/webm", } diff --git a/frame.js b/frame.js index 60aced3e..a16fb574 100644 --- a/frame.js +++ b/frame.js @@ -256,10 +256,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }) }) }, - _status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status) - var keys = {} + _status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status); var keys = {} can.core.List(can.base.Obj(list, can.core.Value(can, [chat.ONEXPORT, mdb.LIST])), function(item) { item = can.base.isString(item)? {name: item}: item - if (item.name == web.SPACE && item.value) { item.value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: item.value}), item.value) } + if (item && item.name == web.SPACE && item.value) { item.value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: item.value}), item.value) } if (can.base.beginWith(item.value, nfs.PS, ice.HTTP)) { item.value = can.page.Format(html.A, item.value, item.value.split("?")[0]) } if (keys[item.name]) { return can.Status(item.name, item.value) } keys[item.name] = item can.page.Append(can, status, [{view: html.ITEM, list: [ @@ -333,8 +332,10 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, select: function(can, select, item) { // can.user.trans(can, item.value||item.values[0]) var trans = {}; can.core.List(item.values, function(value) { trans[can.user.trans(can, value, null, html.INPUT)] = value }) - return can.page.Append(can, select.parentNode, [{type: html.INPUT, data: {className: html.SELECT, type: html.BUTTON, name: item.name, value: can.user.trans(can, item.value||item.values[0], null, html.INPUT), title: can.user.trans(can, item.name, null, html.INPUT)}, onclick: function(event) { var target = event.target - var carte = can.user.carte(event, can, {}, can.core.List(item.values, function(item) { return can.user.trans(can, item, null, html.INPUT) }), function(event, button) { carte.close() + return can.page.Append(can, select.parentNode, [{type: html.INPUT, data: {className: html.SELECT, type: html.BUTTON, name: item.name, value: can.user.trans(can, item.value||item.values[0], null, html.VALUE), title: can.user.trans(can, item.name, null, html.VALUE)}, onclick: function(event) { var target = event.target + var carte = can.user.carte(event, can, {}, can.core.List(item.values, function(item) { + return can.user.trans(can, item, null, html.VALUE) + }), function(event, button) { carte.close() if (target.value != button) { target.value = button, select.value = trans[button], select.onchange && select.onchange({target: select}) } return true }); can.onappend.style(can, [html.SELECT, item.name], carte._target), can.page.style(can, carte._target, html.MIN_WIDTH, event.target.offsetWidth) @@ -346,15 +347,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, _init: function(target) { can.page.style(can, target, html.WIDTH, (select.offsetWidth||80)+10), can.onappend.style(can, html.HIDE, select) }}, {icon: mdb.SELECT}]) }, table: function(can, msg, cb, target, keys) { if (!msg || msg.Length() == 0) { return } var meta = can.base.Obj(msg.Option(mdb.META)) - if (can.user.isMobile) { - can.base.toLast(msg.append, mdb.TIME) - can.base.toLast(msg.append, web.LINK) - } can.base.toLast(msg.append, ctx.ACTION) + if (can.user.isMobile) { can.base.toLast(msg.append, mdb.TIME), can.base.toLast(msg.append, web.LINK) } can.base.toLast(msg.append, ctx.ACTION) var table = can.page.AppendTable(can, msg, target||can._output, msg.append, cb||function(value, key, index, data, list) { if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) { if (key == mdb.VALUE) { key = data.key } data = {}, can.core.List(list, function(item) { data[item.key] = item.value }) } function run(event, cmd, arg) { can.misc.Event(event, can, function(msg) { can.run(can.request(event, data, can.Option()), [ctx.ACTION, cmd].concat(arg)) }) } if (key == web.SPACE && value) { value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: value}), value) } - return {text: [msg.IsDetail() && key == mdb.KEY? can.user.trans(can, value, null, html.INPUT): value, html.TD], onclick: function(event) { var target = event.target + if (key == mdb.ICONS && value) { value = can.page.Format(html.IMG, can.misc.Resource(can, data[key]), msg.IsDetail()? 128: 48, msg.IsDetail()? null: 48) } + return {text: [msg.IsDetail() && key == mdb.KEY? can.user.trans(can, value, null, html.INPUT): can.user.trans(can, value, null, html.VALUE), html.TD], onclick: function(event) { var target = event.target + if (key == cli.QRCODE && can.page.tagis(event.target, html.IMG)) { can.user.opens(event.target.title) } if (can.page.tagis(target, html.INPUT) && target.type == html.BUTTON) { can.requestAction(event, target.name) meta && meta[target.name]? can.user.input(event, can, meta[target.name], function(args) { run(event, target.name, args) }): run(event, target.name) } else { can.sup.onimport.change(event, can.sup, key, event.target.innerText) || can.sup.onexport.record(can.sup, value, key, data, event) } @@ -363,8 +363,17 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { item.run = function(event, cmds, cb) { can.run(can.request(event, data, can.Option()), cmds, cb, true) } item._enter = function(event, value) { if (event.ctrlKey) { run(event, mdb.MODIFY, [key, value]) } } can.onmotion.modifys(can, event.target, function(event, value, old) { run(event, mdb.MODIFY, [key, value]) }, item) - }, _init: function(target) { + }, onmouseout: function() { + can.page.SelectChild(can, can._option, html.DIV_ITEM_TEXT, function(target) { + can.page.ClassList.del(can, target, "will") + }) + }, onmouseover: function(event) { + can.page.SelectChild(can, can._option, html.DIV_ITEM_TEXT, function(target) { + can.page.ClassList.set(can, target, "will", can.page.ClassList.has(can, target, key)) + }) + }, title: can.user.trans(can, can.Option(key) == undefined? key: "click to detail", null, html.INPUT), _init: function(target) { key == ctx.ACTION && can.onappend.mores(can, target, data, can.user.isMobile && !can.user.isLandscape()? 2: can.isCmdMode()? 5: 3) + can.Option(key) != undefined && can.page.style(can, target, "cursor", "pointer") }} }); table && can.onappend.style(can, chat.CONTENT, table), table && msg.IsDetail() && can.onappend.style(can, mdb.DETAIL, table) msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table) diff --git a/index.css b/index.css index c9e3d888..ca45aaed 100644 --- a/index.css +++ b/index.css @@ -72,6 +72,7 @@ table.content.action td:last-child { position:sticky; right:2px; text-align:cent table.content input:not(:last-child) { margin-right:var(--button-margin); } table.content col.action { width:200px; } table.content col.time { width:180px; } +table.content img[title^=http] { cursor:pointer; } table.content:hover col.option { background-color:var(--hover-bg-color); } fieldset.panel.Action.tabs table.content { width:100%; } h1 { text-align:center; margin:20px 0; } h2 { margin:20px 0; } h3 { margin:20px 0; } @@ -187,7 +188,7 @@ fieldset>div.status { font-style:italic; line-height:20px; max-height:32px; } fieldset>div.status>div.item { padding:5px; height:31px; } fieldset>div.status>div.item>label { font-size:0.6rem; } fieldset>div.status>legend { font-style:italic; height:31px; } -legend, select, input[type=button], th, table.content td, h1, h2, h3, div.menu, div.item, div.tabs { cursor:pointer; } +legend, select, input[type=button], th, h1, h2, h3, div.menu, div.item, div.tabs { cursor:pointer; } div.story[data-type=spark] { cursor:copy; } body.en fieldset.input.date>div.action>div.item.select select { width:55px; } body.en fieldset.input.date>div.action>div.item.select.year select { width:100px; } @@ -219,6 +220,7 @@ div.item.select { position:relative; } div.item.select>span.icon { position:absolute; right:0; visibility:hidden; } div.item.select:hover>span.icon { visibility:visible; } div.item.text { position:relative; } +div.item.text.will input { border:var(--box-notice); } div.item.text>span.icon { position:absolute; right:0; visibility:hidden; } div.item.text:hover>span.icon { visibility:visible; } div.item.button>span.icon.create { font-size:32px; line-height:28px; display:block; } diff --git a/lib/base.js b/lib/base.js index 99007bed..44790119 100644 --- a/lib/base.js +++ b/lib/base.js @@ -49,7 +49,7 @@ Volcanos("base", { }, ParseURL: function(url) { var res = this._parse(url); res.link = url, res.origin = res._origin; return res }, ParseJSON: function(str) { var res; if (typeof str == code.OBJECT) { return str } - if (str.indexOf(ice.HTTP) == 0) { var res = this._parse(str, {type: mdb.LINK, name: "", text: str}); return res.name = res._origin.split("://").pop().split(nfs.PS)[0], res } + if (str.indexOf(ice.HTTP) == 0) { var res = this._parse(str, {type: web.LINK, name: "", text: str}); return res.name = res._origin.split("://").pop().split(nfs.PS)[0], res } try { res = JSON.parse(str), res.text = res.text||str, res.type = res.type||nfs.JSON } catch (e) { res = {type: mdb.TEXT, text: str} } return res }, ParseSize: function(size) { size = size.toLowerCase().split(" ")[0] diff --git a/lib/misc.js b/lib/misc.js index 78f64ce6..5487f9f2 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -144,9 +144,11 @@ Volcanos("misc", { }) } return socket }, - Resource(can, path, pod) { - if (path.indexOf(nfs.PS) == 0 || path.indexOf(ice.HTTP) == 0) { return path } - return can.base.MergeURL("/require/"+path, ice.POD, pod||can.Conf(web.SPACE)||can.Conf(ice.POD)) + Resource(can, path, space) { if (can.base.beginWith(path, web.HTTP, nfs.PS)) { return path } + return can.base.MergeURL(nfs.REQUIRE+path, ice.POD, space||can.Conf(web.SPACE)) + }, + ShareLocal(can, path, space) { if (can.base.beginWith(path, web.HTTP, nfs.PS)) { return path } + return can.base.MergeURL(nfs.SHARE_LOCAL+path, ice.POD, space||can.Conf(web.SPACE)) }, Template(can, path, file) { return can.base.Path(nfs.SRC_TEMPLATE, can.ConfIndex(), path, file) }, MergePath: function(can, file, path) { return file.indexOf(nfs.PS) == 0 || file.indexOf(ice.HTTP) == 0? file: can.base.Path(path, file) }, diff --git a/lib/page.js b/lib/page.js index 51c7bcf6..1fe3e7d1 100644 --- a/lib/page.js +++ b/lib/page.js @@ -17,8 +17,7 @@ Volcanos("page", { if (can.base.isUndefined(key)) { var value = {}; can.page.SelectArgs(can, target, "", function(item) { item.name && item.value && (value[item.name] = item.value) }); return [value] } if (can.base.isObject(key)) { return can.core.Item(key, function(key, value) { can.page.SelectArgs(can, target, key, value) }), [key] } if (!can.base.isFunc(cb)) { var value = cb; cb = function(item) { return item.name && (can.base.isUndefined(value)? item.value: (item.value = value))||"" } } - if (key.indexOf(nfs.PT) > -1) { return [""] } - key && can.base.isString(cb) && can.page.Select(can, target, "div.item."+key+">span.value", cb) + if (key.indexOf(nfs.PT) > -1) { return [""] } key && can.base.isString(cb) && can.page.Select(can, target, "div.item."+key+">span.value", cb) return can.page.Select(can, target, key? "select[name="+key+"],"+"input.select[type=button][name="+key+"],"+"input[type=text][name="+key+"],"+"textarea[name="+key+"]": ".args", cb) }, SelectInput: function(can, target, name, cb) { return can.page.Select(can, target, "input[name="+name+"]", cb)[0] }, @@ -141,7 +140,7 @@ Volcanos("page", { return item.value == "" || item.value == item.name? {type: html.SPAN, list: [{text: lex.SP}, {text: item.name}]}: {type: html.SPAN, list: [{text: lex.SP}, {text: item.name}, {text: mdb.EQ}, {className: code.STRING, text: "\""+item.value+"\""}]} }): [] } - var ui = {}; tag = tag||target.tagName.toLowerCase(), isclose = tag != mdb.META && tag != mdb.LINK, _field = field(target) + var ui = {}; tag = tag||target.tagName.toLowerCase(), isclose = tag != mdb.META && tag != web.LINK, _field = field(target) var inner = target.innerHTML? can.page.unicode.inner: ""; if (target && target.tagName) { target.innerText == target.innerHTML && (inner = target.innerText) } return {view: mdb.VIEW, list: [ {view: [[html.ITEM, target.tagName && target.tagName.toLowerCase()]], list: [ @@ -176,7 +175,7 @@ Volcanos("page", { can.page.Append(can, ui.thead, [{data: {dataset: {index: -1}}, th: can.core.List(list, function(key) { if (key[0] != "_") { return can.user.trans(can, key, null, html.INPUT) } }) }]) can.page.Append(can, ui.tbody, can.core.List(msg.Table(), function(item, index, array) { - return {dataset: {index: index}, className: item["status"], td: can.core.List(list, function(key) { if (key[0] != "_") { return cb(can.page.Color(item[key]).trim(), key, index, item, array) } }) } + return {dataset: {index: index}, className: item[mdb.STATUS], td: can.core.List(list, function(key) { if (key[0] != "_") { return cb(can.page.Color(item[key]).trim(), key, index, item, array) } }) } })); return can.page.OrderTable(can, ui._target) }, OrderTable: function(can, table) { can.page.Select(can, table, html.TH, function(th, index) { th.onclick = function(event) { var dataset = event.target.dataset @@ -206,11 +205,10 @@ Volcanos("page", { } }, Format: function(type) { var arg = arguments; switch (type) { - case html.A: return ""+(arg[2]||arg[1])+"" - case html.IMG: return arg[2]? "": "" - case html.SPAN: - arg[2] && typeof arg[2] == code.OBJECT && arg[2].join && (arg[2] = arg[2].join(lex.SP)) - return arg[2]? ""+arg[1]+"": arg[1] + case html.A: return `${arg[2]||arg[1]}"` + case html.IMG: return arg[3]? ``: arg[2]? ``: `` + case html.SPAN: arg[2] && typeof arg[2] == code.OBJECT && arg[2].join && (arg[2] = arg[2].join(lex.SP)) + return arg[2]? `${arg[1]}`: arg[1] default: /* type inner arg... */ var list = ["<"+type]; for (var i = 2; i < arg.length; i += 2) { list.push(lex.SP+arg[i]+mdb.EQ+arg[i+1]) } return list.concat(">", arg[1], "").join("") @@ -316,7 +314,9 @@ Volcanos("page", { item.values = can.base.isString(item.values)? can.core.Split(item.values): item.values if (!item.values && item.value) { item.values = can.core.Split(item.value), item.value = item.values[0] } if (item.values.slice(1).indexOf(item.values[0]) > -1) { item.value = item.value||item.values[0], item.values = item.values.slice(1) } - item.value = value||item.value, input.list = item.values.map(function(value) { return {type: html.OPTION, value: value, inner: value} }); break + item.value = value||item.value, input.list = item.values.map(function(value) { + return {type: html.OPTION, value: value, inner: can.user.trans(can, value, null, html.VALUE)} + }); break case html.TEXTAREA: input.type = html.TEXTAREA // no break case html.USERNAME: // no break case html.PASSWORD: // no break @@ -336,7 +336,7 @@ Volcanos("page", { requireModules: function(can, libs, cb, cbs) { if (!libs || libs.length == 0) { return cb && cb() } for (var i = 0; i < libs.length; i++) { if (libs[i].indexOf(nfs.PS) == 0 || libs[i].indexOf(ice.HTTP) == 0) { continue } if (libs[i].indexOf(nfs._CSS) == -1 && libs[i].indexOf(nfs._JS) == -1) { libs[i] = libs[i]+"/lib/"+libs[i]+nfs._JS } - libs[i] = "/require/modules/"+libs[i] + libs[i] = nfs.REQUIRE_MODULES+libs[i] } can.require(libs, cb, cbs) }, requireDraw: function(can, cb) { can.require([chat.PLUGIN_LOCAL+"wiki/draw.js", chat.PLUGIN_LOCAL+"wiki/draw/path.js"], function() { diff --git a/panel/footer.js b/panel/footer.js index 7520ee30..64291107 100644 --- a/panel/footer.js +++ b/panel/footer.js @@ -94,7 +94,7 @@ Volcanos(chat.ONPLUGIN, { {type: html.TD, list: can.core.List(list, function(item, index) { var vimer if (index == 1) { var _ls = /(https*:\/\/[^/]+)\/*([^:]+):([0-9]+):([0-9]+)/.exec(list[1]); _ls[2] = _ls[2].split(ice.QS)[0] return {view: [html.ITEM, html.SPAN], list: [{text: lex.SP+can.page.unicode.close+lex.SP}, {text: [(_ls[1] == location.origin? "": _ls[1])+_ls[2]+nfs.DF+_ls[3], "", nfs.PATH], onclick: function(event) { - if (can.onexport.record(can, list[1], mdb.LINK, {time: list[0], link: list[1], type: list[2], path: nfs.USR_VOLCANOS, file: _ls[2], line: _ls[3]})) { return } + if (can.onexport.record(can, list[1], web.LINK, {time: list[0], link: list[1], type: list[2], path: nfs.USR_VOLCANOS, file: _ls[2], line: _ls[3]})) { return } if (vimer) { return can.page.Remove(can, vimer._target), vimer = null } vimer = can.onappend.plugin(_can, {index: web.CODE_INNER, args: [nfs.USR_VOLCANOS, _ls[2], _ls[3]]}, function(sub) {}, event.target.parentNode) }}]} diff --git a/panel/header.js b/panel/header.js index c6c3e248..f88890c4 100644 --- a/panel/header.js +++ b/panel/header.js @@ -167,9 +167,9 @@ Volcanos(chat.ONPLUGIN, { }, [web.FILTER, ice.LIST, mdb.CREATE, mdb.PRUNES], function(can, msg, arg) { msg.Defer(function() { msg.PushAction(mdb.REMOVE).StatusTimeCount() }) can.core.Item(can.misc.sessionStorage(can), function(name, value) { can.base.contains(name, arg[0]) && msg.Push(mdb.NAME, name).Push(mdb.VALUE, value) }) }), - location: shy("请求地址", {copy: function(can) { can.user.copy(msg._event, can, location.href) }}, [mdb.LINK, ice.LIST, ice.COPY], function(can, msg, cb) { - can.runAction(can.request({}, kit.Dict(mdb.LINK, location.href)), web.SHARE, [], function(res) { - msg.Echo(res.Append(mdb.TEXT)).Status(kit.Dict(mdb.LINK, res.Append(mdb.NAME))), can.base.isFunc(cb) && cb(msg) + location: shy("请求地址", {copy: function(can) { can.user.copy(msg._event, can, location.href) }}, [web.LINK, ice.LIST, ice.COPY], function(can, msg, cb) { + can.runAction(can.request({}, kit.Dict(web.LINK, location.href)), web.SHARE, [], function(res) { + msg.Echo(res.Append(mdb.TEXT)).Status(kit.Dict(web.LINK, res.Append(mdb.NAME))), can.base.isFunc(cb) && cb(msg) }) }), avatar: shy("用户头像", function(can, sub, cb) { can.page.Append(can, sub._output, [{img: can.user.info.avatar, style: kit.Dict(html.MAX_HEIGHT, sub.ConfHeight(), html.MAX_WIDTH, sub.ConfWidth())}]) }), diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 1acbeb62..b274c3b5 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -9,7 +9,12 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { var paths = can.core.Sp can.Mode(msg.Option("mode")||can.Mode()), can.Option(nfs.FILE) == " " && can.Option(nfs.FILE, "") if (can.Mode() == ice.MSG_RESULT) { msg.result = msg.result||[can._output.innerHTML], can.Mode(chat.SIMPLE), can.sup.Mode(chat.SIMPLE) } can.core.List(paths.concat(can.core.Split(msg.Option(nfs.REPOS))), function(p) { - if (can.base.beginWith(p, nfs.USR_LOCAL_WORK) || can.base.endWith(p, "-dict/") || can.base.isIn(p, nfs.USR_ICONS, nfs.USR_GEOAREA)) { return } + if (can.base.beginWith(p, nfs.USR_LOCAL_WORK) || can.base.endWith(p, "-dict/") || can.base.isIn(p, + nfs.USR_INTSHELL, + nfs.USR_LEARNING, + nfs.USR_GEOAREA, + nfs.USR_ICONS, + )) { return } if (p && paths.indexOf(p) == -1 && p[0] != nfs.PS) { paths.push(p) } }), can.onmotion.clear(can), can.onappend.style(can, code.INNER), can.sup.onimport._process = function(_can, msg) { if (msg.OptionProcess() == ice.PROCESS_REWRITE) { diff --git a/plugin/local/wiki/feel.js b/plugin/local/wiki/feel.js index 7077cf5b..fcfe5ff1 100644 --- a/plugin/local/wiki/feel.js +++ b/plugin/local/wiki/feel.js @@ -149,7 +149,7 @@ Volcanos(chat.ONDETAIL, {list: ["关闭", "上一个", "下一个", "设置头 "下一个": function(event, can) { can.order < can.db.list.length-1? can.show(++can.order): can.user.toast(can, "已经是最后一张啦!") }, "设置头像": function(event, can) { can.setHeader(aaa.AVATAR, can.onimport._file(can, can.db.list[can.order].path)) }, "设置背景": function(event, can) { can.setHeader(aaa.BACKGROUND, can.onimport._file(can, can.db.list[can.order].path)) }, - "复制链接": function(event, can) { can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.db.list[can.order].path)}, true)) ]) }, + "复制链接": function(event, can) { can.onmotion.share(event, can, [], [web.LINK, can.user.copy(event, can, can.misc.MergeURL(can, {_path: can.onimport._file(can, can.db.list[can.order].path)}, true)) ]) }, "下载": function(event, can) { can.user.download(can, path = can.onimport._file(can, can.db.list[can.order].path)) }, "删除": function(event, can) { can.runAction(event, nfs.TRASH, [can.db.list[can.order].path], function(msg) { can.user.toastSuccess(can, "删除成功") }, true) }, }) diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index e5f2103c..85a8cab1 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -6,7 +6,7 @@ fieldset.word>div.output h2.story[data-type=spark][data-name=title] { text-align fieldset.word>div.output h3 { margin-top:20px; } fieldset.word>div.output table { width:100%; } fieldset.word>div.output img { display:block; margin:auto; max-height:100%; max-width:100%; } -fieldset.word>div.output table.content img { margin:unset; } +fieldset.word>div.output table.content img { margin:unset; max-width:unset; } fieldset.word>div.output video { max-height:100%; width:100%; } fieldset.word>div.output iframe { height:480px; width:100%; } fieldset.word>div.output svg.story[data-index] text { cursor:pointer; } diff --git a/plugin/state.js b/plugin/state.js index 3cd28ffa..9a7a0085 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -92,7 +92,7 @@ Volcanos(chat.ONACTION, {list: [ "远程控制": function(event, can) { can.onaction.keyboard(event, can) }, "共享工具": function(event, can) { var meta = can.Conf(); can.onmotion.share(event, can, [], [mdb.NAME, meta.index, mdb.TEXT, JSON.stringify(can.Input())]) }, "打开链接": function(event, can) { can.user.open(can.onexport.link(can)) }, - "生成链接": function(event, can) { can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.onexport.link(can))]) }, + "生成链接": function(event, can) { can.onmotion.share(event, can, [], [web.LINK, can.user.copy(event, can, can.onexport.link(can))]) }, "生成脚本": function(event, can) { var args = can.Input().join(lex.SP), list = [ "export ctx_dev="+location.origin+"; ctx_temp=$(mktemp); curl -o $ctx_temp -fsSL $ctx_dev;"+" source $ctx_temp cmd "+(can.Conf(ctx.INDEX))+lex.SP+args, "ish_sys_dev_run_command "+args, "ish_sys_dev_run_action", "ish_sys_dev_run_source", @@ -165,7 +165,7 @@ Volcanos(chat.ONACTION, {list: [ can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT}], function(list) { add(list[0]) }) }, getLocation: function(event, can, button) { can.user.agent.getLocation(can, function(data) { - can.user.input(can.request(event, data), can, [mdb.TYPE, mdb.NAME, mdb.TEXT, "latitude", "longitude"], function(args) { + can.user.input(can.request(event, data), can, [mdb.TYPE, mdb.NAME, mdb.TEXT, aaa.LATITUDE, aaa.LONGITUDE], function(args) { can.runAction(event, button, args, function() { can.Update() }) }) }) }, diff --git a/proto.js b/proto.js index 2c04da6c..50127cd1 100644 --- a/proto.js +++ b/proto.js @@ -125,7 +125,7 @@ try { if (typeof(window) == code.OBJECT) { var meta = Volcanos.meta if (meta._cache[url]) { return meta._cache[url].push(cb) } else { meta._cache[url] = [cb] } function _cb() { meta._cache[url].forEach(function(cb) { cb() }), delete(meta._cache[url]) } switch (url.split(web.QS)[0].split(nfs.PT).pop().toLowerCase()) { - case nfs.CSS: var item = document.createElement(mdb.LINK); item.href = url, item.rel = "stylesheet", item.onload = _cb, document.head.appendChild(item); break + case nfs.CSS: var item = document.createElement(web.LINK); item.href = url, item.rel = "stylesheet", item.onload = _cb, document.head.appendChild(item); break default: var item = document.createElement(nfs.SCRIPT); item.src = url, item.onerror = _cb, item.onload = _cb, document.body.appendChild(item) } } diff --git a/publish/chrome/contexts.js b/publish/chrome/contexts.js index 5a33375f..e99946a9 100644 --- a/publish/chrome/contexts.js +++ b/publish/chrome/contexts.js @@ -2,9 +2,9 @@ setTimeout(function() { Volcanos({ Option: function() { return [] }, spide: function(can, msg, target) { if (!target) { - msg.Push(mdb.TYPE, mdb.LINK) + msg.Push(mdb.TYPE, web.LINK) msg.Push(mdb.NAME, document.title) - msg.Push(mdb.LINK, location.href) + msg.Push(web.LINK, location.href) } var has = {}; target = target||document.body can.page.Select(can, target, html.AUDIO, function(target) { @@ -12,14 +12,14 @@ setTimeout(function() { Volcanos({ var name = target.src.split("?")[0].split(nfs.PT).pop() msg.Push(mdb.TYPE, html.AUDIO) msg.Push(mdb.NAME, html.AUDIO+nfs.PT+name) - msg.Push(mdb.LINK, target.src) + msg.Push(web.LINK, target.src) }) can.page.Select(can, target, html.VIDEO, function(target) { if (!target.src || has[target.src]) { return } has[target.src] = true var name = target.src.split("?")[0].split(nfs.PT).pop() msg.Push(mdb.TYPE, html.VIDEO) msg.Push(mdb.NAME, html.VIDEO+nfs.PT+name) - msg.Push(mdb.LINK, target.src) + msg.Push(web.LINK, target.src) }) can.page.Select(can, target, html.IMG, function(target) { if (!target.src || has[target.src]) { return } has[target.src] = true @@ -30,13 +30,13 @@ setTimeout(function() { Volcanos({ } else { msg.Push(mdb.NAME, name||"image.jpg") } - msg.Push(mdb.LINK, target.src) + msg.Push(web.LINK, target.src) }) can.page.Select(can, target, html.IFRAME, function(target) { if (!target.src || has[target.src]) { return } has[target.src] = true msg.Push(mdb.TYPE, html.IFRAME) msg.Push(mdb.NAME, "") - msg.Push(mdb.LINK, target.src) + msg.Push(web.LINK, target.src) try { can.spide(can, msg, target.contentWindow.document.body) } catch(e) { @@ -45,7 +45,7 @@ setTimeout(function() { Volcanos({ can.page.Select(can, target, html.A, function(target) { msg.Push(mdb.TYPE, html.A) msg.Push(mdb.NAME, "") - msg.Push(mdb.LINK, target.href) + msg.Push(web.LINK, target.href) }) }, style: function(can, msg, arg) { diff --git a/publish/chrome/daemon.js b/publish/chrome/daemon.js index ea47f875..43057792 100644 --- a/publish/chrome/daemon.js +++ b/publish/chrome/daemon.js @@ -32,7 +32,7 @@ Volcanos({ return msg._source = [sender.tab.id], can.run(msg, req.detail||[], cb), true }) chrome.history && chrome.history.onVisited.addListener(function(item) { - can.run({}, ["sync", mdb.TYPE, mdb.LINK, mdb.NAME, item.title, mdb.LINK, item.url, "tid", item.id]) + can.run({}, ["sync", mdb.TYPE, web.LINK, mdb.NAME, item.title, web.LINK, item.url, "tid", item.id]) }) }, _motion: function(can) {