X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Fjavascript.jsm;fp=common%2Fmodules%2Fjavascript.jsm;h=a0981d7894fed5048a2ca8b945035fa2d6389a60;hb=10dd809e3c62dac9afcb5592982306ab22198f65;hp=c33ca86930e8eb8bf36e229ff5955b7f47dfe649;hpb=c8bcbfcd3f674388aa15b4096ce2c5ed6f91238b;p=dactyl.git diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index c33ca86..a0981d7 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -1,18 +1,19 @@ -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; let { getOwnPropertyNames } = Object; try { -Components.utils.import("resource://dactyl/bootstrap.jsm"); defineModule("javascript", { exports: ["JavaScript", "javascript"], require: ["util"] -}, this); +}); + +lazyRequire("template", ["template"]); let isPrototypeOf = Object.prototype.isPrototypeOf; @@ -118,7 +119,8 @@ var JavaScript = Module("javascript", { context[JavaScript.EVAL_TMP] = tmp; try { - cache[key] = this.modules.dactyl.userEval(arg, context, /*L*/"[Command Line Completion]", 1); + cache[key] = this.modules.dactyl.userEval(arg, context, + /*L*/"[Command Line Completion]", 1); return cache[key]; } @@ -489,9 +491,9 @@ var JavaScript = Module("javascript", { let [, prefix, args] = /^(function .*?)\((.*?)\)/.exec(Function.prototype.toString.call(func)); let n = this._get(i).comma.length; args = template.map(Iterator(args.split(", ")), - function ([i, arg]) {arg}, - <>, ); - this.context.message = <>{prefix}({args}); + function ([i, arg]) ["span", { highlight: i == n ? "Filter" : "" }, arg], + ",\u00a0"); + this.context.message = ["", prefix + "(", args, ")"]; } } } @@ -595,8 +597,8 @@ var JavaScript = Module("javascript", { if (!this.context.tabPressed && key == "" && obj.length > 1) { let message = this.context.message || ""; this.context.waitingForTab = true; - this.context.message = <>{message} - {_("completion.waitingForKeyPress")}; + this.context.message = ["", message, "\n", + _("completion.waitingForKeyPress")]; return null; } @@ -715,7 +717,6 @@ var JavaScript = Module("javascript", { }, addOutput: function addOutput(js) { - default xml namespace = XHTML; this.count++; try { @@ -728,19 +729,21 @@ var JavaScript = Module("javascript", { if (e.fileName) e = util.fixURI(e.fileName) + ":" + e.lineNumber + ": " + e; - xml = {e}; + xml = ["span", { highlight: "ErrorMsg" }, e]; } let prompt = "js" + this.count; Class.replaceProperty(this.context, prompt, result); - XML.ignoreWhitespace = XML.prettyPrinting = false; let nodes = {}; this.rootNode.appendChild( - util.xmlToDom( -
{prompt}> {js}
-
{xml}
-
.elements(), this.document, nodes)); + DOM.fromJSON( + [["div", { highlight: "REPL-E", key: "e" }, + ["span", { highlight: "REPL-R" }, + prompt, ">"], " ", js], + ["div", { highlight: "REPL-P", key: "p" }, + xml]], + this.document, nodes)); this.rootNode.scrollTop += nodes.e.getBoundingClientRect().top - this.rootNode.getBoundingClientRect().top; @@ -749,8 +752,7 @@ var JavaScript = Module("javascript", { count: 0, message: Class.Memoize(function () { - default xml namespace = XHTML; - util.xmlToDom(
, + DOM.fromJSON(["div", { highlight: "REPL", key: "rootNode" }], this.document, this); return this.rootNode; @@ -878,7 +880,7 @@ var JavaScript = Module("javascript", { bind(["", ""], "Scroll up half a page", function ({ self }) { self.repl.scrollVertical("pages", -1); }); }, - options: function (dactyl, modules, window) { + options: function initOptions(dactyl, modules, window) { modules.options.add(["jsdebugger", "jsd"], "Enable the JavaScript debugger service for use in JavaScript completion", "boolean", false, {