diff --git a/frame.js b/frame.js index f91395ed..ebc683b8 100644 --- a/frame.js +++ b/frame.js @@ -253,7 +253,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { action === false || can.onmotion.clear(can, can._action), sub.onappend._action(sub, can.Conf(ice.MSG_ACTION)||msg.Option(ice.MSG_ACTION), action||can._action) action === false || sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS)), can.user.isMobile || sub.onappend.tools(sub, msg) - can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, ""), can.onappend.style(sub, sub.Conf(ctx.STYLE)) + // can.page.style(can, can._output, html.HEIGHT, "", html.WIDTH, ""), can.onappend.style(sub, sub.Conf(ctx.STYLE)) + can.page.style(can, can._output, html.HEIGHT, ""), can.onappend.style(sub, sub.Conf(ctx.STYLE)) + can.onappend.style(sub, sub.Conf(ctx.STYLE)) if (can.isFullMode() || can.isCmdMode()) { can.onimport.size(can, can.page.height(), can.page.width(), true) } can.onmotion.story.auto(can, can._output), can.onexport.output(can, msg), can.base.isFunc(cb) && cb(msg) }, target: output}) diff --git a/index.css b/index.css index b78bfb32..a36088fa 100644 --- a/index.css +++ b/index.css @@ -218,6 +218,8 @@ body { --create-bg-color:blue; --create-fg-color:white; --disable-fg-color:gray; + --code-bg-color:black; + --code-fg-color:silver; --code-comment:darkgray; --code-keyword:darkblue; --code-package:blue; diff --git a/lib/misc.js b/lib/misc.js index 2e973893..65400447 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -71,11 +71,12 @@ Volcanos("misc", { var form = {cmds: cmds}; can.core.List(msg.option, function(key) { !can.base.isIn(key, "log.caller") && msg[key] && (form[key] = msg[key]) }) can.misc.POST(can, msg, can.base.MergeURL(dataset.names.toLowerCase(), ice.MSG_INDEX, _can._index), form, cb) }, - POST: function(can, msg, url, form, cb) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr + POST: function(can, msg, url, form, cb, cbs) { 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) { return msg.detail || (msg.detail = res.detail), can.base.isFunc(cb) && cb(msg.Copy(res)) } can.user.toastFailure(can, xhr.response, url), can.misc.Warn(xhr.status, res, url, form) + cbs && cbs(xhr) }, xhr.setRequestHeader(web.Accept, msg._accept||web.ContentJSON) if (msg._upload) { var data = new FormData(); can.core.ItemForm(form, function(v, i, k) { data.append(k, v) }) data.append(ice.MSG_UPLOAD, web.UPLOAD), data.append(web.UPLOAD, msg._upload) @@ -84,7 +85,7 @@ Volcanos("misc", { if (data) { xhr.open(msg._method||web.GET, url += (url.indexOf(ice.QS) == -1? ice.QS: "&")+data) } } else { var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&") xhr.setRequestHeader(web.ContentType, web.ContentFORM) - } try { xhr.send(data) } catch(e) { can.misc.Warn(e) } + } try { xhr.send(data) } catch(e) { can.misc.Warn(e), cbs && cbs(e) } }, WSS: function(can, args, cb, onopen, onclose, onerror, _msg) { if (can.user.isIE) { return } var url = location.protocol.replace(ice.HTTP, "ws")+"//"+location.host+"/space/" diff --git a/lib/user.js b/lib/user.js index cc0ff031..47b72a9c 100644 --- a/lib/user.js +++ b/lib/user.js @@ -28,7 +28,12 @@ Volcanos("user", { isLandscape: function() { return window.innerWidth > window.innerHeight }, mod: { isPod: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0 || location.pathname.indexOf("/x/") == 0), - isCmd: location && location.pathname && (location.pathname.indexOf("/chat/pod/") == 0 && location.pathname.indexOf("/cmd/") > 0 || location.pathname.indexOf("/chat/cmd/") == 0 || location.pathname.indexOf("/help/") == 0), + isCmd: location && location.pathname && ( + location.pathname.indexOf("/chat/pod/") == 0 && location.pathname.indexOf("/cmd/") > 0 + || location.pathname.indexOf("/chat/cmd/") == 0 + || location.pathname.indexOf("/wiki/portal/") == 0 + || location.pathname.indexOf("/help/") == 0 + ), }, alert: function(text) { alert(JSON.stringify(text)) }, confirm: function(text) { return confirm(JSON.stringify(text)) }, diff --git a/panel/header.js b/panel/header.js index 588b29d1..e6c28cf3 100644 --- a/panel/header.js +++ b/panel/header.js @@ -57,6 +57,7 @@ Volcanos(chat.ONACTION, {_init: function(can) { }, onsize: function(can) { can.ConfHeight(can._target.offsetHeight), can.ConfWidth(can._target.offsetWidth) }, onmain: function(can) { + if (can.base.beginWith(location.pathname, "/wiki/portal/", "/chat/cmd/web.wiki.portal/")) { return can.onengine.signal(can, chat.ONLOGIN) } can.run({}, [], function(msg) { if (!can.Conf(aaa.USERNICK, msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME))) { return msg.Option(chat.SSO)? can.user.jumps(msg.Option(chat.SSO)): can.user.login(can, function() { can.onengine.signal(can, chat.ONMAIN, msg) }, msg.Option(aaa.LOGIN)) } can.user.info.usernick = can.Conf(aaa.USERNICK), can.user.info.userrole = msg.Option(ice.MSG_USERROLE), can.user.info.avatar = msg.Option(aaa.AVATAR), can.user.info.background = msg.Option(aaa.BACKGROUND) diff --git a/plugin/local/wiki/draw.js b/plugin/local/wiki/draw.js index 15a8bf12..b6a5781e 100644 --- a/plugin/local/wiki/draw.js +++ b/plugin/local/wiki/draw.js @@ -16,7 +16,9 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( if (value == ice.AUTO) { return target.removeAttribute(key) } if (key == html.INNER) { return value != undefined && (target.innerHTML = value), target.innerHTML } if (key == ice.SHIP) { return value != undefined && target.setAttribute(key, JSON.stringify(value)), can.base.Obj(target.getAttribute(key), []) } - return value != undefined && target.setAttribute(key, value), target.getAttribute(key) || can.core.Value(target[key], "baseVal.value") || can.core.Value(target[key], "baseVal") || undefined + try { + return value != undefined && target.setAttribute(key, value), target.getAttribute(key) || can.core.Value(target[key], "baseVal.value") || can.core.Value(target[key], "baseVal") || undefined + } catch(e) { } }, target.Val = function(key, value) { return parseInt(target.Value(key, value == undefined? value: parseInt(value)||0))||0 } target.Group = function() { for (var node = target; node; node = node.parentNode) { if (can.page.tagis(node, svg.G, html.SVG)) { return node } } return can.svg } target.Groups = function() { if (target == can.svg) { return html.SVG } var list = [] @@ -217,7 +219,6 @@ Volcanos(chat.ONEXPORT, {list: [svg.GROUP, svg.FIGURE, ctx.INDEX, "pos"], can.Status(ctx.INDEX, target.Value(ctx.INDEX)||"") }, content: function(can, target) { return ['", target? target.innerHTML: "", ""]).join("") }, cursor: function(event, can, target) { diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index 1fe74c50..9d0718b7 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -1,4 +1,4 @@ -Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear(can), can.Conf("padding", 10) +Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear(can), can.Conf(html.PADDING, 10) can.page.Modify(can, target, msg.Result()) can.page.Select(can, target, wiki.STORY_ITEM, function(target) { var meta = target.dataset||{} can.core.CallFunc([can.onimport, can.onimport[meta.name]? meta.name: meta.type||target.tagName.toLowerCase()], [can, meta, target]) @@ -58,7 +58,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( can.page.Select(can, target, html.TD, function(item) { can.onmotion.copy(can, item) }) }, chart: function(can, meta, target) { - can.page.style(can, target, html.MAX_WIDTH, can.ConfWidth(), html.OVERFLOW, ice.AUTO) + can.page.style(can, target, html.MAX_WIDTH, can.ConfWidth()-2*can.Conf(html.PADDING), html.OVERFLOW, ice.AUTO) if (!meta.fg && !meta.bg) { target.className.baseVal = "story auto" } target.onclick = function(event) { can.misc.Event(event, can, function(msg) { meta.index && can.onappend._float(can, meta.index, can.base.Obj(meta.args, []).concat([event.target.innerHTML])) @@ -70,14 +70,14 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( }) } }, image: function(can, meta, target) { - can.page.style(can, target, html.MAX_HEIGHT, can.base.Min(can.ConfHeight()-2*can.Conf("padding"), window.innerHeight/2), html.MAX_WIDTH, can.ConfWidth()-2*can.Conf("padding")) + can.page.style(can, target, html.MAX_HEIGHT, can.base.Min(can.ConfHeight()-2*can.Conf(html.PADDING), window.innerHeight/2), html.MAX_WIDTH, can.ConfWidth()-2*can.Conf(html.PADDING)) }, video: function(can, meta, target) { - can.page.style(can, target, html.MAX_HEIGHT, can.base.Min(can.ConfHeight()-2*can.Conf("padding"), window.innerHeight/2), html.MAX_WIDTH, can.ConfWidth()-2*can.Conf("padding")) + can.page.style(can, target, html.MAX_HEIGHT, can.base.Min(can.ConfHeight()-2*can.Conf(html.PADDING), window.innerHeight/2), html.MAX_WIDTH, can.ConfWidth()-2*can.Conf(html.PADDING)) }, audio: function(can, meta, target) {}, - layout: function(can) { var height = can.ConfHeight(), width = can.ConfWidth() + layout: function(can) { var height = can.ConfHeight(), width = can.ConfWidth(), padding = can.Conf(html.PADDING) can.isCmdMode() && can.ConfHeight(can.page.height()) if (can.sup._navmenu) { can.page.style(can, can.sup._navmenu, html.HEIGHT, can.ConfHeight()) can.page.style(can, can._output, html.HEIGHT, height, html.WIDTH, width = can.ConfWidth()-can.sup._navmenu.offsetWidth, "clear", "none", "float", "left") @@ -85,10 +85,12 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( can.isCmdMode() && can.ConfHeight(can.page.height()) && can.page.styleHeight(can, can._output, "") } can.core.List(can._plugins, function(sub) { - sub.ConfHeight(sub.Conf("_height")||can.base.Min(300, height-300)), sub.ConfWidth(width-(can.user.isWindows? 40: 20)) - sub.onimport.size(sub, can.base.Min(300, height-300), width-(can.user.isWindows? 40: 20), true) + sub.ConfHeight(sub.Conf("_height")||can.base.Min(300, height-300)), sub.ConfWidth(width-(can.user.isWindows? 4*padding: 2*padding)) + sub.onimport.size(sub, can.base.Min(300, height-300), width-(can.user.isWindows? 4*padding: 2*padding), true) + }) + can.page.Select(can, can._output, can.page.Keys(html.IMG, html.VIDEO), function(target) { + can.page.style(can, target, html.MAX_HEIGHT, height-2*padding, html.MAX_WIDTH, width-2*padding) }) - can.page.Select(can, can._output, can.page.Keys(html.IMG, html.VIDEO), function(target) { can.page.style(can, target, html.MAX_HEIGHT, height-20, html.MAX_WIDTH, width-20) }) }, }, [""]) Volcanos(chat.ONACTION, {_trans: {view: "视图"}, diff --git a/plugin/state.js b/plugin/state.js index a29a9742..caae7cde 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -62,7 +62,7 @@ Volcanos(chat.ONIMPORT, { (can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(height), html.WIDTH, can.ConfWidth(width), html.MAX_HEIGHT, "", html.MAX_WIDTH, ""), can.page.style(can, can._target, html.WIDTH, can.ConfWidth(width))) var sub = can.core.Value(can, chat._OUTPUTS_CURRENT); if (!sub) { return can.Mode(mode), auto } sub.ConfHeight(can.ConfHeight()), sub.ConfWidth(can.ConfWidth()) - if (mode) { sub.Mode(can.Mode(mode)), sub.onlayout[mode](sub) } else { sub.onlayout._init(sub) } return auto + if (mode) { sub.Mode(can.Mode(mode)), sub.onlayout[mode](sub, height, width) } else { sub.onlayout._init(sub, height, width) } return auto }, change: function(event, can, name, value, cb) { return can.page.SelectArgs(can, can._option, "", function(input) { if (input.name != name || value == input.value) { return } can.page.Select(can, input.parentNode, "span.value", function(target) { target.innerText = value }) diff --git a/plugin/table.js b/plugin/table.js index 86b4462d..d0802415 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -152,14 +152,14 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( }, }) Volcanos(chat.ONLAYOUT, { - _init: function(can) { can.core.CallFunc([can.onimport, html.LAYOUT], {can: can}) }, - simple: function(can) { can.onlayout._init(can) }, - output: function(can) { can.onlayout._init(can) }, - float: function(can) { can.onlayout._init(can) }, - full: function(can) { can.onlayout._init(can) }, - cmd: function(can) { can.onlayout._init(can) - can.page.style(can, can._output, html.MAX_HEIGHT, can.ConfHeight()||window.innerHeight-2*html.ACTION_HEIGHT) - can.page.style(can, can._output, html.MAX_WIDTH, can.ConfWidth()||window.innerWidth) + _init: function(can, height, width) { can.core.CallFunc([can.onimport, html.LAYOUT], {can: can, height: height, width: width}) }, + simple: function(can, height, width) { can.onlayout._init(can, height, width) }, + output: function(can, height, width) { can.onlayout._init(can, height, width) }, + float: function(can, height, width) { can.onlayout._init(can, height, width) }, + full: function(can, height, width) { can.onlayout._init(can, height, width) }, + cmd: function(can, height, width) { can.onlayout._init(can, height, width) + can.page.style(can, can._output, html.MAX_HEIGHT, height||can.ConfHeight()||window.innerHeight-2*html.ACTION_HEIGHT) + can.page.style(can, can._output, html.MAX_WIDTH, width||can.ConfWidth()||window.innerWidth) }, }) Volcanos(chat.ONEXPORT, { diff --git a/proto.js b/proto.js index b924f5f0..db5518f9 100644 --- a/proto.js +++ b/proto.js @@ -13,7 +13,7 @@ var ice = { TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", PS: "/", PT: ".", FS: ",", QS: "?", NL: "\n", LT: "<", GT: ">", OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process", - AUTO: "auto", + AUTO: "auto", HOME: "home", HTTP: "http", HTML: "html", LIST: "list", BACK: "back", SHOW: "show", HIDE: "hide", HELP: "help", COPY: "copy", VIEW: "view", MODE: "mode", SHIP: "ship", EXEC: "exec", @@ -241,6 +241,7 @@ var html = {PLUGIN_MARGIN: 10, ACTION_HEIGHT: 32, ACTION_MARGIN: 200, H1: "h1", H2: "h2", H3: "h3", A: "a", LABEL: "label", INNER: "inner", TITLE: "title", SPACE: "space", SPAN: "span", CODE: "code", DIV: "div", IMG: "img", VIDEO: "video", WSS: "wss", SVG: "svg", CANVAS: "canvas", IFRAME: "iframe", WEBVIEW: "webview", CHROME: "chrome", MOBILE: "mobile", LANDSCAPE: "landscape", + HEADER: "header", NAV: "nav", MAIN: "main", ASIDE: "aside", CLASS: "class", DISPLAY: "display", BLOCK: "block", NONE: "none", OVERFLOW: "overflow", HIDDEN: "hidden", SCROLL: "scroll", FLOAT: "float", CLEAR: "clear", BOTH: "both", PADDING: "padding", BORDER: "border", MARGIN: "margin", MARGIN_TOP: "margin-top", MARGIN_X: "margin-x", MARGIN_Y: "margin-y",