diff --git a/frame.js b/frame.js index 26b464a0..92be96d0 100644 --- a/frame.js +++ b/frame.js @@ -39,7 +39,7 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { toast = toast||can.user.toastProcess(msg._can, _toast) }) } msg.option = can.core.List(msg.option, function(item) { return [chat._TOAST, ice.MSG_HANDLE].indexOf(item) > -1 && delete(msg[item])? undefined: item }) - can.getHeader(chat.TOPIC, function(topic) { can.request(event, {topic: topic}) }) + can.getHeader(chat.TOPIC, function(topic) { msg.Option(chat.TOPIC, topic) }) if (can.base.isUndefined(msg._daemon)) { var sub = msg._can can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(can)-1) if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) } @@ -52,8 +52,7 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { }, _static: function(event, can, msg, panel, cmds, cb) { if (can.user.isLocalFile) { var msg = can.request(event); msg.Clear(ice.MSG_APPEND) - var keys = can.core.Keys(panel._name, cmds.join(ice.FS)) - var res = Volcanos.meta.pack[keys]; res? msg.Copy(res): can.user.toast(can, "缺失数据") + var res = Volcanos.meta.pack[can.core.Keys(panel._name, cmds.join(ice.FS))]; res? msg.Copy(res): can.user.toast(can, "缺失数据") return can.base.isFunc(cb) && cb(msg), true } return false }, @@ -86,8 +85,8 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { }) Volcanos(chat.ONDAEMON, {_init: function(can, name) { if (can.user.isLocalFile) { return } can.misc.WSS(can, {type: html.CHROME, name: can.misc.Search(can, cli.DAEMON)||name||"", text: can.user.title()}, function(event, msg, cmd, arg) { if (!msg) { return } - var sub = can.ondaemon._list[msg.Option(ice.MSG_TARGET)]; can.base.isFunc(can.ondaemon[cmd])? - can.core.CallFunc(can.ondaemon[cmd], { can: can, sub: sub, msg: msg, cmd: cmd, arg: arg, cb: function() { msg.Reply() }, }): + var sub = can.ondaemon._list[msg.Option(ice.MSG_TARGET)]; can.base.isFunc(sub.ondaemon[cmd])? + can.core.CallFunc(sub.ondaemon[cmd], {can: can, sub: sub, msg: msg, cmd: cmd, arg: arg, cb: function() { msg.Reply() }}): can.onengine._search({}, can, msg, can, [chat._SEARCH, cmd].concat(arg), function() { msg.Reply() }) }) }, _list: [""], @@ -118,14 +117,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { Status: function(key, value) { if (can.base.isObject(key)) { return can.core.Item(key, sub.Status), key } can.page.Select(can, status, [[[html.DIV, key], html.SPAN]], function(target) { - if (value && value.indexOf && value.indexOf(ice.HTTP) == 0) { value = can.page.Format(html.A, value) } + if (can.base.beginWith(value, ice.HTTP)) { value = can.page.Format(html.A, value) } return can.base.isUndefined(value)? (value = target.innerHTML): (target.innerHTML = value) }); return value }, Action: function(key, value) { return can.page.SelectArgs(can, action, key, value)[0] }, Option: function(key, value) { return can.page.SelectArgs(can, option, key, value)[0] }, Update: function(event, cmds, cb, silent) { sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input(), cb, silent); return true }, - Focus: function() { can.page.Select(can, option, html.INPUT_ARGS, function(target, index) { index == 0 && target.focus() }) }, + Focus: function() { can.page.SelectOne(can, option, html.INPUT_ARGS, function(target) { target.focus() }) }, Input: function(cmds, save) { cmds = cmds && cmds.length > 0? cmds: can.page.SelectArgs(can, option, "").concat(can.page.SelectArgs(can, action, "")), cmds = can.base.trim(cmds) return !save || cmds[0] == ctx.ACTION || can.base.Eq(sub._history[sub._history.length-1], cmds) || sub._history.push(cmds), cmds @@ -140,7 +139,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { case lang.OBJECT: can.page.style(can, sub._target, style); break } sub.Mode() != meta.type && can.page.ClassList.add(can, field, sub.Mode()) - sub._trans = can.base.Copy(sub._trans||{}, can.core.Value(sub, [chat.ONACTION, "_trans"])) + sub._trans = can.base.Copy(sub._trans||{}, can.core.Value(sub, [chat.ONACTION, chat._TRANS])) meta.inputs && sub.onappend._option(sub, meta, sub._option, meta.msg) if (meta.msg) { var msg = sub.request(); msg.Copy(can.base.Obj(meta.msg)), sub.onappend._output(sub, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) } @@ -178,14 +177,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, _action: function(can, list, action, meta) { meta = meta||can.onaction||{}, action = action||can._action, can.onmotion.clear(can, action) return can.core.List(can.page.inputs(can, can.base.getValid(can.base.Obj(list), can.core.Value(can, [chat.ONACTION, mdb.LIST]), can.core.Item(meta))||[]), function(item) { - !can.base.isUndefined(item) && can.onappend.input(can, item == ""? /*空白*/ {type: html.SPACE}: - can.base.isString(item)? /*按键*/ {type: html.BUTTON, value: can.user.trans(can, item), onclick: function(event) { + !can.base.isUndefined(item) && can.onappend.input(can, item == ""? /* 空白 */ {type: html.SPACE}: + can.base.isString(item)? /* 按键 */ {type: html.BUTTON, value: can.user.trans(can, item), onclick: function(event) { var cb = meta[item]||meta[chat._ENGINE]; cb? can.core.CallFunc(cb, {event: event, can: can, button: item}): can.run(event, [ctx.ACTION, item].concat(can.sup.Input())) }, onkeydown: function(event) { if (event.key == lang.ENTER) { var cb = meta[item]||meta[chat._ENGINE]; cb? can.core.CallFunc(cb, {event: event, can: can, button: item}): can.run(event, [ctx.ACTION, item].concat(can.sup.Input())) - }}}: item.length > 0? /*列表*/ {type: html.SELECT, name: item[0], values: item.slice(1), onchange: function(event) { var button = item[event.target.selectedIndex+1] + }}}: item.length > 0? /* 列表 */ {type: html.SELECT, name: item[0], values: item.slice(1), onchange: function(event) { var button = item[event.target.selectedIndex+1] meta[item[0]]? can.core.CallFunc(meta[item[0]], [event, can, item[0], button]): meta[button]? can.core.CallFunc(meta[button], [event, can, button]): null - }}: /*其它*/ item, "", action) + }}: /* 其它 */ item, "", action) }), meta }, _output0: function(can, meta, event, cmds, cb, silent) { var msg = can.request(event); if (msg.RunAction(event, can, cmds)) { return } @@ -218,7 +217,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, can._outputs && can._outputs.push(sub), sub.sup = can sub._index = can._index, sub._msg = msg, sub.Conf(sub._args = can.base.ParseURL(display)) - sub._trans = can.base.Copy(sub._trans||{}, can._trans, can.core.Value(sub, [chat.ONACTION, "_trans"])) + sub._trans = can.base.Copy(sub._trans||{}, can._trans, can.core.Value(sub, [chat.ONACTION, chat._TRANS])) if (sub.onimport && can.base.isArray(sub.onimport.list) && sub.onimport.list.length > 0) { can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: can.page.inputs(can, sub.onimport.list) }) } @@ -226,8 +225,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.onmotion.clear(can, can._action), can.user.isMobile && can.ConfHeight() > can.ConfWidth() && can.onmotion.hidden(can, can._action) action === false || sub.onappend._action(sub, msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), action||can._action) action === false || sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), sub.onappend.tools(sub, msg) - can.core.List([chat.FLOAT, chat.FULL, chat.CMD], function(mode) { can.page.ClassList.has(can, can._target, mode) && sub.onlayout[mode](sub) }) can.user.isMobile && can.isCmdMode() && can.page.style(can, can._output, html.MAX_HEIGHT, can.ConfHeight()) + can.core.List([chat.FLOAT, chat.FULL, chat.CMD], function(mode) { can.page.ClassList.has(can, can._target, mode) && sub.onlayout[mode](sub) }) can.onmotion.story.auto(can, can._output), can.onaction._output(can, msg), can.base.isFunc(cb) && cb(msg) }, target: output}) }) @@ -332,11 +331,11 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }) }); return res }, figure: function(can, meta, target, cbs) { if ([html.BUTTON, html.SELECT].indexOf(meta.type) > -1) { return } - var input = meta.action||mdb.KEY; input != ice.AUTO && can.require(["/plugin/input/"+input+nfs._JS], function(can) { + var input = meta.action||mdb.KEY; input != ice.AUTO && can.require([chat.PLUGIN_INPUT+input+nfs._JS], function(can) { can.core.ItemCB(can.onfigure[input], function(key, on) { var last = target[key]; target[key] = function(event) { on(event, can, meta, function(cb) { function _cbs(sub, value, old) { can.onmotion.hidden(can, sub._target), can.base.isFunc(cbs)? cbs(sub, value, old): target.value = value||"", can.onmotion.delay(can, function() { can.onmotion.focus(can, target) }) } if (target._can) { return can.onmotion.toggle(can, target._can._target, true), can.base.isFunc(cb) && cb(target._can, _cbs) } - can.onappend._init(can, {type: html.INPUT, name: input, pos: chat.FLOAT, mode: meta.mode}, ["/plugin/input/"+input+nfs._JS], function(sub) { sub.Conf(meta) + can.onappend._init(can, {type: html.INPUT, name: input, pos: chat.FLOAT, mode: meta.mode}, [chat.PLUGIN_INPUT+input+nfs._JS], function(sub) { sub.Conf(meta) sub.run = function(event, cmds, cb) { var msg = can.request(event) if (meta.range) { for (var i = meta.range[0]; i < meta.range[1]; i += meta.range[2]||1) { msg.Push(mdb.VALUE, i) } cb(msg); return } (meta.run||can.run)(sub.request(event, can.Option()), cmds, cb, true) @@ -349,8 +348,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }) }, }) -Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||document.body - var height = can.page.height(), width = can.page.width() +Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||document.body; var height = can.page.height(), width = can.page.width() can.page.SelectChild(can, target, can.page.Keys(html.FIELDSET_HEAD, html.FIELDSET_FOOT), function(field) { height -= field.offsetHeight }) can.page.SelectChild(can, target, html.FIELDSET_LEFT, function(field) { can.page.styleHeight(can, field, height), can.user.isMobile || (width -= field.offsetWidth) @@ -388,21 +386,19 @@ Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||documen can.onmotion.toggle(can, view, show), view._toggle? view._toggle(event, show): can.onimport.layout && can.onimport.layout(can); return show } var gt = "❯", lt = "❮", down = lt, up = gt, button = {} var ui = can.page.Append(can, target||can._output, [{view: [chat.LAYOUT, html.TABLE], list: [ - {view: [chat.PROJECT, html.TD], list: [chat.PROJECT]}, {type: html.TD, list: [ - {type: html.TR, list: [{type: html.TR, list: [ - {view: [chat.CONTENT, html.TD], list: [{view: [chat.CONTENT]}, - {view: [[html.TOGGLE, chat.PROJECT]], list: [{text: [gt, html.DIV]}], _init: function(target) { - button[chat.PROJECT] = {target: target, show: lt, hide: gt}, target.onclick = function() { toggle(ui.project) } - }}, - {view: [[html.TOGGLE, chat.PROFILE]], list: [{text: [lt, html.DIV]}], _init: function(target) { - button[chat.PROFILE] = {target: target, show: gt, hide: lt}, target.onclick = function() { toggle(ui.profile) } - }}, - {view: [[html.TOGGLE, chat.DISPLAY]], list: [{text: [up, html.DIV]}], _init: function(target) { - button[chat.DISPLAY] = {target: target, show: down, hide: up}, target.onclick = function() { toggle(ui.display) } - }}, - ]}, {view: [chat.PROFILE, html.TD], list: [chat.PROFILE]}, - ]}]}, {view: [chat.DISPLAY, html.TR], list: [chat.DISPLAY]} - ]} + {view: [chat.PROJECT, html.TD], list: [chat.PROJECT]}, {type: html.TD, list: [ {type: html.TR, list: [{type: html.TR, list: [ + {view: [chat.CONTENT, html.TD], list: [chat.CONTENT, + {view: [[html.TOGGLE, chat.PROJECT]], list: [{text: [gt, html.DIV]}], _init: function(target) { + button[chat.PROJECT] = {target: target, show: lt, hide: gt}, target.onclick = function() { toggle(ui.project) } + }}, + {view: [[html.TOGGLE, chat.PROFILE]], list: [{text: [lt, html.DIV]}], _init: function(target) { + button[chat.PROFILE] = {target: target, show: gt, hide: lt}, target.onclick = function() { toggle(ui.profile) } + }}, + {view: [[html.TOGGLE, chat.DISPLAY]], list: [{text: [up, html.DIV]}], _init: function(target) { + button[chat.DISPLAY] = {target: target, show: down, hide: up}, target.onclick = function() { toggle(ui.display) } + }}, + ]}, {view: [chat.PROFILE, html.TD], list: [chat.PROFILE]}, + ]}]}, {view: [chat.DISPLAY, html.TR], list: [chat.DISPLAY]} ]} ] }]); function set(meta, button) { can.page.Appends(can, meta.target, [{text: [button, html.DIV]}]) } can.core.List([chat.PROJECT, chat.DISPLAY, chat.PROFILE], function(item) { var meta = button[item] ui[item]._hide = function() { set(meta, meta.hide) }, ui[item]._show = function() { set(meta, meta.show) } @@ -422,15 +418,9 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { }, }, auto: function(can, target) { var that = this; target = target||can._output - can.page.Select(can, target, wiki.STORY_ITEM, function(item) { var meta = item.dataset - can.page.style(can, item, can.base.Obj(meta.style)), can.core.CallFunc(that._hash[meta.type], [can, meta, target]) - }) - can.page.Select(can, target, html.INPUT_BUTTON, function(target) { - if (target.value == target.name) { target.value = can.user.trans(can, target.name) } - }) - can.page.Select(can, target, html.IFRAME, function(item) { - can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30) - }) + can.page.Select(can, target, wiki.STORY_ITEM, function(item) { var meta = item.dataset; can.page.style(can, item, can.base.Obj(meta.style)), can.core.CallFunc(that._hash[meta.type], [can, meta, target]) }) + can.page.Select(can, target, html.INPUT_BUTTON, function(target) { if (target.value == target.name) { target.value = can.user.trans(can, target.name) } }) + can.page.Select(can, target, html.IFRAME, function(item) { can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30) }) }, }, @@ -515,9 +505,7 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { Volcanos(chat.ONKEYMAP, {_init: function(can, target) { document.body.onclick = function(event) { if (can.page.tagis(event.target, html.SELECT, html.INPUT, html.TEXTAREA)) { return } - if (can.page.tagis(event.target, html.A) && can.user.isWebview) { - return event.shiftKey? window.outopen(event.target.href): can.user.open(event.target.href) - } + if (can.page.tagis(event.target, html.A) && can.user.isWebview) { return event.shiftKey? window.outopen(event.target.href): can.user.open(event.target.href) } can.page.Select(can, document.body, can.page.Keys("div.carte.float", "fieldset.input.key.float"), function(target) { can.page.Remove(can, target) }) } can.onkeymap._build(can), document.body.onkeydown = function(event) { @@ -534,16 +522,11 @@ Volcanos(chat.ONKEYMAP, {_init: function(can, target) { can._keylist = can.onkeymap._parse(event, can, msg.Option("model"), can._keylist, can._output) } }, - _build: function(can) { - can.core.Item(can.onkeymap._mode, function(item, value) { var engine = {list: {}} - can.core.Item(value, function(key, cb) { var map = engine - for (var i = 0; i < key.length; i++) { - if (!map.list[key[i]]) { map.list[key[i]] = {list: {}} } - map = map.list[key[i]]; if (i == key.length-1) { map.cb = cb } - } - }), can.onkeymap._engine[item] = engine - }) - }, + _build: function(can) { can.core.Item(can.onkeymap._mode, function(item, value) { var engine = {list: {}} + can.core.Item(value, function(key, cb) { var map = engine; for (var i = 0; i < key.length; i++) { + if (!map.list[key[i]]) { map.list[key[i]] = {list: {}} } map = map.list[key[i]]; if (i == key.length-1) { map.cb = cb } + } }), can.onkeymap._engine[item] = engine + }) }, _parse: function(event, can, mode, list, target) { list = list||[] if (event.metaKey && !can.user.isWebview) { return } if ([lang.META, lang.ALT, lang.CONTROL, lang.SHIFT].indexOf(event.key) > -1) { return list } list.push(event.key); for (var pre = 0; pre < list.length; pre++) { if ("0" <= list[pre] && list[pre] <= "9") { continue } break } diff --git a/lib/base.js b/lib/base.js index 64f8443b..630269a3 100644 --- a/lib/base.js +++ b/lib/base.js @@ -99,7 +99,7 @@ Volcanos("base", { Date: function(time) { var now = new Date() if (typeof time == lang.STRING && time != "") { var ls = time.split(ice.SP) var vs = ls[0].split("-"); now.setFullYear(parseInt(vs[0])), now.setMonth(parseInt(vs[1])-1), now.setDate(parseInt(vs[2])) - var vs = ls[1].split(":"); now.setHours(parseInt(vs[0])), now.setMinutes(parseInt(vs[1])), now.setSeconds(parseInt(vs[2])) + var vs = ls[1].split(ice.DF); now.setHours(parseInt(vs[0])), now.setMinutes(parseInt(vs[1])), now.setSeconds(parseInt(vs[2])) } else if (time) { now = time } return now }, Time: function(time, fmt) { var now = this.Date(time) @@ -141,7 +141,7 @@ Volcanos("base", { } }, - beginWith: function(str, begin) { return str.trim().indexOf(begin) == 0 }, + beginWith: function(str, begin) { return typeof str == lang.STRING && str.trim().indexOf(begin) == 0 }, endWith: function(str, end) { return str.lastIndexOf(end) + end.length == str.length }, trim: function(args) { if (this.isString(args)) { return args.trim() } if (this.isArray(args)) { for (var i = args.length-1; i >= 0; i--) { if (!args[i]) { args.pop() } else { break } } } diff --git a/lib/core.js b/lib/core.js index cb2bf864..5ce43d52 100644 --- a/lib/core.js +++ b/lib/core.js @@ -53,12 +53,12 @@ Volcanos("core", { case mdb.NAME: return {type: type = html.TEXT, name: item} case mdb.TEXT: return {type: type = html.TEXTAREA, name: item} default: var ls = this.Split(item, " ", ":=@"), res = {type: type, name: ls[0]}; for (var i = 1; i < ls.length; i += 2) { switch (ls[i]) { - case ":": res[mdb.TYPE] = ls[i+1]; break - case "=": + case ice.DF: res[mdb.TYPE] = ls[i+1]; break + case ice.EQ: if (res[mdb.TYPE] == html.SELECT) { res.values = this.Split(ls[i+1]); for (var j = 1; j < res.values.length; j++) { if (res.values[0] == "" || res.values[0] == res.values[j]) { res.value = res.values[0], res.values = res.values.slice(1); break } } } else { res.value = ls[i+1] } break - case "@": res[ctx.ACTION] = ls[i+1]; break + case ice.AT: res[ctx.ACTION] = ls[i+1]; break } } return res } }, CallFunc: function(func, args, mod) { args = args||{}; var can = args["can"]||args[0], msg = args["msg"]||args[1] @@ -108,8 +108,8 @@ Volcanos("core", { if (typeof cb == lang.FUNCTION) { cb(k, meta[k]) } else { cb[k] = function(event) { meta[k](event, can, item) } } })(k) } } return list }, - Timer: shy("定时器, value, [1,2,3,4], {interval, length}", function(interval, cb, cbs) { - var timer = {stop: false}; function loop(i) { + Timer: shy("定时器, value, [1,2,3,4], {interval, length}", function(interval, cb, cbs) { var timer = {stop: false} + function loop(i) { timer.stop || i >= interval.length && interval.length >= 0 || cb(timer, interval.interval||interval[i], i, interval)? typeof cbs == lang.FUNCTION && cbs(timer, interval): setTimeout(function() { loop(i+1) }, interval.interval||interval[i+1]) } interval = typeof interval == lang.OBJECT? interval: [interval]; if (interval.interval == 0) { return cb(), timer } diff --git a/lib/misc.js b/lib/misc.js index b867df28..9e1e2ccd 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -7,7 +7,7 @@ Volcanos("misc", {Message: function(event, can) { var msg = {} } return false }, Display: function(file) { msg.Option(ice.MSG_DISPLAY, file) }, - DisplayStory: function(file) { msg.Option(ice.MSG_DISPLAY, "/plugin/story/"+file) }, + DisplayStory: function(file) { msg.Option(ice.MSG_DISPLAY, chat.PLUGIN_STORY+file) }, OptionStatus: function() { return msg.Option(ice.MSG_STATUS) }, OptionProcess: function() { return msg.Option(ice.MSG_PROCESS) }, SearchOrOption: function(key) { return can.misc.Search(can, key)||msg.Option(key) }, @@ -108,9 +108,7 @@ Volcanos("misc", {Message: function(event, can) { var msg = {} POST: function(can, msg, url, form, cb) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr xhr.open(msg._method||web.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return } try { var res = JSON.parse(xhr.responseText) } catch (e) { var res = {result: [xhr.responseText]} } msg.Option("_cost", new Date() - begin) - if (xhr.status == 200) { if (can.misc.Debug(msg._can, msg, web.POST, res)) { debugger } - return can.base.isFunc(cb) && cb(msg.Copy(res)) - } can.misc.Warn(xhr.status, res, url, form) + if (xhr.status == 200) { return can.base.isFunc(cb) && cb(msg.Copy(res)) } can.misc.Warn(xhr.status, res, url, form) }, xhr.setRequestHeader(web.Accept, msg._accept||web.ContentJSON) if (msg._upload) { @@ -121,7 +119,6 @@ Volcanos("misc", {Message: function(event, can) { var msg = {} var data = can.core.Items(form, function(value, index, key) { return key+ice.EQ+encodeURIComponent(value) }).join("&") xhr.setRequestHeader(web.ContentType, web.ContentFORM) } - if (can.misc.Debug(msg._can, msg, web.POST, data)) { debugger } try { xhr.send(data) } catch(e) { can.misc.Warn(e) } }, GET: function(can, url, cb) { var xhr = new XMLHttpRequest() @@ -178,24 +175,24 @@ Volcanos("misc", {Message: function(event, can) { var msg = {} Search: function(can, key, value) { var args = {} if (value == undefined && can.base.isString(key)) { var ls = location.pathname.split(ice.PS); if (ls[1] == chat.SHARE) { args[chat.SHARE] = ls[2] } for (var i = 2; i < ls.length; i += 2) { if (kit.Dict(ice.POD, true, ice.CMD, true, web.WEBSITE, true)[ls[i]]) { args[ls[i]] = ls[i+1] } } - } location.search && location.search.slice(1).split("&").forEach(function(item) { var x = item.split("="); x[1] != "" && (args[x[0]] = decodeURIComponent(x[1])) }) + } location.search && location.search.slice(1).split("&").forEach(function(item) { var x = item.split(ice.EQ); x[1] != "" && (args[x[0]] = decodeURIComponent(x[1])) }) if (can.base.isUndefined(key)) { return args } else if (can.base.isObject(key)) { can.core.Item(key, function(key, value) { can.base.isUndefined(value) || (args[key] = value), args[key] == "" && delete(args[key]) }) } else if (can.base.isUndefined(value)) { return args[key] } else { args[key] = value, args[key] == "" && delete(args[key]) } - var search = can.core.Item(args, function(key, value) { return key+"="+encodeURIComponent(value) }).join("&") + var search = can.core.Item(args, function(key, value) { return key+ice.EQ+encodeURIComponent(value) }).join("&") return search? location.search = search: location.href = location.pathname }, CookieSessid: function(can, value, path) { return can.misc.Cookie(can, ice.MSG_SESSID+"_"+can.base.replaceAll(location.host, ice.PT, "_", ice.DF, "_"), value, path) }, Cookie: function(can, key, value, path) { - function set(k, v) { document.cookie = k+"="+v+";path="+(path||ice.PS) } + function set(k, v) { document.cookie = k+ice.EQ+v+";path="+(path||ice.PS) } if (can.base.isObject(key)) { for (var k in key) { set(k, key[k]) } key = undefined } if (can.base.isUndefined(key)) { var cs = {} - return document.cookie.split("; ").forEach(function(item) { var ls = item.split("="); cs[ls[0]] = ls[1] }), cs + return document.cookie.split("; ").forEach(function(item) { var ls = item.split(ice.EQ); cs[ls[0]] = ls[1] }), cs } can.base.isUndefined(value) || set(key, value) var val = (new RegExp(key+"=([^;]*);?")).exec(document.cookie) diff --git a/lib/page.js b/lib/page.js index fd048293..6b9110a5 100644 --- a/lib/page.js +++ b/lib/page.js @@ -21,6 +21,7 @@ Volcanos("page", {ClassList: { return can.page.Select(can, option, key? "textarea[name="+key+"],"+"input[name="+key+"],"+"select[name="+key+"]": ".args", cb) }, SelectChild: function(can, target, key, cb) { var i = 0; return can.page.Select(can, target, key, function(node) { if (node.parentNode == target) { return cb(node, i++) } }) }, + SelectOne: function(can, target, key, cb) { return can.page.Select(can, target, key, function(target, index) { index == 0 && can.base.isFunc(cb) && cb(target) })[0] }, Select: function(can, target, key, cb, interval, cbs) { if (key == ice.PT) { cb(target); return [] } return can.core.List(target && target.querySelectorAll(can.page.Keys(key)), cb, interval, cbs) }, diff --git a/panel/footer.js b/panel/footer.js index 6f4e90df..20b24e5e 100644 --- a/panel/footer.js +++ b/panel/footer.js @@ -85,7 +85,7 @@ Volcanos(chat.ONEXPORT, {help: "导出数据", return ui }, ntip: function(can) { can.onexport.float(can, can._tips, "ntip", function(value, key, index, line) { - can.onappend.plugin(can, {type: chat.SRORY, mode: chat.FLOAT, index: "web.code.inner", args: ["usr/volcanos/"].concat(line.fileline.split(":"))}, function(sub) { + can.onappend.plugin(can, {type: chat.SRORY, mode: chat.FLOAT, index: "web.code.inner", args: ["usr/volcanos/"].concat(line.fileline.split(ice.DF))}, function(sub) { can.getActionSize(function(left, top, width, height) { left = left||0, top = top||0 sub.onimport.size(sub, sub.ConfHeight(height/2), sub.ConfWidth(width)) can.onmotion.move(can, sub._target, {left: left, top: top+height/4}) diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index fc062b8d..63298a0e 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -20,12 +20,13 @@ fieldset.inner>div.output div.content td.text span.keyword { color:blue; font-we fieldset.inner>div.output div.content td.text span.string { color:magenta; } fieldset.inner>div.output div.content td.text span.constant { color:magenta; } fieldset.inner>div.output div.content td.text span.datatype { color:green; } -fieldset.inner>div.output div.content td.text span.function { color:purple; font-weight:bold; } -fieldset.inner.float>div.output div.content td.text span.keyword { color:yellow; font-weight:bold; } -fieldset.inner.float>div.output div.content td.text span.datatype { color:lightgreen; } -body.black fieldset.inner>div.output div.content td.text span.keyword { color:yellow; font-weight:bold; } -body.black fieldset.inner>div.output div.content td.text span.datatype { color:lightgreen; } -body.black fieldset.inner>div.output div.content td.text span.function { color:cyan; font-weight:bold; } +fieldset.inner>div.output div.content td.text span.function { color:purple; } +fieldset.inner.float>div.output div.content td.text span.keyword { color:yellow; } +fieldset.inner.float>div.output div.content td.text span.datatype { color:cyan; } +fieldset.inner.float>div.output div.content td.text span.function { color:lightgreen; } +body.black fieldset.inner>div.output div.content td.text span.keyword { color:yellow; } +body.black fieldset.inner>div.output div.content td.text span.datatype { color:cyan; } +body.black fieldset.inner>div.output div.content td.text span.function { color:lightgreen; } fieldset.inner>div.output td.content iframe { border:0; } fieldset.inner>div.output td.profile iframe { border:0; } fieldset.inner.float>div.status { display:none; } diff --git a/plugin/local/code/inner/syntax.js b/plugin/local/code/inner/syntax.js index c07ef6cf..3918bf5d 100644 --- a/plugin/local/code/inner/syntax.js +++ b/plugin/local/code/inner/syntax.js @@ -271,7 +271,9 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", }, keyword: { "var": code.KEYWORD, + "new": code.KEYWORD, "typeof": code.KEYWORD, + "function": code.KEYWORD, "if": code.KEYWORD, "else": code.KEYWORD, @@ -284,35 +286,49 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", "default": code.KEYWORD, "return": code.KEYWORD, "debugger": code.KEYWORD, - - "can": code.KEYWORD, - "sub": code.KEYWORD, - "sup": code.KEYWORD, - "msg": code.KEYWORD, - - "ice": code.KEYWORD, - "kit": code.KEYWORD, - - "event": code.KEYWORD, - "target": code.KEYWORD, - "window": code.KEYWORD, - "location": code.KEYWORD, - "document": code.KEYWORD, - "history": code.KEYWORD, + "try": code.KEYWORD, + "catch": code.KEYWORD, "null": code.CONSTANT, "true": code.CONSTANT, "false": code.CONSTANT, "undefined": code.CONSTANT, - "function": code.FUNCTION, - "arguments": code.FUNCTION, - "this": code.FUNCTION, + "event": code.DATATYPE, + "target": code.DATATYPE, + "window": code.DATATYPE, + "location": code.DATATYPE, + "navigator": code.DATATYPE, + "document": code.DATATYPE, + "history": code.DATATYPE, + "console": code.DATATYPE, + "arguments": code.DATATYPE, + "this": code.DATATYPE, + "JSON": code.DATATYPE, + "Date": code.DATATYPE, + "Error": code.DATATYPE, + "XMLHttpRequest": code.DATATYPE, + + "encodeURIComponent": code.FUNCTION, + "decodeURIComponent": code.FUNCTION, + "setTimeout": code.FUNCTION, + "parseFloat": code.FUNCTION, + "parseInt": code.FUNCTION, "delete": code.FUNCTION, - "Volcanos": code.FUNCTION, + "confirm": code.FUNCTION, + "alert": code.FUNCTION, + + "kit": code.DATATYPE, + "ice": code.DATATYPE, + "can": code.DATATYPE, + "sub": code.DATATYPE, + "sup": code.DATATYPE, + "msg": code.DATATYPE, + "shy": code.FUNCTION, - "cb": code.FUNCTION, "cbs": code.FUNCTION, + "cb": code.FUNCTION, + "Volcanos": code.FUNCTION, }, }, css: { diff --git a/plugin/local/wiki/draw.js b/plugin/local/wiki/draw.js index 09aa4872..4497d150 100644 --- a/plugin/local/wiki/draw.js +++ b/plugin/local/wiki/draw.js @@ -150,7 +150,7 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", data: {size: {}, copy: []}, show: function(can, target, figure) { return can.onexport._size(can, target, figure) } }, - text: { // hi + text: { // hi data: {points: 1, size: {}, copy: [html.INNER]}, draw: function(event, can, point, style) { if (point.length < 1 || event.type == "mousemove") { return } var p0 = point[0], text = style&&style.inner||can.user.prompt(mdb.TEXT) @@ -185,7 +185,7 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", }, text: function(can, data, target) { return data.x = target.Val(svg.X)+target.Val(html.WIDTH)/2, data.y = target.Val(svg.Y)+target.Val(html.HEIGHT)/2, data }, }, - line: { // + line: { // data: {points: 2, size: {x: svg.X1, y: svg.Y1}, copy: [svg.X1, svg.Y1, svg.X2, svg.Y2]}, grid: function(event, can, point) { var target = event.target if (target == can.svg) { return } @@ -440,7 +440,7 @@ Volcanos(chat.ONDETAIL, {help: "组件详情", list: [cli.START, ice.RUN, ice.CO Volcanos(chat.ONEXPORT, {help: "导出数据", list: [svg.GROUP, "figure", "index", "pos"], _show: function(can, target) { var figure = can.onfigure._get(can, target) function show() { return can.onexport._size(can, target, figure)+ice.SP+can.onexport._position(can, target, figure) } - can.Status("figure", target.tagName+":"+target.Value(svg.PID)+ice.SP+(figure? (figure.show||show)(can, target, figure): "")) + can.Status("figure", target.tagName+ice.DF+target.Value(svg.PID)+ice.SP+(figure? (figure.show||show)(can, target, figure): "")) can.Status(svg.GROUP, target.Groups()||can.group.Groups()||html.SVG) can.Status("index", target.Value("index")) }, diff --git a/plugin/story/parse.js b/plugin/story/parse.js index ff760be4..0e294d90 100644 --- a/plugin/story/parse.js +++ b/plugin/story/parse.js @@ -20,9 +20,9 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", list: ["{", "}", html.HEAD, html. var meta = type? {type: type, name: ls[0]}: {type: ls[0]} } else { var meta = {name: ls[0]}; for (var i = 1; i < ls.length; i += 2) { switch (ls[i]) { - case "@": meta.action = ls[i+1]; break - case "=": meta.value = ls[i+1]; break - case ":": meta.type = ls[i+1]; break + case ice.AT: meta.action = ls[i+1]; break + case ice.EQ: meta.value = ls[i+1]; break + case ice.DF: meta.type = ls[i+1]; break } } } diff --git a/proto.js b/proto.js index 5b38ca61..5e180a6f 100644 --- a/proto.js +++ b/proto.js @@ -101,7 +101,7 @@ var ssh = { } var nfs = { PATH: "path", FILE: "file", LINE: "line", SIZE: "size", - SAVE: "save", LOAD: "load", TAGS: "tags", FIND: "find", GREP: "grep", + SAVE: "save", LOAD: "load", FIND: "find", GREP: "grep", TAGS: "tags", DIR: "dir", CAT: "cat", DEFS: "defs", TRASH: "trash", SCRIPT: "script", CONTENT: "content", DIR_ROOT: "dir_root", PWD: "./", HTML: "html", CSS: "css", JS: "js", GO: "go", SH: "sh", CSV: "csv", JSON: "json", ZML: "zml", IML: "iml", TXT: "txt", PNG: "png", @@ -111,7 +111,7 @@ var tcp = { HOST: "host", PORT: "port", } var lex = { - SPLIT: "split", PREFIX: "prefix", + SPLIT: "split", PREFIX: "prefix", SUFFIX: "suffix", } var gdb = { SIGNAL: "signal", @@ -171,6 +171,8 @@ var chat = { PLUGIN_STATE_JS: "/plugin/state.js", PLUGIN_INPUT_JS: "/plugin/input.js", PLUGIN_TABLE_JS: "/plugin/table.js", ONENGINE: "onengine", ONDAEMON: "ondaemon", ONAPPEND: "onappend", ONLAYOUT: "onlayout", ONMOTION: "onmotion", ONKEYMAP: "onkeymap", ONIMPORT: "onimport", ONSYNTAX: "onsyntax", ONFIGURE: "onfigure", ONACTION: "onaction", ONDETAIL: "ondetail", ONEXPORT: "onexport", ONPLUGIN: "onplugin", + PLUGIN_INPUT: "/plugin/input/", + PLUGIN_STORY: "/plugin/story/", ONMAIN: "onmain", ONLOGIN: "onlogin", ONSEARCH: "onsearch", ONREMOTE: "onremote", ONSIZE: "onsize", ONTOAST: "ontoast", ONSHARE: "onshare", ONPRINT: "onprint", @@ -178,7 +180,7 @@ var chat = { ONSTORM_SELECT: "onstorm_select", ONACTION_NOTOOL: "onaction_notool", ONACTION_TOUCH: "onaction_touch", ONACTION_CMD: "onaction_cmd", ONOPENSEARCH: "onopensearch", ONSEARCH_FOCUS: "onsearch_focus", ONCOMMAND_FOCUS: "oncommand_focus", - _INIT: "_init", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1", + _INIT: "_init", _TRANS: "_trans", _ENGINE: "_engine", _SEARCH: "_search", _OUTPUTS_CURRENT: "_outputs.-1", _NAMES: "_names", _TOAST: "_toast", } var team = { @@ -295,7 +297,6 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", cache: }, setHeader: function(key, value) { return can.set("Header", key, value) }, getHeader: function(key, cb) { return can.get("Header", key, cb) }, - setRiver: function(key, value) { return can.set("River", key, value) }, setAction: function(key, value) { return can.set("Action", key, value) }, getAction: function(key, cb) { return can.get("Action", key, cb) }, getActionSize: function(cb) { return can.get("Action", "size", cb) }, @@ -314,7 +315,7 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", cache: for (var i = 0; i < arguments.length; i += 2) { if (typeof key == lang.OBJECT) { res = can.core.Value(can._conf, arguments[i]), i--; continue } res = can.core.Value(can._conf, arguments[i], arguments[i+1]) - } return res == undefined && key.indexOf(ctx.FEATURE+ice.PT) == -1? can.Conf(can.core.Keys(ctx.FEATURE, key)): res + } return can.base.isUndefined(res) && key.indexOf(ctx.FEATURE+ice.PT) == -1? can.Conf(can.core.Keys(ctx.FEATURE, key)): res }, _conf: {}, }; can = can||{}, kit.proto(can, proto), kit.proto(proto, meta), _can_path = _can_name||_can_path