From: Michael Schutte Date: Mon, 9 Sep 2013 08:34:09 +0000 (+0200) Subject: New upstream version 1.0+hg6948 X-Git-Tag: debian/1.0+hg6948-1~1 X-Git-Url: https://git.donarmstrong.com/dactyl.git?a=commitdiff_plain;h=378bd64ab2a4ea1b5c9db33610b0f6aa91807001;hp=18c7ca5d1dae90b58e08cb4146c7d725081dd460;p=dactyl.git New upstream version 1.0+hg6948 --- diff --git a/.hg_archival.txt b/.hg_archival.txt index af226a2..19d75fb 100644 --- a/.hg_archival.txt +++ b/.hg_archival.txt @@ -1,5 +1,5 @@ repo: 373f1649c80dea9be7b5bc9c57e8395f94f93ab1 -node: ddb20953fcebb277dc5a68679d69f39873e3a866 +node: dd11a1a668d0ac31de134e00a8149fe044dad758 branch: default latesttag: pentadactyl-1.0rc1 -latesttagdistance: 195 +latesttagdistance: 219 diff --git a/common/bootstrap.js b/common/bootstrap.js index d0dd98a..de289ee 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -37,9 +37,9 @@ function reportError(e) { Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService) .logStringMessage(stack); } -function debug() { +function debug(...args) { if (DEBUG) - dump(name + ": " + Array.join(arguments, ", ") + "\n"); + dump(name + ": " + args.join(", ") + "\n"); } function httpGet(uri) { @@ -103,7 +103,7 @@ let JSMLoader = { return resourceProto.resolveURI(uri); let chan = Services.io.newChannelFromURI(uri); - try { chan.cancel(Cr.NS_BINDING_ABORTED) } catch (e) {} + try { chan.cancel(Cr.NS_BINDING_ABORTED); } catch (e) {} return chan.name; }, diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js index 0be89de..481cbcd 100644 --- a/common/components/commandline-handler.js +++ b/common/components/commandline-handler.js @@ -91,4 +91,4 @@ else var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]); var EXPORTED_SYMBOLS = ["NSGetFactory", "global"]; -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js index 4b64644..4013be2 100644 --- a/common/content/abbreviations.js +++ b/common/content/abbreviations.js @@ -347,7 +347,7 @@ var Abbreviations = Module("abbreviations", { arguments: [abbr.lhs], literalArg: abbr.rhs, options: { - "-javascript": abbr.rhs ? null : undefined + "-javascript": callable(abbr.rhs) ? null : undefined } } for ([, abbr] in Iterator(abbreviations.user.merged)) @@ -380,4 +380,4 @@ var Abbreviations = Module("abbreviations", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/autocommands.js b/common/content/autocommands.js index b141902..eaaa1c7 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -122,7 +122,7 @@ var AutoCommands = Module("autocommands", { ["td", {}, item.filter.toJSONXML ? item.filter.toJSONXML(modules) : String(item.filter)], ["td", {}, String(item.command)]]), ["tr", { style: "height: .5ex;" }]]).toArray(), - ["tr", { style: "height: .5ex;" }], + ["tr", { style: "height: .5ex;" }] ])]); commandline.commandOutput(table); }, @@ -246,7 +246,7 @@ var AutoCommands = Module("autocommands", { return void dactyl.echomsg(_("autocmd.noMatching")); let [event, url] = args; - let defaultURL = url || buffer.uri.spec; + let uri = util.createURI(url) || buffer.uri; let validEvents = Object.keys(config.autocommands); // TODO: add command validators @@ -254,7 +254,7 @@ var AutoCommands = Module("autocommands", { _("autocmd.cantExecuteAll")); dactyl.assert(validEvents.indexOf(event) >= 0, _("autocmd.noGroup", args)); - dactyl.assert(autocommands.get(event).some(function (c) c.patterns.some(function (re) re.test(defaultURL) ^ !re.result)), + dactyl.assert(autocommands.get(event).some(function (c) c.filter(uri)), _("autocmd.noMatching")); if (this.name == "doautoall" && dactyl.has("tabs")) { @@ -263,13 +263,13 @@ var AutoCommands = Module("autocommands", { for (let i = 0; i < tabs.count; i++) { tabs.select(i); // if no url arg is specified use the current buffer's URL - autocommands.trigger(event, { url: url || buffer.uri.spec }); + autocommands.trigger(event, { url: uri.spec }); } tabs.select(current); } else - autocommands.trigger(event, { url: defaultURL }); + autocommands.trigger(event, { url: uri.spec }); }, { argCount: "*", // FIXME: kludged for proper error message should be "1". completer: function (context) completion.autocmdEvent(context), @@ -296,4 +296,4 @@ var AutoCommands = Module("autocommands", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 65ec115..d92c624 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -118,7 +118,7 @@ var Bookmarks = Module("bookmarks", { * @param {Element} elem A form element for which to add a keyword. */ addSearchKeyword: function addSearchKeyword(elem) { - if (elem instanceof HTMLFormElement || elem.form) + if (elem instanceof Ci.nsIDOMHTMLFormElement || elem.form) var { url, postData, charset } = DOM(elem).formData; else var [url, postData, charset] = [elem.href || elem.src, null, elem.ownerDocument.characterSet]; @@ -730,4 +730,4 @@ var Bookmarks = Module("bookmarks", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/browser.js b/common/content/browser.js index a1b1110..79d98d2 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -66,7 +66,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), events: { DOMContentLoaded: function onDOMContentLoaded(event) { let doc = event.originalTarget; - if (doc instanceof HTMLDocument) + if (doc instanceof Ci.nsIDOMHTMLDocument) this._triggerLoadAutocmd("DOMLoad", doc); }, @@ -78,7 +78,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), if (doc instanceof Document) dactyl.initDocument(doc); - if (doc instanceof HTMLDocument) { + if (doc instanceof Ci.nsIDOMHTMLDocument) { if (doc.defaultView.frameElement) { // document is part of a frameset @@ -222,7 +222,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), if (dactyl.forceTarget in openModes) mode = openModes[dactyl.forceTarget]; - CommandExMode().open(mode + "open " + (args || "")) + CommandExMode().open(mode + "open " + (args || "")); } function decode(uri) util.losslessDecodeURI(uri) @@ -282,4 +282,4 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/commandline.js b/common/content/commandline.js index f01cbb0..9ea1fc3 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -54,7 +54,7 @@ var CommandWidgets = Class("CommandWidgets", { ["vbox", { id: "dactyl-completions-" + s + "commandline-container", class: "dactyl-container", hidden: "false", collapsed: "true" }, ["iframe", { class: "dactyl-completions", id: "dactyl-completions-" + s + "commandline", src: "dactyl://content/buffer.xhtml", contextmenu: "dactyl-contextmenu", flex: "1", hidden: "false", collapsed: "false", highlight: "Events", - events: "mowEvents" }]]]], + events: "mowEvents" }]]]] }); this.elements = {}; @@ -167,11 +167,11 @@ var CommandWidgets = Class("CommandWidgets", { function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id)); - this.active.__defineGetter__(obj.name, function () self.activeGroup[obj.name][obj.name]); - this.activeGroup.__defineGetter__(obj.name, function () self.getGroup(obj.name)); + this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]); + this.activeGroup.__defineGetter__(obj.name, () => this.getGroup(obj.name)); - memoize(this.statusbar, obj.name, function () get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name))); - memoize(this.commandbar, obj.name, function () get("dactyl-", {}, (obj.id || obj.name))); + memoize(this.statusbar, obj.name, () => get("dactyl-statusline-field-", statusline.widgets, (obj.id || obj.name))); + memoize(this.commandbar, obj.name, () => get("dactyl-", {}, (obj.id || obj.name))); if (!(obj.noValue || obj.getValue)) { Object.defineProperty(this, obj.name, Modes.boundProperty({ @@ -488,9 +488,9 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, { init.supercall(this); }, - complete: function CPM_complete(context) { + complete: function CPM_complete(context, ...args) { if (this.completer) - context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1)); + context.forkapply("prompt", 0, this, "completer", args); }, get mode() modes.PROMPT @@ -504,8 +504,6 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, { */ var CommandLine = Module("commandline", { init: function init() { - const self = this; - this._callbacks = {}; memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true })); @@ -634,7 +632,7 @@ var CommandLine = Module("commandline", { node.completionList = ItemList(elem); node.completionList.isAboveMow = node.id == - this.widgets.statusbar.commandline.id + this.widgets.statusbar.commandline.id; } return node.completionList; }, @@ -741,7 +739,7 @@ var CommandLine = Module("commandline", { if (val) this.widgets["message-pre"] = _("commandline.moreMessages", val) + " "; else - this.widgets["message-pre"] = null + this.widgets["message-pre"] = null; }, _lastEcho: null, @@ -777,13 +775,12 @@ var CommandLine = Module("commandline", { highlightGroup = highlightGroup || this.HL_NORMAL; - let self = this; - function appendToMessages(data) { + let appendToMessages = (data) => { let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data }; // Make sure the memoized message property is an instance property. message.message; - self._messageHistory.add(update({ highlight: highlightGroup }, message)); + this._messageHistory.add(update({ highlight: highlightGroup }, message)); return message.message; } @@ -802,7 +799,7 @@ var CommandLine = Module("commandline", { if ((flags & this.FORCE_MULTILINE) || (/\n/.test(data) || !isinstance(data, [_, "String"])) && !(flags & this.FORCE_SINGLELINE)) action = mow.closure.echo; - let single = function () action == self._echoLine; + let checkSingleLine = () => action == this._echoLine; if (forceSingle) { this._lastEcho = null; @@ -810,11 +807,11 @@ var CommandLine = Module("commandline", { } else { // So complicated... - if (single() && !this.widgets.mowContainer.collapsed) { + if (checkSingleLine() && !this.widgets.mowContainer.collapsed) { highlightGroup += " Message"; action = mow.closure.echo; } - else if (!single() && this.widgets.mowContainer.collapsed) { + else if (!checkSingleLine() && this.widgets.mowContainer.collapsed) { if (this._lastEcho && this.widgets.message && this.widgets.message[1] == this._lastEcho.msg) { if (!(this._lastEcho.flags & this.APPEND_TO_MESSAGES)) appendToMessages(this._lastEcho.data); @@ -832,20 +829,20 @@ var CommandLine = Module("commandline", { else if (this._lastEcho && this.widgets.message && this.widgets.message[1] == this._lastEcho.msg) { if (!(this._lastEcho.flags & this.APPEND_TO_MESSAGES)) appendToMessages(this._lastEcho.data); - if (single() && !(flags & this.APPEND_TO_MESSAGES)) + if (checkSingleLine() && !(flags & this.APPEND_TO_MESSAGES)) appendToMessages(data); flags |= this.APPEND_TO_MESSAGES; this.hiddenMessages++; } - this._lastEcho = single() && { flags: flags, msg: data, data: arguments[0] }; + this._lastEcho = checkSingleLine() && { flags: flags, msg: data, data: arguments[0] }; } this._lastClearable = action === this._echoLine && String(data); this._lastEchoTime = (flags & this.FORCE_SINGLELINE) && Date.now(); if (action) - action.call(this, data, highlightGroup, single); + action.call(this, data, highlightGroup, checkSingleLine()); }, _lastEchoTime: 0, @@ -958,7 +955,7 @@ var CommandLine = Module("commandline", { updateOutputHeight: deprecated("mow.resize", function updateOutputHeight(open, extra) mow.resize(open, extra)), - withOutputToString: function withOutputToString(fn, self) { + withOutputToString: function withOutputToString(fn, self, ...args) { dactyl.registerObserver("echoLine", observe, true); dactyl.registerObserver("echoMultiline", observe, true); @@ -968,7 +965,7 @@ var CommandLine = Module("commandline", { } this.savingOutput = true; - dactyl.trapErrors.apply(dactyl, [fn, self].concat(Array.slice(arguments, 2))); + dactyl.trapErrors.apply(dactyl, [fn, self].concat(args)); this.savingOutput = false; return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem) .join("\n"); @@ -1013,7 +1010,7 @@ var CommandLine = Module("commandline", { this.store = this.store.filter(function (line) (line.value || line) != str); dactyl.trapErrors(function () { - this.store.push({ value: str, timestamp: Date.now()*1000, privateData: privateData }); + this.store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData }); }, this); this.store = this.store.slice(Math.max(0, this.store.length - options["history"])); }, @@ -1767,8 +1764,7 @@ var CommandLine = Module("commandline", { return Events.PASS; }); - let bind = function bind() - mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(Array.slice(arguments))) + let bind = function bind(...args) mappings.add.apply(mappings, [[modes.COMMAND_LINE]].concat(args)); bind(["", ""], "Stop waiting for completions or exit Command Line mode", function ({ self }) { @@ -2030,7 +2026,7 @@ var ItemList = Class("ItemList", { if (start < 0 || start >= this.itemCount) return null; - group = array.nth(groups, function (g) let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0) + group = array.nth(groups, function (g) let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0); return [group.context, start - group.offsets.start]; }, @@ -2342,7 +2338,7 @@ var ItemList = Class("ItemList", { container.scrollTop = scroll; if (scrollY != null) win.scrollTo(0, Math.max(scrollY, 0)); - } + }; }, /** @@ -2455,4 +2451,4 @@ var ItemList = Class("ItemList", { }) }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 02ce9bd..64aa913 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -83,7 +83,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { } }, - observers: { "dactyl-cleanup": function dactyl_cleanup(subject, reason) { let modules = dactyl.modules; @@ -236,8 +235,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }); }, - triggerObserver: function triggerObserver(type) { - return this.applyTriggerObserver(type, Array.slice(arguments, 1)); + triggerObserver: function triggerObserver(type, ...args) { + return this.applyTriggerObserver(type, args); }, addUsageCommand: function (params) { @@ -524,10 +523,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * Acts like the Function builtin, but the code executes in the * userContext global. */ - userFunc: function userFunc() { + userFunc: function userFunc(...args) { return this.userEval( - "(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" + - " { " + arguments[arguments.length - 1] + " })"); + "(function userFunction(" + args.slice(0, -1).join(", ") + ")" + + " { " + args.pop() + " })"); }, /** @@ -600,7 +599,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (win.frameElement) win.frameElement.blur(); // Grr. - if (content.document.activeElement instanceof HTMLIFrameElement) + if (content.document.activeElement instanceof Ci.nsIDOMHTMLIFrameElement) content.document.activeElement.blur(); }); } @@ -682,7 +681,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { tag = function (map) [ let (c = obj.modes[0].char) c ? c + "_" : "", map - ] + ]; link = function (map) { let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map); let k = ["k", {}, extra]; @@ -710,7 +709,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { let description = ["description", {}, obj.description ? ["p", {}, template.linkifyHelp(obj.description.replace(/\.?$/, "."), true)] : "", extraHelp ? extraHelp : "", - !(extraHelp || obj.description) ? ["p", {}, /*L*/ "Sorry, no help available."] : ""] + !(extraHelp || obj.description) ? ["p", {}, /*L*/ "Sorry, no help available."] : ""]; res.push( ["item", {}, @@ -1117,11 +1116,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * @param {function} func The function to call * @param {object} self The 'this' object for the function. */ - trapErrors: function trapErrors(func, self) { + trapErrors: function trapErrors(func, self, ...args) { try { if (isString(func)) func = self[func]; - return func.apply(self || this, Array.slice(arguments, 2)); + return func.apply(self || this, args); } catch (e) { try { @@ -1200,7 +1199,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { dactyl.reportError(e, true); } }); - } + }; }, /** @@ -1404,10 +1403,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { groups.every(function (g) !g.validator || g.validator(val)) }); - options.add(["helpfile", "hf"], - "Name of the main help file", - "string", "intro"); - options.add(["loadplugins", "lpl"], "A regexp list that defines which plugins are loaded at startup and via :loadplugins", "regexplist", "'\\.(js|" + config.fileExtension + ")$'"); @@ -1829,7 +1824,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { commandline.commandOutput([ ["div", {}, [config.appName, " ", config.version, date, " running on: "].join("")], ["div", {}, [window.navigator.userAgent].join("")] - ]) + ]); } }, { argCount: "0", @@ -2003,4 +1998,4 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/disable-acr.jsm b/common/content/disable-acr.jsm index 5f5b4fe..86e55c4 100644 --- a/common/content/disable-acr.jsm +++ b/common/content/disable-acr.jsm @@ -64,7 +64,7 @@ function chromeDocuments() { Ci.nsIDocShell.ENUMERATE_FORWARDS); while (docShells.hasMoreElements()) try { - yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument; + yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument; } catch (e) {} } @@ -73,4 +73,4 @@ function chromeDocuments() { var EXPORTED_SYMBOLS = ["cleanup", "init"]; -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/content/editor.js b/common/content/editor.js index eef3c1d..01a25eb 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -470,7 +470,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { } try { - var tmpfile = io.createTempFile(); + var tmpfile = io.createTempFile("txt", "." + buffer.uri.host); if (!tmpfile) throw Error(_("io.cantCreateTempFile")); @@ -870,7 +870,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { function addBeginInsertModeMap(keys, commands, description) { mappings.add([modes.TEXT_EDIT], keys, description || "", function () { - commands.forEach(function (cmd) { editor.executeCommand(cmd, 1) }); + commands.forEach(function (cmd) { editor.executeCommand(cmd, 1); }); modes.push(modes.INSERT); }, { type: "editor" }); @@ -1148,26 +1148,25 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { mappings.add([modes.TEXT_EDIT], names, description, action, update({ type: "editor" }, params)); - bind([""], "Increment the next number", - function ({ count }) { editor.modifyNumber(count || 1) }, + function ({ count }) { editor.modifyNumber(count || 1); }, { count: true }); bind([""], "Decrement the next number", - function ({ count }) { editor.modifyNumber(-(count || 1)) }, + function ({ count }) { editor.modifyNumber(-(count || 1)); }, { count: true }); // text edit mode bind(["u"], "Undo changes", - function (args) { - editor.editor.undo(Math.max(args.count, 1)); + function ({ count }) { + editor.editor.undo(Math.max(count, 1)); editor.deselect(); }, { count: true, noTransaction: true }); bind([""], "Redo undone changes", - function (args) { - editor.editor.redo(Math.max(args.count, 1)); + function ({ count }) { + editor.editor.redo(Math.max(count, 1)); editor.deselect(); }, { count: true, noTransaction: true }); @@ -1325,8 +1324,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { }, { count: true }); - let bind = function bind() mappings.add.apply(mappings, - [[modes.AUTOCOMPLETE]].concat(Array.slice(arguments))) + let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args)); bind([""], "Return to Insert mode", function () Events.PASS_THROUGH); @@ -1407,4 +1405,4 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/eval.js b/common/content/eval.js index 9e10d9f..5ef0951 100644 --- a/common/content/eval.js +++ b/common/content/eval.js @@ -9,4 +9,4 @@ catch (e) { __dactyl_eval_error = e; } // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/events.js b/common/content/events.js index 98dc028..ffa279b 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -611,7 +611,10 @@ var Events = Module("events", { if (!(services.focus.getLastFocusMethod(win) & 0x3000) && events.isContentNode(elem) && !buffer.focusAllowed(elem) - && isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement, Window])) { + && isinstance(elem, [Ci.nsIDOMHTMLInputElement, + Ci.nsIDOMHTMLSelectElement, + Ci.nsIDOMHTMLTextAreaElement, + Ci.nsIDOMWindow])) { if (elem.frameElement) dactyl.focusContent(true); @@ -673,7 +676,7 @@ var Events = Module("events", { // Hack to deal with and so forth not dispatching input // events - if (key && event.originalTarget instanceof HTMLInputElement && !modes.main.passthrough) { + if (key && event.originalTarget instanceof Ci.nsIDOMHTMLInputElement && !modes.main.passthrough) { let elem = event.originalTarget; elem.dactylKeyPress = elem.value; util.timeout(function () { @@ -844,7 +847,7 @@ var Events = Module("events", { // access to the real focus target // Huh? --djk onFocusChange: util.wrapCallback(function onFocusChange(event) { - function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument + function hasHTMLDocument(win) win && win.document && win.document instanceof Ci.nsIDOMHTMLDocument if (dactyl.ignoreFocus) return; @@ -861,7 +864,7 @@ var Events = Module("events", { if (elem && elem.readOnly) return; - if (isinstance(elem, [HTMLEmbedElement, HTMLEmbedElement])) { + if (isinstance(elem, [Ci.nsIDOMHTMLEmbedElement, Ci.nsIDOMHTMLEmbedElement])) { if (!modes.main.passthrough && modes.main != modes.EMBED) modes.push(modes.EMBED); return; @@ -965,8 +968,9 @@ var Events = Module("events", { isInputElement: function isInputElement(elem) { return DOM(elem).isEditable || - isinstance(elem, [HTMLEmbedElement, HTMLObjectElement, - HTMLSelectElement]) + isinstance(elem, [Ci.nsIDOMHTMLEmbedElement, + Ci.nsIDOMHTMLObjectElement, + Ci.nsIDOMHTMLSelectElement]); }, kill: function kill(event) { @@ -1168,4 +1172,4 @@ var Events = Module("events", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/help.js b/common/content/help.js index 70c3753..1d921fa 100644 --- a/common/content/help.js +++ b/common/content/help.js @@ -24,4 +24,4 @@ function checkFragment() { document.addEventListener("load", checkFragment, true); document.addEventListener("hashChange", checkFragment, true); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/hints.js b/common/content/hints.js index a9154e8..d151c2c 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -337,9 +337,11 @@ var HintSession = Class("HintSession", CommandMode, { if (elem.hasAttributeNS(NS, "hint")) [hint.text, hint.showText] = [elem.getAttributeNS(NS, "hint"), true]; - else if (isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement])) + else if (isinstance(elem, [Ci.nsIDOMHTMLInputElement, + Ci.nsIDOMHTMLSelectElement, + Ci.nsIDOMHTMLTextAreaElement])) [hint.text, hint.showText] = hints.getInputHint(elem, doc); - else if (elem.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(elem.textContent)) + else if (elem.firstElementChild instanceof Ci.nsIDOMHTMLImageElement && /^\s*$/.test(elem.textContent)) [hint.text, hint.showText] = [elem.firstElementChild.alt || elem.firstElementChild.title, true]; else hint.text = elem.textContent.toLowerCase(); @@ -349,7 +351,7 @@ var HintSession = Class("HintSession", CommandMode, { let leftPos = Math.max((rect.left + offsetX), offsetX); let topPos = Math.max((rect.top + offsetY), offsetY); - if (elem instanceof HTMLAreaElement) + if (elem instanceof Ci.nsIDOMHTMLAreaElement) [leftPos, topPos] = this.getAreaOffset(elem, leftPos, topPos); hint.span.setAttribute("style", ["display: none; left:", leftPos, "px; top:", topPos, "px"].join("")); @@ -596,7 +598,7 @@ var HintSession = Class("HintSession", CommandMode, { if (!hint.valid) continue inner; - if (hint.text == "" && hint.elem.firstChild && hint.elem.firstChild instanceof HTMLImageElement) { + if (hint.text == "" && hint.elem.firstChild && hint.elem.firstChild instanceof Ci.nsIDOMHTMLImageElement) { if (!hint.imgSpan) { let rect = hint.elem.firstChild.getBoundingClientRect(); if (!rect) @@ -614,7 +616,7 @@ var HintSession = Class("HintSession", CommandMode, { let str = this.getHintString(hintnum); let text = []; - if (hint.elem instanceof HTMLInputElement) + if (hint.elem instanceof Ci.nsIDOMHTMLInputElement) if (hint.elem.type === "radio") text.push(UTF8(hint.elem.checked ? "⊙" : "○")); else if (hint.elem.type === "checkbox") @@ -781,7 +783,8 @@ var Hints = Module("hints", { this.addMode("i", "Show image", function (elem) dactyl.open(elem.src)); this.addMode("I", "Show image in a new tab", function (elem) dactyl.open(elem.src, dactyl.NEW_TAB)); - function isScrollable(elem) isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]) || + function isScrollable(elem) isinstance(elem, [Ci.nsIDOMHTMLFrameElement, + Ci.nsIDOMHTMLIFrameElement]) || Buffer.isScrollable(elem, 0, true) || Buffer.isScrollable(elem, 0, false); }, @@ -850,7 +853,7 @@ var Hints = Module("hints", { else { for (let [, option] in Iterator(options["hintinputs"])) { if (option == "value") { - if (elem instanceof HTMLSelectElement) { + if (elem instanceof Ci.nsIDOMHTMLSelectElement) { if (elem.selectedIndex >= 0) return [elem.item(elem.selectedIndex).text.toLowerCase(), false]; } @@ -1349,7 +1352,7 @@ var Hints = Module("hints", { { values: { "0": "Follow the first hint as soon as typed text uniquely identifies it. Follow the selected hint on .", - "1": "Follow the selected hint on .", + "1": "Follow the selected hint on ." } }); @@ -1386,4 +1389,4 @@ var Hints = Module("hints", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/history.js b/common/content/history.js index c69237f..f19b1e2 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -61,12 +61,12 @@ var History = Module("history", { }, get session() { - let webNav = window.getWebNavigation() + let webNav = window.getWebNavigation(); let sh = webNav.sessionHistory; let obj = []; obj.__defineGetter__("index", function () sh.index); - obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val) }); + obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val); }); obj.__iterator__ = function () array.iterItems(this); for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry)) @@ -352,7 +352,7 @@ var History = Module("history", { completion.addUrlCompleter("history", "History", completion.history); }, mappings: function initMappings() { - function bind() mappings.add.apply(mappings, [config.browserModes].concat(Array.slice(arguments))); + function bind(...args) mappings.add.apply(mappings, [config.browserModes].concat(args)); bind([""], "Go to an older position in the jump list", function ({ count }) { history.stepTo(-Math.max(count, 1), true); }, @@ -371,13 +371,13 @@ var History = Module("history", { { count: true }); bind(["[d"], "Go back to the previous domain in the browser history", - function ({ count }) { history.search("domain", -Math.max(count, 1)) }, + function ({ count }) { history.search("domain", -Math.max(count, 1)); }, { count: true }); bind(["]d"], "Go forward to the next domain in the browser history", - function ({ count }) { history.search("domain", Math.max(count, 1)) }, + function ({ count }) { history.search("domain", Math.max(count, 1)); }, { count: true }); } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/key-processors.js b/common/content/key-processors.js index aa1e016..08cc401 100644 --- a/common/content/key-processors.js +++ b/common/content/key-processors.js @@ -250,18 +250,17 @@ var KeyProcessor = Class("KeyProcessor", { }, execute: function execute(map, args) - let (self = this) - function execute() { - if (self.preExecute) - self.preExecute.apply(self, args); + () => { + if (this.preExecute) + this.preExecute.apply(this, args); - args.self = self.main.params.mappingSelf || self.main.mappingSelf || map; - let res = map.execute.call(map, args); + args.self = this.main.params.mappingSelf || this.main.mappingSelf || map; + let res = map.execute.call(map, args); - if (self.postExecute) - self.postExecute.apply(self, args); - return res; - }, + if (this.postExecute) + this.postExecute.apply(this, args); + return res; + }, onKeyPress: function onKeyPress(event) { if (event.skipmap) @@ -322,3 +321,4 @@ var KeyArgProcessor = Class("KeyArgProcessor", KeyProcessor, { } }); +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/mappings.js b/common/content/mappings.js index c272eb5..68bba94 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -123,8 +123,7 @@ var Map = Class("Map", { contexts.context, args); - let self = this; - function repeat() self.action(args) + let repeat = () => this.action(args); if (this.names[0] != ".") // FIXME: Kludge. mappings.repeat = repeat; @@ -496,7 +495,7 @@ var Mappings = Module("mappings", { ["td", {}, modeSign], ["td", {}, name], ["td", {}, map.rhs || map.action.toSource()]])), - ["tr", { style: "height: .5ex;" }]])] + ["tr", { style: "height: .5ex;" }]])]; // E4X-FIXME // // TODO: Move this to an ItemList to show this automatically @@ -572,7 +571,7 @@ var Mappings = Module("mappings", { options: [ { names: ["-arg", "-a"], - description: "Accept an argument after the requisite key press", + description: "Accept an argument after the requisite key press" }, { names: ["-builtin", "-b"], @@ -828,8 +827,8 @@ var Mappings = Module("mappings", { mappings: function initMappings(dactyl, modules, window) { mappings.add([modes.COMMAND], ["\\"], "Emits pseudo-key", - function () { events.feedkeys("") }); + function () { events.feedkeys(""); }); } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/marks.js b/common/content/marks.js index 4776c1c..8131e29 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -233,7 +233,7 @@ var Marks = Module("marks", { _scrollTo: function _scrollTo(mark) { if (!mark.path) - var node = buffer.findScrollable(0, (mark.offset || mark.position).x) + var node = buffer.findScrollable(0, (mark.offset || mark.position).x); else for (node in DOM.XPath(mark.path, buffer.focusedFrame.document)) break; @@ -303,7 +303,6 @@ var Marks = Module("marks", { Math.round(mark.position.y * 100) + "%)", (tab && "tab: " + tabs.index(tab)) ].filter(util.identity).join(", "); - }, isLocalMark: bind("test", /^[a-z`']$/), @@ -408,4 +407,4 @@ var Marks = Module("marks", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/modes.js b/common/content/modes.js index 2df79d9..fc33fd7 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -606,7 +606,7 @@ var Modes = Module("modes", { }, setter: function (vals) { - modes.all.forEach(function (m) { delete m.passUnknown }); + modes.all.forEach(function (m) { delete m.passUnknown; }); vals = vals.map(function (v) update(new String(v.toLowerCase()), { mode: v.replace(/^!/, "").toUpperCase(), @@ -634,8 +634,8 @@ var Modes = Module("modes", { }, prefs: function initPrefs() { prefs.watch("accessibility.browsewithcaret", - function () { modes.onCaretChange.apply(modes, arguments) }); + function () { modes.onCaretChange.apply(modes, arguments); }); } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/mow.js b/common/content/mow.js index 689d9a7..6ef53f8 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -157,7 +157,7 @@ var MOW = Module("mow", { dactyl.open(event.target.href, where); }; - if (event.target instanceof HTMLAnchorElement) + if (event.target instanceof Ci.nsIDOMHTMLAnchorElement) switch (DOM.Event.stringify(event)) { case "": openLink(dactyl.CURRENT_TAB); @@ -192,7 +192,7 @@ var MOW = Module("mow", { popupshowing: function onPopupShowing(event) { let menu = commandline.widgets.contextMenu; let enabled = { - link: window.document.popupNode instanceof HTMLAnchorElement, + link: window.document.popupNode instanceof Ci.nsIDOMHTMLAnchorElement, path: window.document.popupNode.hasAttribute("path"), selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed }; @@ -399,4 +399,4 @@ var MOW = Module("mow", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index 9fc5aca..f2c1039 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -204,4 +204,4 @@ var QuickMarks = Module("quickmarks", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/statusline.js b/common/content/statusline.js index 0de0208..4cf50c4 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -269,7 +269,7 @@ var StatusLine = Module("statusline", { }); }, - updateUrl: deprecated("statusline.status", function updateUrl(url) { this.status = url || buffer.uri }), + updateUrl: deprecated("statusline.status", function updateUrl(url) { this.status = url || buffer.uri; }), /** * Set the contents of the status line's input buffer to the given @@ -393,4 +393,4 @@ var StatusLine = Module("statusline", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/content/tabs.js b/common/content/tabs.js index fb155db..016355f 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -237,7 +237,7 @@ var Tabs = Module("tabs", { return this._groups; if (func) - func = bind(function (func) { func(this._groups) }, this, func); + func = bind(function (func) { func(this._groups); }, this, func); if (window.TabView && window.TabView._initFrame) window.TabView._initFrame(func); @@ -335,7 +335,6 @@ var Tabs = Module("tabs", { completion.listCompleter("buffer", filter); }, - /** * Return an iterator of tabs matching the given filter. If no * *filter* or *count* is provided, returns the currently selected @@ -1312,4 +1311,4 @@ var Tabs = Module("tabs", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/common/locale/en-US/autocommands.xml b/common/locale/en-US/autocommands.xml index 6cb779b..d5e3fa1 100644 --- a/common/locale/en-US/autocommands.xml +++ b/common/locale/en-US/autocommands.xml @@ -40,10 +40,10 @@

- If the -group=group flag is given, add this autocmd - to the named group. Any filters for group apply in - addition to filter. When listing commands this limits the - output to the specified group. + If the -group=group flag is given, add this + autocommand to the named group. Any filters for group + apply in addition to filter. When listing commands this + limits the output to the specified group.

Available events:

diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index 26c77c2..af586ab 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -1330,23 +1330,6 @@ - - 'noprivate' 'private' - 'private' - &option.private.type; - &option.private.default; - -

- Set the private browsing option. In private browsing mode - history, cache files, cookies, form data, passwords, download list - entries, local and URL marks, command-line history - and macros are available only for the duration of the private - browsing session and deleted when returning to normal browsing - mode. See also privacy. -

-
-
- $&dactyl.idName;_RUNTIME 'rtp' 'runtimepath' diff --git a/common/locale/en-US/privacy.xml b/common/locale/en-US/privacy.xml index ee7e6b8..0bd9549 100644 --- a/common/locale/en-US/privacy.xml +++ b/common/locale/en-US/privacy.xml @@ -28,8 +28,7 @@ When in private browsing mode, no data other than Bookmarks and QuickMarks are written to disk. Further, upon exiting private mode, all newly accumulated data, including command-line history, local and URL - marks, and macros, are purged from memory. For more information, see - private. + marks, and macros, are purged from memory.

Clearing private data

diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index 2e52a9a..e2c577a 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -15,8 +15,7 @@ defineModule("addons", { this.lazyRequire("completion", ["completion"]); lazyRequire("template", ["template"]); -var callResult = function callResult(method) { - let args = Array.slice(arguments, 1); +var callResult = function callResult(method, ...args) { return function (result) { result[method].apply(result, args); }; } @@ -25,7 +24,7 @@ var listener = function listener(action, event) this.dactyl[install.error ? "echoerr" : "echomsg"]( _("addon.error", action, event, (install.name || install.sourceURI.spec) + (install.error ? ": " + addons.errors[install.error] : ""))); - } + }; var AddonListener = Class("AddonListener", { init: function init(modules) { @@ -120,7 +119,7 @@ var actions = { }, get filter() { return function (addon) !addon.userDisabled && - !(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE)) + !(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE)); }, perm: "disable" }, @@ -206,14 +205,13 @@ var Addon = Class("Addon", { ["span", { highlight: pending[0] }, pending[1]], " on ", ["a", { href: "#", "dactyl:command": "dactyl.restart" }, "restart"], - ")"] + ")"]; return info; }, update: function callee() { - let self = this; - function update(key, xml) { - let node = self.nodes[key]; + let update = (key, xml) => { + let node = this.nodes[key]; while (node.firstChild) node.removeChild(node.firstChild); @@ -390,9 +388,9 @@ var Addons = Module("addons", { } if (!file.exists()) - AddonManager.getInstallForURL(url, install, "application/x-xpinstall"); + AddonManager.getInstallForURL(url, install, "application/x-xpinstall"); else if (file.isReadable() && file.isFile()) - AddonManager.getInstallForFile(file, install, "application/x-xpinstall"); + AddonManager.getInstallForFile(file.file, install, "application/x-xpinstall"); else if (file.isDirectory()) dactyl.echoerr(_("addon.cantInstallDir", file.path.quote())); else @@ -498,4 +496,4 @@ endModule(); } catch(e){ if (isString(e)) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 589c804..a9318eb 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2012 Kris Maglione +// Copyright (c) 2009-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -68,8 +68,8 @@ Object.defineProperty(defineModule.loadLog, "push", { } }); defineModule.prefix = ""; -defineModule.dump = function dump_() { - let msg = Array.map(arguments, function (msg) { +defineModule.dump = function dump_(...args) { + let msg = args.map(function (msg) { if (loaded.util && typeof msg == "object") msg = util.objectToString(msg); return msg; @@ -78,13 +78,13 @@ defineModule.dump = function dump_() { .replace(/^./gm, JSMLoader.name + ": $&")); } defineModule.modules = []; -defineModule.time = function time(major, minor, func, self) { +defineModule.time = function time(major, minor, func, self, ...args) { let time = Date.now(); if (typeof func !== "function") func = self[func]; try { - var res = func.apply(self, Array.slice(arguments, 4)); + var res = func.apply(self, args); } catch (e) { loaded.util && util.reportError(e); @@ -241,7 +241,7 @@ function properties(obj, prototypes, debugger_) { return array.uniq([k for (k in obj)].concat( Object.getOwnPropertyNames( XPCNativeWrapper.unwrap(obj)) - .filter(filter))) + .filter(filter))); } else if (!e.stack) { throw Error(e); @@ -441,18 +441,18 @@ function curry(fn, length, self, acc) { return fn; // Close over function with 'this' - function close(self, fn) function () fn.apply(self, Array.slice(arguments)); + function close(self, fn) function () fn.apply(self, arguments); if (acc == null) acc = []; - return function curried() { - let args = acc.concat(Array.slice(arguments)); - + return function curried(...args) { // The curried result should preserve 'this' - if (arguments.length == 0) + if (args.length == 0) return close(self || this, curried); + let args = acc.concat(args); + if (args.length >= length) return fn.apply(self || this, args); @@ -461,15 +461,14 @@ function curry(fn, length, self, acc) { } if (curry.bind) - var bind = function bind(meth, self) let (func = callable(meth) ? meth : self[meth]) - func.bind.apply(func, Array.slice(arguments, 1)); + var bind = function bind(meth, self, ...args) let (func = callable(meth) ? meth : self[meth]) + func.bind.apply(func, [self].concat(args)); else - var bind = function bind(func, self) { + var bind = function bind(func, self, ...args) { if (!callable(func)) func = self[func]; - let args = Array.slice(arguments, bind.length); - return function bound() func.apply(self, args.concat(Array.slice(arguments))); + return function bound(...args2) func.apply(self, args.concat(args2)); }; /** @@ -574,8 +573,8 @@ function isString(val) objproto.toString.call(val) == "[object String]"; */ function callable(val) typeof val === "function" && !(val instanceof Ci.nsIDOMElement); -function call(fn) { - fn.apply(arguments[1], Array.slice(arguments, 2)); +function call(fn, self, ...args) { + fn.apply(self, args); return fn; } @@ -660,8 +659,8 @@ function update(target) { func.superapply = function superapply(self, args) let (meth = Object.getPrototypeOf(target)[k]) meth && meth.apply(self, args); - func.supercall = function supercall(self) - func.superapply(self, Array.slice(arguments, 1)); + func.supercall = function supercall(self, ...args) + func.superapply(self, args); } } Object.defineProperty(target, k, desc); @@ -687,8 +686,8 @@ function update_(target) { func.superapply = function super_apply(self, args) let (meth = Object.getPrototypeOf(target)[k]) meth && meth.apply(self, args); - func.supercall = function super_call(self) - func.superapply(self, Array.slice(arguments, 1)); + func.supercall = function super_call(self, ...args) + func.superapply(self, args); } } Object.defineProperty(target, k, desc); @@ -722,9 +721,8 @@ function update_(target) { * * @returns {function} The constructor for the resulting class. */ -function Class() { +function Class(...args) { - var args = Array.slice(arguments); if (isString(args[0])) var name = args.shift(); var superclass = Class; @@ -953,14 +951,13 @@ Class.prototype = { * @returns {nsITimer} The timer which backs this timeout. */ timeout: function timeout(callback, timeout) { - const self = this; - function timeout_notify(timer) { - if (self.stale || + let timeout_notify = (timer) => { + if (this.stale || util.rehashing && !isinstance(Cu.getGlobalForObject(callback), ["BackstagePass"])) return; - self.timeouts.splice(self.timeouts.indexOf(timer), 1); - util.trapErrors(callback, self); - } + this.timeouts.splice(this.timeouts.indexOf(timer), 1); + util.trapErrors(callback, this); + }; let timer = services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT); this.timeouts.push(timer); return timer; @@ -973,12 +970,11 @@ Class.prototype = { * localized properties. */ update: function update() { - let self = this; // XXX: Duplication. for (let i = 0; i < arguments.length; i++) { let src = arguments[i]; - Object.getOwnPropertyNames(src || {}).forEach(function (k) { + Object.getOwnPropertyNames(src || {}).forEach((k) => { let desc = Object.getOwnPropertyDescriptor(src, k); if (desc.value instanceof Class.Property) desc = desc.value.init(k, this) || desc.value; @@ -986,12 +982,16 @@ Class.prototype = { if (typeof desc.value === "function") { let func = desc.value.wrapped || desc.value; if (!func.superapply) { - func.__defineGetter__("super", function () Object.getPrototypeOf(self)[k]); - func.superapply = function superapply(self, args) - let (meth = Object.getPrototypeOf(self)[k]) - meth && meth.apply(self, args); - func.supercall = function supercall(self) - func.superapply(self, Array.slice(arguments, 1)); + func.__defineGetter__("super", () => Object.getPrototypeOf(this)[k]); + + func.superapply = function superapply(self, args) { + let meth = Object.getPrototypeOf(self)[k]; + return meth && meth.apply(self, args); + }; + + func.supercall = function supercall(self, ...args) { + return func.superapply(self, args); + } } } @@ -1080,7 +1080,7 @@ function XPCOMShim(interfaces) { getInterfaces: function (count) { count.value = 0; } }); return (interfaces || []).reduce(function (shim, iface) shim.QueryInterface(Ci[iface]), - ip.data) + ip.data); }; let stub = Class.Property({ configurable: true, @@ -1097,7 +1097,7 @@ var ErrorBase = Class("ErrorBase", Error, { init: function EB_init(message, level) { level = level || 0; let error = Error(message); - update(this, error) + update(this, error); this.stack = error.stack; this.message = message; @@ -1127,22 +1127,22 @@ var Finished = Class("Finished", ErrorBase); * @param {Object} classProperties Properties to be applied to the class constructor. * @returns {Class} */ -function Module(name, prototype) { +function Module(name, prototype, ...args) { try { - let init = callable(prototype) ? 4 : 3; - let proto = arguments[callable(prototype) ? 2 : 1]; + let init = callable(prototype) ? 2 : 1; + let proto = callable(prototype) ? args[0] : prototype; proto._metaInit_ = function () { delete module.prototype._metaInit_; currentModule[name.toLowerCase()] = this; }; - const module = Class.apply(Class, Array.slice(arguments, 0, init)); + const module = Class.apply(Class, [name, prototype, ...args.slice(0, init)]); let instance = module(); module.className = name.toLowerCase(); instance.INIT = update(Object.create(Module.INIT), - arguments[init] || {}); + args[init] || {}); currentModule[module.className] = instance; defineModule.modules.push(instance); @@ -1172,7 +1172,7 @@ Module.INIT = { module.isLocalModule = true; modules.jsmodules[this.constructor.className] = module; - locals.reverse().forEach(function (fn, i) update(objs[i], fn.apply(module, args))) + locals.reverse().forEach(function (fn, i) update(objs[i], fn.apply(module, args))); memoize(module, "closure", Class.makeClosure); module.instance = module; @@ -1199,13 +1199,9 @@ Module.INIT = { * * @returns {function} The constructor for the new Struct. */ -function Struct() { - if (!/^[A-Z]/.test(arguments[0])) - var args = Array.slice(arguments, 0); - else { - var className = arguments[0]; - args = Array.slice(arguments, 1); - } +function Struct(...args) { + if (/^[A-Z]/.test(args[0])) + var className = args.shift(); const Struct = Class(className || "Struct", StructBase, { length: args.length, @@ -1599,9 +1595,9 @@ var array = Class("array", Array, { }, array: ary, toString: function () this.array.toString(), - concat: function () this.__noSuchMethod__("concat", Array.slice(arguments)), - filter: function () this.__noSuchMethod__("filter", Array.slice(arguments)), - map: function () this.__noSuchMethod__("map", Array.slice(arguments)) + concat: function (...args) this.__noSuchMethod__("concat", args), + filter: function (...args) this.__noSuchMethod__("filter", args), + map: function (...args) this.__noSuchMethod__("map", args) }; } }, { @@ -1734,8 +1730,8 @@ var array = Class("array", Array, { /* Make Minefield not explode, because Minefield exploding is not fun. */ let iterProto = Iter.prototype; Object.keys(iter).forEach(function (k) { - iterProto[k] = function () { - let res = iter[k].apply(iter, [this].concat(Array.slice(arguments))); + iterProto[k] = function (...args) { + let res = iter[k].apply(iter, [this].concat(args)); if (isinstance(res, ["Iterator", "Generator"])) return Iter(res); return res; @@ -1744,8 +1740,8 @@ Object.keys(iter).forEach(function (k) { Object.keys(array).forEach(function (k) { if (!(k in iterProto)) - iterProto[k] = function () { - let res = array[k].apply(array, [this.toArray()].concat(Array.slice(arguments))); + iterProto[k] = function (...args) { + let res = array[k].apply(array, [this.toArray()].concat(args)); if (isinstance(res, ["Iterator", "Generator"])) return Iter(res); if (isArray(res)) @@ -1769,4 +1765,4 @@ endModule(); // catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);} -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/bookmarkcache.jsm b/common/modules/bookmarkcache.jsm index cedf7bd..be55f98 100644 --- a/common/modules/bookmarkcache.jsm +++ b/common/modules/bookmarkcache.jsm @@ -262,4 +262,4 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), { endModule(); -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm index 6c9426d..4206133 100644 --- a/common/modules/bootstrap.jsm +++ b/common/modules/bootstrap.jsm @@ -19,3 +19,4 @@ this["import"] = function import_(obj) { Components.utils.import("resource://gre/modules/Services.jsm"); function loadSubScript() Services.scriptloader.loadSubScript.apply(null, arguments); +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 964c3c8..15aea79 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -33,7 +33,7 @@ var Buffer = Module("Buffer", { let win = services.focus.focusedWindow; if (!win || win == window || util.topWindow(win) != window) - return window.content + return window.content; if (win.top == window) return win; return win.top; @@ -83,7 +83,7 @@ var Buffer = Module("Buffer", { services.contentPrefs.getPref(this.uri, pref, sanitizer.getContext(this.win), callback); else - services.contentPrefs.getPref(uri, pref, callback); + services.contentPrefs.getPref(this.uri, pref, callback); }, /** @@ -219,7 +219,7 @@ var Buffer = Module("Buffer", { */ get zoomLevel() { let v = this.contentViewer; - return v[v.textZoom == 1 ? "fullZoom" : "textZoom"] * 100 + return v[v.textZoom == 1 ? "fullZoom" : "textZoom"] * 100; }, set zoomLevel(value) { this.setZoom(value, this.fullZoom); }, @@ -755,8 +755,8 @@ var Buffer = Module("Buffer", { * vertical percentages. See {@link Buffer.scrollToPercent} for * parameters. */ - scrollToPercent: function scrollToPercent(horizontal, vertical) - Buffer.scrollToPercent(this.findScrollable(0, vertical == null), horizontal, vertical), + scrollToPercent: function scrollToPercent(horizontal, vertical, dir) + Buffer.scrollToPercent(this.findScrollable(dir || 0, vertical == null), horizontal, vertical), /** * Scrolls the currently active element to the given horizontal and @@ -907,7 +907,7 @@ var Buffer = Module("Buffer", { let distance = reverse ? function (rect) -rect.top : function (rect) rect.top; let elems = [[e, distance(e.getBoundingClientRect())] for (e in path.matcher(this.focusedFrame.document))] .filter(function (e) e[1] > FUDGE) - .sort(function (a, b) a[1] - b[1]) + .sort(function (a, b) a[1] - b[1]); if (offScreen && !reverse) elems = elems.filter(function (e) e[1] > this, this.topWindow.innerHeight); @@ -995,8 +995,6 @@ var Buffer = Module("Buffer", { showPageInfo: function showPageInfo(verbose, sections) { let { commandline, dactyl, options } = this.modules; - let self = this; - // Ctrl-g single line output if (!verbose) { let file = this.win.location.pathname.split("/").pop() || _("buffer.noName"); @@ -1004,7 +1002,7 @@ var Buffer = Module("Buffer", { let info = template.map( (sections || options["pageinfo"]) - .map(function (opt) Buffer.pageInfo[opt].action.call(self)), + .map((opt) => Buffer.pageInfo[opt].action.call(this)), function (res) res && iter(res).join(", ") || undefined, ", ").join(""); @@ -1016,9 +1014,9 @@ var Buffer = Module("Buffer", { return; } - let list = template.map(sections || options["pageinfo"], function (option) { + let list = template.map(sections || options["pageinfo"], (option) => { let { action, title } = Buffer.pageInfo[option]; - return template.table(title, action.call(self, true)); + return template.table(title, action.call(this, true)); }, ["br"]); commandline.commandOutput(list); @@ -1144,7 +1142,10 @@ var Buffer = Module("Buffer", { let ext = uri.fileExtension || "txt"; if (doc.contentType) - ext = services.mime.getPrimaryExtension(doc.contentType, ext); + try { + ext = services.mime.getPrimaryExtension(doc.contentType, ext); + } + catch (e) {} if (!isString(doc)) return io.withTempFiles(function (temp) { @@ -1251,14 +1252,13 @@ var Buffer = Module("Buffer", { * Updates the zoom level of this buffer from a content preference. */ updateZoom: util.wrapCallback(function updateZoom() { - let self = this; let uri = this.uri; if (prefs.get("browser.zoom.siteSpecific")) { - this.getPref("dactyl.content.full-zoom", function (val) { - if (val != null && uri.equals(self.uri) && val != prefs.get("browser.zoom.full")) - [self.contentViewer.textZoom, self.contentViewer.fullZoom] = - [self.contentViewer.fullZoom, self.contentViewer.textZoom]; + this.getPref("dactyl.content.full-zoom", (val) => { + if (val != null && uri.equals(this.uri) && val != prefs.get("browser.zoom.full")) + [this.contentViewer.textZoom, this.contentViewer.fullZoom] = + [this.contentViewer.fullZoom, this.contentViewer.textZoom]; }); } }), @@ -1365,10 +1365,10 @@ var Buffer = Module("Buffer", { get scrollRightMax() this.win.scrollMaxY, get scrollLeft() this.win.scrollX, - set scrollLeft(val) { this.win.scrollTo(val, this.win.scrollY) }, + set scrollLeft(val) { this.win.scrollTo(val, this.win.scrollY); }, get scrollTop() this.win.scrollY, - set scrollTop(val) { this.win.scrollTo(this.win.scrollX, val) } + set scrollTop(val) { this.win.scrollTo(this.win.scrollX, val); } }; return elem; }, @@ -1471,8 +1471,13 @@ var Buffer = Module("Buffer", { return elem[pos] > 0; let max = pos + "Max"; - if (max in elem && pos > 0) - return elem[pos] < elem[max]; + if (max in elem) { + if (elem[pos] < elem[max]) + return true; + if (dir > 0) + return false; + return elem[pos] > 0; + } let style = DOM(elem).style; let borderSize = Math.round(parseFloat(style[border1]) + parseFloat(style[border2])); @@ -1672,7 +1677,7 @@ var Buffer = Module("Buffer", { return { x: elem.scrollLeft && elem.scrollLeft / this._exWidth(node), y: elem.scrollTop / parseFloat(style.lineHeight) - } + }; }, _exWidth: function _exWidth(elem) { @@ -1739,7 +1744,7 @@ var Buffer = Module("Buffer", { const BRANCH = "printer_" + PRINTER + "."; const BRANCHES = ["print.", BRANCH, "print." + BRANCH]; function set(pref, value) { - BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value) }); + BRANCHES.forEach(function (branch) { prefs.set(branch + pref, value); }); } prefs.withContext(function () { @@ -2007,17 +2012,17 @@ var Buffer = Module("Buffer", { mappings.add([modes.NORMAL], ["", ""], "Increment last number in URL", - function (args) { buffer.incrementURL(Math.max(args.count, 1)); }, + function ({ count }) { buffer.incrementURL(Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["", ""], "Decrement last number in URL", - function (args) { buffer.incrementURL(-Math.max(args.count, 1)); }, + function ({ count }) { buffer.incrementURL(-Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["gu", ""], "Go to parent directory", - function (args) { buffer.climbUrlPath(Math.max(args.count, 1)); }, + function ({ count }) { buffer.climbUrlPath(Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["gU", ""], @@ -2026,9 +2031,9 @@ var Buffer = Module("Buffer", { mappings.add([modes.COMMAND], [".", ""], "Repeat the last key event", - function (args) { + function ({ count }) { if (mappings.repeat) { - for (let i in util.interruptibleRange(0, Math.max(args.count, 1), 100)) + for (let i in util.interruptibleRange(0, Math.max(count, 1), 100)) mappings.repeat(); } }, @@ -2045,22 +2050,22 @@ var Buffer = Module("Buffer", { // scrolling mappings.add([modes.NORMAL], ["j", "", "", ""], "Scroll document down", - function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollVertical("lines", Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["k", "", "", ""], "Scroll document up", - function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollVertical("lines", -Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], dactyl.has("mail") ? ["h", ""] : ["h", "", ""], "Scroll document to the left", - function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollHorizontal("columns", -Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], dactyl.has("mail") ? ["l", ""] : ["l", "", ""], "Scroll document to the right", - function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollHorizontal("columns", Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["0", "^", ""], @@ -2073,112 +2078,113 @@ var Buffer = Module("Buffer", { mappings.add([modes.NORMAL], ["gg", "", ""], "Go to the top of the document", - function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 0); }, + function ({ count }) { buffer.scrollToPercent(null, count != null ? count : 0, + count != null ? 0 : -1); }, { count: true }); mappings.add([modes.NORMAL], ["G", "", ""], "Go to the end of the document", - function (args) { - if (args.count) + function ({ count }) { + if (count) var elem = options.get("linenumbers") .getLine(buffer.focusedFrame.document, - args.count); + count); if (elem) elem.scrollIntoView(true); - else if (args.count) - buffer.scrollToPosition(null, args.count); + else if (count) + buffer.scrollToPosition(null, count); else - buffer.scrollToPercent(null, 100); + buffer.scrollToPercent(null, 100, 1); }, { count: true }); mappings.add([modes.NORMAL], ["%", ""], "Scroll to {count} percent of the document", - function (args) { - dactyl.assert(args.count > 0 && args.count <= 100); - buffer.scrollToPercent(null, args.count); + function ({ count }) { + dactyl.assert(count > 0 && count <= 100); + buffer.scrollToPercent(null, count); }, { count: true }); mappings.add([modes.NORMAL], ["", ""], "Scroll window downwards in the buffer", - function (args) { buffer._scrollByScrollSize(args.count, true); }, + function ({ count }) { buffer._scrollByScrollSize(count, true); }, { count: true }); mappings.add([modes.NORMAL], ["", ""], "Scroll window upwards in the buffer", - function (args) { buffer._scrollByScrollSize(args.count, false); }, + function ({ count }) { buffer._scrollByScrollSize(count, false); }, { count: true }); mappings.add([modes.NORMAL], ["", "", "", ""], "Scroll up a full page", - function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollVertical("pages", -Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], [""], "Scroll down a full page", - function (args) { + function ({ count }) { if (isinstance((services.focus.focusedWindow || buffer.win).document.activeElement, [Ci.nsIDOMHTMLInputElement, Ci.nsIDOMHTMLButtonElement, Ci.nsIDOMXULButtonElement])) return Events.PASS; - buffer.scrollVertical("pages", Math.max(args.count, 1)); + buffer.scrollVertical("pages", Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["", "", ""], "Scroll down a full page", - function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollVertical("pages", Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["]f", ""], "Focus next frame", - function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); }, + function ({ count }) { buffer.shiftFrameFocus(Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["[f", ""], "Focus previous frame", - function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); }, + function ({ count }) { buffer.shiftFrameFocus(-Math.max(count, 1)); }, { count: true }); mappings.add([modes.NORMAL], ["["], "Jump to the previous element as defined by 'jumptags'", - function (args) { buffer.findJump(args.arg, args.count, true); }, + function ({ arg, count }) { buffer.findJump(arg, count, true); }, { arg: true, count: true }); mappings.add([modes.NORMAL], ["g]"], "Jump to the next off-screen element as defined by 'jumptags'", - function (args) { buffer.findJump(args.arg, args.count, false, true); }, + function ({ arg, count }) { buffer.findJump(arg, count, false, true); }, { arg: true, count: true }); mappings.add([modes.NORMAL], ["]"], "Jump to the next element as defined by 'jumptags'", - function (args) { buffer.findJump(args.arg, args.count, false); }, + function ({ arg, count }) { buffer.findJump(arg, count, false); }, { arg: true, count: true }); mappings.add([modes.NORMAL], ["{"], "Jump to the previous paragraph", - function (args) { buffer.findJump("p", args.count, true); }, + function ({ count }) { buffer.findJump("p", count, true); }, { count: true }); mappings.add([modes.NORMAL], ["}"], "Jump to the next paragraph", - function (args) { buffer.findJump("p", args.count, false); }, + function ({ count }) { buffer.findJump("p", count, false); }, { count: true }); mappings.add([modes.NORMAL], ["]]", ""], "Follow the link labeled 'next' or '>' if it exists", - function (args) { - buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true); + function ({ count }) { + buffer.findLink("next", options["nextpattern"], (count || 1) - 1, true); }, { count: true }); mappings.add([modes.NORMAL], ["[[", ""], "Follow the link labeled 'prev', 'previous' or '<' if it exists", - function (args) { - buffer.findLink("prev", options["previouspattern"], (args.count || 1) - 1, true); + function ({ count }) { + buffer.findLink("prev", options["previouspattern"], (count || 1) - 1, true); }, { count: true }); @@ -2192,10 +2198,10 @@ var Buffer = Module("Buffer", { mappings.add([modes.NORMAL], ["gi", ""], "Focus last used input field", - function (args) { + function ({ count }) { let elem = buffer.lastInputField; - if (args.count >= 1 || !elem || !events.isContentNode(elem)) { + if (count >= 1 || !elem || !events.isContentNode(elem)) { let xpath = ["frame", "iframe", "input", "xul:textbox", "textarea[not(@disabled) and not(@readonly)]"]; let frames = buffer.allFrames(null, true); @@ -2219,7 +2225,7 @@ var Buffer = Module("Buffer", { }); dactyl.assert(elements.length > 0); - elem = elements[Math.constrain(args.count, 1, elements.length) - 1]; + elem = elements[Math.constrain(count, 1, elements.length) - 1]; } buffer.focusElement(elem); DOM(elem).scrollIntoView(); @@ -2275,52 +2281,52 @@ var Buffer = Module("Buffer", { // zooming mappings.add([modes.NORMAL], ["zi", "+", ""], "Enlarge text zoom of current web page", - function (args) { buffer.zoomIn(Math.max(args.count, 1), false); }, + function ({ count }) { buffer.zoomIn(Math.max(count, 1), false); }, { count: true }); mappings.add([modes.NORMAL], ["zm", ""], "Enlarge text zoom of current web page by a larger amount", - function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); }, + function ({ count }) { buffer.zoomIn(Math.max(count, 1) * 3, false); }, { count: true }); mappings.add([modes.NORMAL], ["zo", "-", ""], "Reduce text zoom of current web page", - function (args) { buffer.zoomOut(Math.max(args.count, 1), false); }, + function ({ count }) { buffer.zoomOut(Math.max(count, 1), false); }, { count: true }); mappings.add([modes.NORMAL], ["zr", ""], "Reduce text zoom of current web page by a larger amount", - function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); }, + function ({ count }) { buffer.zoomOut(Math.max(count, 1) * 3, false); }, { count: true }); mappings.add([modes.NORMAL], ["zz", ""], "Set text zoom value of current web page", - function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); }, + function ({ count }) { buffer.setZoom(count > 1 ? count : 100, false); }, { count: true }); mappings.add([modes.NORMAL], ["ZI", "zI", ""], "Enlarge full zoom of current web page", - function (args) { buffer.zoomIn(Math.max(args.count, 1), true); }, + function ({ count }) { buffer.zoomIn(Math.max(count, 1), true); }, { count: true }); mappings.add([modes.NORMAL], ["ZM", "zM", ""], "Enlarge full zoom of current web page by a larger amount", - function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); }, + function ({ count }) { buffer.zoomIn(Math.max(count, 1) * 3, true); }, { count: true }); mappings.add([modes.NORMAL], ["ZO", "zO", ""], "Reduce full zoom of current web page", - function (args) { buffer.zoomOut(Math.max(args.count, 1), true); }, + function ({ count }) { buffer.zoomOut(Math.max(count, 1), true); }, { count: true }); mappings.add([modes.NORMAL], ["ZR", "zR", ""], "Reduce full zoom of current web page by a larger amount", - function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); }, + function ({ count }) { buffer.zoomOut(Math.max(count, 1) * 3, true); }, { count: true }); mappings.add([modes.NORMAL], ["zZ", ""], "Set full zoom value of current web page", - function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); }, + function ({ count }) { buffer.setZoom(count > 1 ? count : 100, true); }, { count: true }); // page info @@ -2656,7 +2662,7 @@ Buffer.addPageInfoSection("m", "Meta Tags", function (verbose) { }); Buffer.addPageInfoSection("s", "Security", function (verbose) { - let { statusline } = this.modules + let { statusline } = this.modules; let identity = this.topWindow.gIdentityHandler; @@ -2697,4 +2703,4 @@ Buffer.addPageInfoSection("s", "Security", function (verbose) { endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/cache.jsm b/common/modules/cache.jsm index 5f39bc6..e25bd42 100644 --- a/common/modules/cache.jsm +++ b/common/modules/cache.jsm @@ -28,7 +28,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), { "cache": function (uri, path) { let contentType = "text/plain"; try { - contentType = services.mime.getTypeFromURI(uri) + contentType = services.mime.getTypeFromURI(uri); } catch (e) {} @@ -268,4 +268,4 @@ endModule(); // catch(e){ if (typeof e === "string") e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 199cfff..617c6bd 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -352,7 +352,7 @@ var Command = Class("Command", { { configurable: true, enumerable: true, get: function () opt.default }; if (prop.get && !prop.set) - prop.set = function (val) { Class.replaceProperty(this, opt.names[0], val) }; + prop.set = function (val) { Class.replaceProperty(this, opt.names[0], val); }; Object.defineProperty(res, opt.names[0], prop); } }); @@ -536,7 +536,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { if (this.cached) this.modules.initDependencies("commands"); this.cached = false; - return array.iterValues(this._list.sort(function (a, b) a.name > b.name)) + return array.iterValues(this._list.sort(function (a, b) a.name > b.name)); }, /** @property {string} The last executed Ex command line. */ @@ -583,8 +583,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { this.remove(name); } - let self = this; - let closure = function () self._map[name]; + let closure = () => this._map[name]; memoize(this._map, name, function () commands.Command(specs, description, action, extra)); if (!extra.hidden) @@ -1171,7 +1170,7 @@ var Commands = Module("commands", { if (sub.substr(0, 2) === "<<" && hereDoc) let ([count, arg] = getNextArg(sub)) { sub = arg + sub.substr(count); - } + }; args.push(sub); args.quote = null; @@ -1572,7 +1571,7 @@ var Commands = Module("commands", { return dactyl.userEval(completer); }); if (callable(result)) - return result.apply(this, Array.slice(arguments)); + return result.apply(this, arguments); else return context.completions = result; }; @@ -1765,9 +1764,9 @@ var Commands = Module("commands", { mappings.add([modes.COMMAND], ["@:"], "Repeat the last Ex command", - function (args) { + function ({ count }) { if (commands.repeat) { - for (let i in util.interruptibleRange(0, Math.max(args.count, 1), 100)) + for (let i in util.interruptibleRange(0, Math.max(count, 1), 100)) dactyl.execute(commands.repeat); } else @@ -1787,7 +1786,7 @@ let quote = function quote(q, list, map) { Commands.quoteMap = { "\n": "\\n", - "\t": "\\t", + "\t": "\\t" }; Commands.quoteArg = { @@ -1813,4 +1812,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index eec3857..24b091a 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -135,10 +135,10 @@ var CompletionContext = Class("CompletionContext", { * {@link #filters} array. */ this.filterFunc = function filterFunc(items) { - let self = this; - return this.filters. - reduce(function r(res, filter) res.filter(function f(item) filter.call(self, item)), - items); + return this.filters + .reduce((res, filter) + => res.filter((item) => filter.call(this, item)), + items); }; /** * @property {Array} An array of predicates on which to filter the @@ -674,7 +674,6 @@ var CompletionContext = Class("CompletionContext", { }, getRows: function getRows(start, end, doc) { - let self = this; let items = this.items; let cache = this.cache.rows; let step = start > end ? -1 : 1; @@ -706,8 +705,8 @@ var CompletionContext = Class("CompletionContext", { * for the new context. If a string is provided, it is * interpreted as a method to access on *self*. */ - fork: function fork(name, offset, self, completer) { - return this.forkapply(name, offset, self, completer, Array.slice(arguments, fork.length)); + fork: function fork(name, offset, self, completer, ...args) { + return this.forkapply(name, offset, self, completer, args); }, forkapply: function forkapply(name, offset, self, completer, args) { @@ -732,13 +731,11 @@ var CompletionContext = Class("CompletionContext", { return context; }, - split: function split(name, obj, fn) { - const self = this; - + split: function split(name, obj, fn, ...args) { let context = this.fork(name); - function alias(prop) { - context.__defineGetter__(prop, function get_() self[prop]); - context.__defineSetter__(prop, function set_(val) self[prop] = val); + let alias = (prop) => { + context.__defineGetter__(prop, () => this[prop]); + context.__defineSetter__(prop, (val) => this[prop] = val); } alias("_cache"); alias("_completions"); @@ -749,7 +746,7 @@ var CompletionContext = Class("CompletionContext", { context.hasItems = true; this.hasItems = false; if (fn) - return fn.apply(obj || this, [context].concat(Array.slice(arguments, split.length))); + return fn.apply(obj || this, [context].concat(args)); return context; }, @@ -821,7 +818,6 @@ var CompletionContext = Class("CompletionContext", { * context. */ reset: function reset() { - let self = this; if (this.parent) throw Error(); @@ -842,7 +838,7 @@ var CompletionContext = Class("CompletionContext", { this.value = this._value; this._caret = this.value.length; } - //for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret))) + //for (let key in (k for ([k, v] in Iterator(this.contexts)) if (v.offset > this.caret))) // delete this.contexts[key]; for each (let context in this.contexts) { context.hasItems = false; @@ -907,10 +903,10 @@ var Completion = Module("completion", { get options() modules.options, // FIXME - _runCompleter: function _runCompleter(name, filter, maxItems) { + _runCompleter: function _runCompleter(name, filter, maxItems, ...args) { let context = modules.CompletionContext(filter); context.maxItems = maxItems; - let res = context.fork.apply(context, ["run", 0, this, name].concat(Array.slice(arguments, 3))); + let res = context.fork.apply(context, ["run", 0, this, name].concat(args)); if (res) { if (Components.stack.caller.name === "runCompleter") // FIXME return { items: res.map(function m(i) ({ item: i })) }; @@ -921,14 +917,14 @@ var Completion = Module("completion", { }, runCompleter: function runCompleter(name, filter, maxItems) { - return this._runCompleter.apply(this, Array.slice(arguments)) + return this._runCompleter.apply(this, arguments) .items.map(function m(i) i.item); }, - listCompleter: function listCompleter(name, filter, maxItems) { + listCompleter: function listCompleter(name, filter, maxItems, ...args) { let context = modules.CompletionContext(filter || ""); context.maxItems = maxItems; - context.fork.apply(context, ["list", 0, this, name].concat(Array.slice(arguments, 3))); + context.fork.apply(context, ["list", 0, this, name].concat(args)); context = context.contexts["/list"]; context.wait(null, true); @@ -943,7 +939,7 @@ var Completion = Module("completion", { template.map(contexts, function m(context) [template.completionRow(context.title, "CompTitle"), template.map(context.items, function m(item) context.createRow(item), null, 100)])]); - }, + } }), //////////////////////////////////////////////////////////////////////////////// @@ -991,10 +987,10 @@ var Completion = Module("completion", { }, this); }, - addUrlCompleter: function addUrlCompleter(opt) { - let completer = Completion.UrlCompleter.apply(null, Array.slice(arguments)); - completer.args = Array.slice(arguments, completer.length); - this.urlCompleters[opt] = completer; + addUrlCompleter: function addUrlCompleter(name, description, completer, ...args) { + let completer = Completion.UrlCompleter(name, description, completer); + completer.args = args; + this.urlCompleters[name] = completer; }, autocomplete: curry(function autocomplete(provider, context) { @@ -1019,7 +1015,7 @@ var Completion = Module("completion", { let words = context.filter.toLowerCase().split(/\s+/g); context.hasItems = true; context.completions = context.completions.filter(function f({ url, title }) - words.every(function e(w) (url + " " + title).toLowerCase().indexOf(w) >= 0)) + words.every(function e(w) (url + " " + title).toLowerCase().indexOf(w) >= 0)); context.format = this.modules.bookmarks.format; context.keys.extra = function k_extra(item) { @@ -1229,4 +1225,4 @@ endModule(); // catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/config.jsm b/common/modules/config.jsm index 305880d..9e5b7c0 100644 --- a/common/modules/config.jsm +++ b/common/modules/config.jsm @@ -37,7 +37,7 @@ AboutHandler.prototype = { return channel; }, - getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT, + getURIFlags: function (uri) Ci.nsIAboutModule.ALLOW_SCRIPT }; var ConfigBase = Class("ConfigBase", { /** @@ -415,7 +415,7 @@ var ConfigBase = Class("ConfigBase", { "list.href": Class.Memoize(function () "http://groups.google.com/group/" + config.name), "hg.latest": Class.Memoize(function () this.code + "source/browse/"), // XXX - "irc": "irc://irc.oftc.net/#pentadactyl", + "irc": "irc://irc.oftc.net/#pentadactyl" }), dtdExtra: { @@ -494,7 +494,7 @@ var ConfigBase = Class("ConfigBase", { */ get outputHeight() this.browser.mPanelContainer.boxObject.height, - tabStrip: Class.Memoize(function () document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer), + tabStrip: Class.Memoize(function () document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer) }), /** @@ -568,12 +568,6 @@ var ConfigBase = Class("ConfigBase", { sidebars: {}, - /** - * @property {string} The leaf name of any temp files created by - * {@link io.createTempFile}. - */ - get tempFile() this.name + ".txt", - /** * @constant * @property {string} The default highlighting rules. @@ -620,4 +614,4 @@ endModule(); // catch(e){ if (typeof e === "string") e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index c34d2dd..ffada2b 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -19,8 +19,6 @@ var Const = function Const(val) Class.Property({ enumerable: true, value: val }) var Group = Class("Group", { init: function init(name, description, filter, persist) { - const self = this; - this.name = name; this.description = description; this.filter = filter || this.constructor.defaultFilter; @@ -67,7 +65,7 @@ var Group = Class("Group", { get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0, }, { - compileFilter: function (patterns, default_) { + compileFilter: function (patterns, default_ = false) { if (arguments.length < 2) default_ = false; @@ -171,13 +169,12 @@ var Contexts = Module("contexts", { Hives: Class("Hives", Class.Property, { init: function init(name, constructor) { const { contexts } = modules; - const self = this; if (this.Hive) return { enumerable: true, - get: function () array(contexts.groups[self.name]) + get: () => array(contexts.groups[this.name]) }; this.Hive = constructor; @@ -546,7 +543,7 @@ var Contexts = Module("contexts", { if (callable(params)) action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })"); else - action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg).array); + action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg)); process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param; action.params = params; action.makeParams = makeParams; @@ -819,4 +816,4 @@ endModule(); // catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/dom-e4x.jsm b/common/modules/dom-e4x.jsm index 5a1cdfb..c83810b 100644 --- a/common/modules/dom-e4x.jsm +++ b/common/modules/dom-e4x.jsm @@ -51,3 +51,4 @@ function fromXML(node, doc, nodes) { } } +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 61e4446..b76bc0f 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -100,7 +100,7 @@ var DOM = Class("DOM", { href: { get: function (elem) elem.href || elem.getAttribute("href") }, src: { get: function (elem) elem.src || elem.getAttribute("src") }, checked: { get: function (elem) elem.hasAttribute("checked") ? elem.getAttribute("checked") == "true" : elem.checked, - set: function (elem, val) { elem.setAttribute("checked", !!val); elem.checked = val } }, + set: function (elem, val) { elem.setAttribute("checked", !!val); elem.checked = val; } }, collapsed: BooleanAttribute("collapsed"), disabled: BooleanAttribute("disabled"), hidden: BooleanAttribute("hidden"), @@ -125,7 +125,7 @@ var DOM = Class("DOM", { if (val instanceof Ci.nsIDOMNode) return val; - if (typeof val == "xml" || DOM.isJSONXML(val)) { + if (DOM.isJSONXML(val)) { val = dom.constructor(val, dom.document); if (container) container[idx] = val[0]; @@ -140,6 +140,9 @@ var DOM = Class("DOM", { return val; } + if (DOM.isJSONXML(val)) + val = (function () this).bind(val); + if (callable(val)) return this.each(function (elem, i) { util.withProperErrors(fn, this, munge(val.call(this, elem, i)), elem, i); @@ -190,8 +193,8 @@ var DOM = Class("DOM", { let res = this.Empty(); this.each(function (elem) { - while(true) { - elem = fn.call(this, elem) + while (true) { + elem = fn.call(this, elem); if (elem instanceof Ci.nsIDOMNode) res[res.length++] = elem; else if (elem && "length" in elem) @@ -269,7 +272,7 @@ var DOM = Class("DOM", { each: function each(meth, arg) { return self.each(function (elem) { elem.classList[meth](arg); - }) + }); }, add: function add(cls) this.each("add", cls), @@ -309,7 +312,7 @@ var DOM = Class("DOM", { let { highlight } = this; let v = callable(val) ? val.call(thisObj || this, elem, i) : val; - highlight[(v == null ? highlight.has(hl) : !v) ? "remove" : "add"](hl) + highlight[(v == null ? highlight.has(hl) : !v) ? "remove" : "add"](hl); }), }), @@ -343,7 +346,7 @@ var DOM = Class("DOM", { get bottom() this.top + this.height, left: r.left + node.clientLeft, get right() this.left + this.width - } + }; }, scrollPos: function scrollPos(left, top) { @@ -575,7 +578,7 @@ var DOM = Class("DOM", { let res = []; this.each(function (elem) { try { - let hasChildren = elem.firstChild && (!/^\s*$/.test(elem.firstChild) || elem.firstChild.nextSibling) + let hasChildren = elem.firstChild && (!/^\s*$/.test(elem.firstChild) || elem.firstChild.nextSibling); if (color) res.push(["span", { highlight: "HelpXML" }, ["span", { highlight: "HelpXMLTagStart" }, @@ -590,7 +593,7 @@ var DOM = Class("DOM", { ], !hasChildren ? "" : ["", "...", - ["span", { highlight: "HtmlTagEnd" },"<", namespaced(elem), ">"]] + ["span", { highlight: "HtmlTagEnd" }, "<", namespaced(elem), ">"]] ]); else { let tag = "<" + [namespaced(elem)].concat( @@ -791,19 +794,19 @@ var DOM = Class("DOM", { html: function html(txt, self) { return this.getSet(arguments, function (elem) elem.innerHTML, - util.wrapCallback(function (elem, val) { elem.innerHTML = val })); + util.wrapCallback(function (elem, val) { elem.innerHTML = val; })); }, text: function text(txt, self) { return this.getSet(arguments, function (elem) elem.textContent, - function (elem, val) { elem.textContent = val }); + function (elem, val) { elem.textContent = val; }); }, val: function val(txt) { return this.getSet(arguments, function (elem) elem.value, - function (elem, val) { elem.value = val == null ? "" : val }); + function (elem, val) { elem.value = val == null ? "" : val; }); }, listen: function listen(event, listener, capture) { @@ -902,7 +905,7 @@ var DOM = Class("DOM", { return true; if (rect.top > viewport.bottom) return false; - return Math.abs(rect.top) < Math.abs(viewport.bottom - rect.bottom) + return Math.abs(rect.top) < Math.abs(viewport.bottom - rect.bottom); } let rect; @@ -1063,7 +1066,6 @@ var DOM = Class("DOM", { return this; }, - code_key: Class.Memoize(function (prop) this.init()[prop]), code_nativeKey: Class.Memoize(function (prop) this.init()[prop]), keyTable: Class.Memoize(function (prop) this.init()[prop]), @@ -1331,7 +1333,6 @@ var DOM = Class("DOM", { return "<" + modifier + key + ">"; }, - defaults: { load: { bubbles: false }, submit: { cancelable: true } @@ -1613,7 +1614,7 @@ var DOM = Class("DOM", { else elem.setAttributeNS(vals[0] || "", key, val); } - args.forEach(function(e) { + args.forEach(function (e) { elem.appendChild(tag(e, namespaces)); }); @@ -1627,7 +1628,7 @@ var DOM = Class("DOM", { else namespaces = fromJSON.namespaces; - return tag(xml, namespaces) + return tag(xml, namespaces); }, { namespaces: { "": "http://www.w3.org/1999/xhtml", @@ -1663,13 +1664,13 @@ var DOM = Class("DOM", { function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === ""; function hasString(args) { - return args.some(function (a) isString(a) || isFragment(a) && hasString(a)) + return args.some(function (a) isString(a) || isFragment(a) && hasString(a)); } function isStrings(args) { if (!isArray(args)) return util.dump("ARGS: " + {}.toString.call(args) + " " + args), false; - return args.every(function (a) isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a)) + return args.every(function (a) isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a)); } function tag(args, namespaces, indent) { @@ -1724,7 +1725,7 @@ var DOM = Class("DOM", { contents.push(string); }); if (contents.length) - res.push(contents.join("\n"), join) + res.push(contents.join("\n"), join); }); if (res[res.length - 1] == join) res.pop(); @@ -1785,7 +1786,7 @@ var DOM = Class("DOM", { ""); else { let contents = []; - args.forEach(function(e) { + args.forEach(function (e) { let string = tag(e, namespaces, indent + INDENT); if (string) contents.push(string); @@ -1803,7 +1804,7 @@ var DOM = Class("DOM", { else namespaces = DOM.fromJSON.namespaces; - return tag(xml, namespaces, "") + return tag(xml, namespaces, ""); }, parseNamespace: function parseNamespace(name, namespaces) { @@ -1908,4 +1909,4 @@ endModule(); // catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm index fdf5925..26ac1cc 100644 --- a/common/modules/downloads.jsm +++ b/common/modules/downloads.jsm @@ -23,21 +23,20 @@ var states = iter([v, k.slice(prefix.length).toLowerCase()] var Download = Class("Download", { init: function init(id, list) { - let self = this; this.download = services.downloadManager.getDownload(id); this.list = list; this.nodes = { - commandTarget: self + commandTarget: this }; DOM.fromJSON( ["tr", { highlight: "Download", key: "row" }, ["td", { highlight: "DownloadTitle" }, ["span", { highlight: "Link" }, - ["a", { key: "launch", href: self.target.spec, path: self.targetFile.path }, - self.displayName], + ["a", { key: "launch", href: this.target.spec, path: this.targetFile.path }, + this.displayName], ["span", { highlight: "LinkInfo" }, - self.targetFile.path]]], + this.targetFile.path]]], ["td", { highlight: "DownloadState", key: "state" }], ["td", { highlight: "DownloadButtons Buttons" }, ["a", { highlight: "Button", href: "javascript:0", key: "pause" }, _("download.action.Pause")], @@ -54,19 +53,19 @@ var Download = Class("Download", { ["td", { highlight: "DownloadSpeed", key: "speed" }], ["td", { highlight: "DownloadTime", key: "time" }], ["td", {}, - ["a", { highlight: "DownloadSource", key: "source", href: self.source.spec }, - self.source.spec]]], + ["a", { highlight: "DownloadSource", key: "source", href: this.source.spec }, + this.source.spec]]], this.list.document, this.nodes); - this.nodes.launch.addEventListener("click", function (event) { + this.nodes.launch.addEventListener("click", (event) => { if (event.button == 0) { event.preventDefault(); - self.command("launch"); + this.command("launch"); } }, false); - self.updateStatus(); - return self; + this.updateStatus(); + return this; }, get status() states[this.state], @@ -102,7 +101,6 @@ var Download = Class("Download", { this.updateStatus(); }, launch: function launch() { - let self = this; // Behavior mimics that of the builtin Download Manager. function action() { try { @@ -119,13 +117,13 @@ var Download = Class("Download", { let file = io.File(this.targetFile); if (file.isExecutable() && prefs.get("browser.download.manager.alertOnEXEOpen", true)) this.list.modules.commandline.input(_("download.prompt.launchExecutable") + " ", - function (resp) { + (resp) => { if (/^a(lways)$/i.test(resp)) { prefs.set("browser.download.manager.alertOnEXEOpen", false); resp = "yes"; } if (/^y(es)?$/i.test(resp)) - action.call(self); + action.call(this); }); else action.call(this); @@ -419,7 +417,6 @@ var Downloads = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), { let file = download.targetFile.path; let size = download.size; - overlay.modules.forEach(function (modules) { modules.dactyl.echomsg({ domains: [util.getHost(url)], message: _("io.downloadFinished", title, file) }, 1, modules.commandline.ACTIVE_WINDOW); @@ -516,4 +513,4 @@ endModule(); // catch(e){ if (isString(e)) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index ee85905..9c1897d 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -851,4 +851,4 @@ var RangeFind = Class("RangeFind", { endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/help.jsm b/common/modules/help.jsm index a092ad5..623aeca 100644 --- a/common/modules/help.jsm +++ b/common/modules/help.jsm @@ -131,12 +131,10 @@ var Help = Module("Help", { let beta = array(betas.iterate(NEWS)) .map(function (m) m[1]).uniq().slice(-1)[0]; - function rec(text, level, li) { let res = []; let list, space, i = 0; - for (let match in re.iterate(text)) { if (match.comment) continue; @@ -195,7 +193,6 @@ var Help = Module("Help", { // } // } - return '\n' + '\n' + DOM.toXML(["document", { xmlns: "dactyl", name: "versions", @@ -448,9 +445,16 @@ var Help = Module("Help", { javascript: function initJavascript(dactyl, modules, window) { modules.JavaScript.setCompleter([modules.help.exportHelp], [function (context, args) overlay.activeModules.completion.file(context)]); + }, + options: function initOptions(dactyl, modules, window) { + const { options } = modules; + + options.add(["helpfile", "hf"], + "Name of the main help file", + "string", "intro"); } }); endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index bf242e0..fca9347 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -218,11 +218,12 @@ var Highlights = Module("Highlight", { * @param {string} class */ selector: function selector(class_) - let (self = this) - class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g, - function (m, n1, hl) n1 + - (self.highlight[hl] && self.highlight[hl].class != class_ - ? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")), + class_.replace(/(^|[>\s])([A-Z][\w-]+)\b/g, + (m, n1, hl) => { + if (this.highlight[hl] && this.highlight[hl].class != class_) + return n1 + this.highlight[hl].selector; + return n1 + "[dactyl|highlight~=" + hl + "]"; + }), groupRegexp: util.regexp(literal(/* ^ @@ -452,4 +453,4 @@ var Highlights = Module("Highlight", { endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 9e717d7..8a3a06b 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -149,7 +149,7 @@ var IO = Module("io", { let sourceJSM = function sourceJSM() { context = contexts.Module(uri); dactyl.triggerObserver("io.source", context, file, file.lastModifiedTime); - } + }; if (/\.jsm$/.test(filename)) sourceJSM(); @@ -307,23 +307,20 @@ var IO = Module("io", { }, /** - * Creates a temporary file. + * Returns a temporary file. * + * @param {string} ext The filename extension. + * @default "txt" + * @param {string} label A metadata string appended to the filename. Useful + * for identifying the file, beyond its extension, to external + * applications. + * @default "" * @returns {File} */ - createTempFile: function createTempFile(name, type) { - if (name instanceof Ci.nsIFile) { - var file = name.clone(); - if (!type || type == "file") - file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); - else - file.createUnique(Ci.nsIFile.DIRECTORY_TYPE, octal(777)); - } - else { - file = services.directory.get("TmpD", Ci.nsIFile); - file.append(this.config.tempFile + (name ? "." + name : "")); - file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); - } + createTempFile: function createTempFile(ext = "txt", label = "") { + let file = services.directory.get("TmpD", Ci.nsIFile); + file.append(config.name + label + "." + ext); + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, octal(666)); services.externalApp.deleteTemporaryFileOnExit(file); @@ -543,9 +540,9 @@ var IO = Module("io", { * @returns {boolean} false if temp files couldn't be created, * otherwise, the return value of *func*. */ - withTempFiles: function withTempFiles(func, self, checked, ext) { + withTempFiles: function withTempFiles(func, self, checked, ext, label) { let args = array(util.range(0, func.length)) - .map(bind("createTempFile", this, ext)).array; + .map(bind("createTempFile", this, ext, label)).array; try { if (!args.every(util.identity)) return false; @@ -639,7 +636,7 @@ var IO = Module("io", { lines.push("\n\" vim: set ft=" + config.name + ":"); try { - file.write(lines.join("\n")); + file.write(lines.join("\n").concat("\n")); dactyl.echomsg(_("io.writing", file.path.quote()), 2); } catch (e) { @@ -675,13 +672,13 @@ var IO = Module("io", { item.file = file; } - rtItems.ftdetect.template = // {{{ + rtItems.ftdetect.template = //{{{ literal(/*" Vim filetype detection file
au BufNewFile,BufRead *rc*,*. set filetype= */);//}}} - rtItems.ftplugin.template = // {{{ + rtItems.ftplugin.template = //{{{ literal(/*" Vim filetype plugin file
@@ -708,7 +705,7 @@ endif let &cpo = s:cpo_save unlet s:cpo_save */);//}}} - rtItems.syntax.template = // {{{ + rtItems.syntax.template = //{{{ literal(/*" Vim syntax file
@@ -812,7 +809,7 @@ unlet s:cpo_save return lines.map(function (l) l.join("")).join("\n").replace(/\s+\n/gm, "\n"); }//}}} - let params = { // {{{ + let params = { //{{{ header: ['" Language: ' + config.appName + ' configuration file', '" Maintainer: Doug Kearns ', '" Version: ' + config.version].join("\n"), @@ -830,7 +827,7 @@ unlet s:cpo_save array(o.realNames for (o in options) if (o.type == "boolean")) .flatten().map(String.quote), ", ") + "]" - }; // }}} + }; //}}} for (let { file, template } in values(rtItems)) { try { @@ -1165,4 +1162,4 @@ endModule(); } catch(e){ if (isString(e)) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index a0981d7..b74c86f 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -765,13 +765,12 @@ var JavaScript = Module("javascript", { init: function init(context) { init.supercall(this); - let self = this; let sandbox = true || isinstance(context, ["Sandbox"]); this.context = modules.newContext(context, !sandbox, "Dactyl REPL Context"); this.js = modules.JavaScript(); this.js.replContext = this.context; - this.js.newContext = function newContext() modules.newContext(self.context, !sandbox, "Dactyl REPL Temp Context"); + this.js.newContext = () => modules.newContext(this.context, !sandbox, "Dactyl REPL Temp Context"); this.js.globals = [ [this.context, /*L*/"REPL Variables"], @@ -856,8 +855,7 @@ var JavaScript = Module("javascript", { mappings: function initMappings(dactyl, modules, window) { const { mappings, modes } = modules; - function bind() mappings.add.apply(mappings, - [[modes.REPL]].concat(Array.slice(arguments))) + function bind(...args) mappings.add.apply(mappings, [[modes.REPL]].concat(args)) bind([""], "Accept the current input", function ({ self }) { self.accept(); }); @@ -900,4 +898,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/main.jsm b/common/modules/main.jsm index 41ef16c..ae6926d 100644 --- a/common/modules/main.jsm +++ b/common/modules/main.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2012 Kris Maglione +// Copyright (c) 2009-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -65,14 +65,13 @@ var Modules = function Modules(window) { * * @returns {function} The constructor for the resulting module. */ - function Module(name) { - let args = Array.slice(arguments); + function Module(name, ...args) { var base = ModuleBase; - if (callable(args[1])) - base = args.splice(1, 1)[0]; + if (callable(args[0])) + base = args.shift(); - let [, prototype, classProperties, moduleInit] = args; + let [prototype, classProperties, moduleInit] = args; prototype._metaInit_ = function () { delete module.prototype._metaInit_; Class.replaceProperty(modules, module.className, this); @@ -92,7 +91,6 @@ var Modules = function Modules(window) { const create = window.Object.create.bind(window.Object); - const BASES = [BASE, "resource://dactyl-local-content/"]; jsmodules = Cu.createObjectIn(window); @@ -322,25 +320,24 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({ }, scanModules: function scanModules() { - let self = this; let { Module, modules } = this.modules; - defineModule.modules.forEach(function defModule(mod) { + defineModule.modules.forEach((mod) => { let names = Set(Object.keys(mod.INIT)); if ("init" in mod.INIT) Set.add(names, "init"); - keys(names).forEach(function (name) { self.deferInit(name, mod.INIT, mod); }); + keys(names).forEach((name) => { this.deferInit(name, mod.INIT, mod); }); }); - Module.list.forEach(function frobModule(mod) { + Module.list.forEach((mod) => { if (!mod.frobbed) { - modules.__defineGetter__(mod.className, function () { + modules.__defineGetter__(mod.className, () => { delete modules[mod.className]; - return self.loadModule(mod.className, null, Components.stack.caller); + return this.loadModule(mod.className, null, Components.stack.caller); }); Object.keys(mod.prototype.INIT) - .forEach(function (name) { self.deferInit(name, mod.prototype.INIT, mod); }); + .forEach((name) => { this.deferInit(name, mod.prototype.INIT, mod); }); } mod.frobbed = true; }); @@ -357,4 +354,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm index 12ab0f3..533c004 100644 --- a/common/modules/messages.jsm +++ b/common/modules/messages.jsm @@ -98,7 +98,7 @@ var Messages = Module("messages", { file = io.File(file); function properties(base, iter_, prop) iter(function _properties() { - function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[\\:=]/g, "\\$&"); + function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&"); prop = prop || "description"; for (var obj in iter_) { @@ -147,7 +147,6 @@ var Messages = Module("messages", { obj[_prop] = this.default; return { get: function get() { - let self = this; let value = this[_prop]; function getter(key, default_) function getter() messages.get([name, key].join("."), default_); @@ -205,4 +204,4 @@ endModule(); // catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 1440e23..ac5ceb9 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2013 by Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -258,7 +258,7 @@ var Option = Class("Option", { return null; }, - // Properties {{{2 + // Properties {{{ /** @property {string} The option's canonical name. */ name: null, @@ -400,7 +400,8 @@ var Option = Class("Option", { hasChanged: false, /** - * Returns the timestamp when the option's value was last changed. + * @property {number} Returns the timestamp when the option's value was + * last changed. */ get lastSet() options.store.get(this.name).time, set lastSet(val) { options.store.set(this.name, { value: this.globalValue, time: Date.now() }); }, @@ -411,6 +412,7 @@ var Option = Class("Option", { */ setFrom: null + //}}} }, { /** * @property {number} Global option scope. @@ -906,8 +908,6 @@ var Options = Module("options", { * @optional */ add: function add(names, description, type, defaultValue, extraInfo) { - const self = this; - if (!util.isDactyl(Components.stack.caller)) deprecated.warn(add, "options.add", "group.options.add"); @@ -925,7 +925,7 @@ var Options = Module("options", { this.remove(name); } - let closure = function () self._optionMap[name]; + let closure = () => this._optionMap[name]; memoize(this._optionMap, name, function () Option.types[type](modules, names, description, defaultValue, extraInfo)); for (let alias in values(names.slice(1))) @@ -1566,4 +1566,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index f8a4fb5..560982c 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -20,7 +20,7 @@ var setAttr = function setAttr(elem, ns, name, val) { elem.removeAttributeNS(ns, name); else elem.setAttributeNS(ns, name, val); -} +}; var Overlay = Class("Overlay", { init: function init(window) { @@ -42,7 +42,6 @@ var Overlay = Class("Overlay", { } }); - var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { init: function init() { util.addObserver(this); @@ -234,7 +233,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen let iterator = Iterator(obj[key]); if (isArray(obj[key])) { iterator = ([elem[1].id, elem.slice(2), elem[1]] - for each (elem in obj[key])) + for each (elem in obj[key])); } for (let [elem, xml, attrs] in iterator) { @@ -381,7 +380,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen Object.defineProperty(object, k, desc); if (callable(value)) { - var sentinel = "(function DactylOverlay() {}())" + var sentinel = "(function DactylOverlay() {}())"; value.toString = function toString() toString.toString.call(this).replace(/\}?$/, sentinel + "; $&"); value.toSource = function toSource() toSource.toSource.call(this).replace(/\}?$/, sentinel + "; $&"); } @@ -432,4 +431,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/prefs.jsm b/common/modules/prefs.jsm index b0fdd17..d01d1c2 100644 --- a/common/modules/prefs.jsm +++ b/common/modules/prefs.jsm @@ -439,4 +439,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/protocol.jsm b/common/modules/protocol.jsm index 82b59a3..f73e209 100644 --- a/common/modules/protocol.jsm +++ b/common/modules/protocol.jsm @@ -44,9 +44,9 @@ function NetError(orig, error) { originalURI: orig, - asyncOpen: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND }, + asyncOpen: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND; }, - open: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND } + open: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND; } }).data.QueryInterface(Ci.nsIChannel); } function RedirectChannel(to, orig, time, message) { @@ -72,7 +72,7 @@ function Protocol(scheme, classID, contentBase) { contentBase: contentBase, - _xpcom_factory: JSMLoader.Factory(Protocol), + _xpcom_factory: JSMLoader.Factory(Protocol) }; return Protocol; } @@ -259,4 +259,4 @@ XMLChannel.prototype = { endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index 9b4eb54..01b0eca 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -70,7 +70,6 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef util.addObserver(this); - services.add("contentPrefs", "@mozilla.org/content-pref/service;1", Ci.nsIContentPrefService); services.add("cookies", "@mozilla.org/cookiemanager;1", [Ci.nsICookieManager, Ci.nsICookieManager2, Ci.nsICookieService]); services.add("loginManager", "@mozilla.org/login-manager;1", Ci.nsILoginManager); @@ -201,7 +200,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef template.map(util.range(0, Math.ceil(items.length / 2)), function (i) ["row", {}, template.map(items.slice(i * 2, i * 2 + 2), function (item) - ["checkbox", { xmlns: XUL, label: item.description, preference: branch + item.name }])])]]], + ["checkbox", { xmlns: XUL, label: item.description, preference: branch + item.name }])])]]] } })); } @@ -215,7 +214,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef template.map(ourItems(), function ([item, desc]) ["listitem", { xmlns: "xul", preference: branch + item, type: "checkbox", label: config.appName + ", " + desc, - onsyncfrompreference: "return gSanitizePromptDialog.onReadGeneric();" }]), + onsyncfrompreference: "return gSanitizePromptDialog.onReadGeneric();" }]) ] }, ready: function ready(win) { @@ -508,7 +507,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef description: "Timespan for which to sanitize items", completer: function (context) modules.options.get("sanitizetimespan").completer(context), type: modules.CommandOption.STRING, - validator: function (arg) modules.options.get("sanitizetimespan").validator(arg), + validator: function (arg) modules.options.get("sanitizetimespan").validator(arg) } ], privateData: true @@ -599,19 +598,6 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef }, options: function initOptions(dactyl, modules) { const options = modules.options; - if (services.has("privateBrowsing") && "privateBrowsingEnabled" in services.privateBrowsing) - options.add(["private", "pornmode"], - "Set the 'private browsing' option", - "boolean", false, - { - initialValue: true, - getter: function () services.privateBrowsing.privateBrowsingEnabled, - setter: function (value) { - if (services.privateBrowsing.privateBrowsingEnabled != value) - services.privateBrowsing.privateBrowsingEnabled = value; - }, - persist: false - }); options.add(["sanitizeitems", "si"], "The default list of private items to sanitize", @@ -731,4 +717,4 @@ endModule(); // catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);} -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/services.jsm b/common/modules/services.jsm index d3ac781..377cd13 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -47,13 +47,13 @@ var Services = Module("Services", { this.add("downloadManager", "@mozilla.org/download-manager;1", "nsIDownloadManager"); this.add("environment", "@mozilla.org/process/environment;1", "nsIEnvironment"); this.add("extensionManager", "@mozilla.org/extensions/manager;1", "nsIExtensionManager"); - this.add("externalApp", "@mozilla.org/uriloader/external-helper-app-service;1", "nsPIExternalAppLauncher") + this.add("externalApp", "@mozilla.org/uriloader/external-helper-app-service;1", "nsPIExternalAppLauncher"); this.add("externalProtocol", "@mozilla.org/uriloader/external-protocol-service;1", "nsIExternalProtocolService"); this.add("favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"); this.add("file:", this.PROTOCOL + "file", "nsIFileProtocolHandler"); this.add("focus", "@mozilla.org/focus-manager;1", "nsIFocusManager"); - this.add("history", "@mozilla.org/browser/global-history;2", - ["nsIBrowserHistory", "nsIGlobalHistory2", "nsINavHistoryService", "nsPIPlacesDatabase"]); + this.add("history", "@mozilla.org/browser/nav-history-service;1", + ["nsIBrowserHistory", "nsINavHistoryService", "nsPIPlacesDatabase"]); this.add("io", "@mozilla.org/network/io-service;1", "nsIIOService"); this.add("json", "@mozilla.org/dom/json;1", "nsIJSON", "createInstance"); this.add("listeners", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"); @@ -99,7 +99,7 @@ var Services = Module("Services", { this.addClass("Persist", "@mozilla.org/embedding/browser/nsWebBrowserPersist;1", "nsIWebBrowserPersist"); this.addClass("Pipe", "@mozilla.org/pipe;1", "nsIPipe", "init"); this.addClass("Process", "@mozilla.org/process/util;1", "nsIProcess", "init"); - this.addClass("Pump", "@mozilla.org/network/input-stream-pump;1", "nsIInputStreamPump", "init") + this.addClass("Pump", "@mozilla.org/network/input-stream-pump;1", "nsIInputStreamPump", "init"); this.addClass("StreamChannel","@mozilla.org/network/input-stream-channel;1", ["nsIInputStreamChannel", "nsIChannel"], "setURI"); this.addClass("StreamCopier", "@mozilla.org/network/async-stream-copier;1","nsIAsyncStreamCopier", "init"); @@ -126,7 +126,7 @@ var Services = Module("Services", { if (!service.interfaces.length) return res.wrappedJSObject || res; - service.interfaces.forEach(function (iface) res.QueryInterface(Ci[iface])); + service.interfaces.forEach(function (iface) res instanceof Ci[iface]); if (service.init && args.length) { if (service.callable) res[service.init].apply(res, args); @@ -139,7 +139,7 @@ var Services = Module("Services", { if (service.quiet === false) throw e.stack ? e : Error(e); - if (typeof util !== "undefined") + if (typeof util !== "undefined" && util != null) util.reportError(e); else dump("dactyl: Service creation failed for '" + service.class + "': " + e + "\n" + (e.stack || Error(e).stack)); @@ -176,13 +176,12 @@ var Services = Module("Services", { * class. */ addClass: function addClass(name, class_, ifaces, init, quiet) { - const self = this; this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []), method: "createInstance", init: init, quiet: quiet }; if (init) memoize(this.services[name], "callable", function () callable(XPCOMShim(this.interfaces)[this.init])); - this[name] = function Create() self._create(name, arguments); + this[name] = (function Create() this._create(name, arguments)).bind(this); update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))])); return this[name]; }, @@ -214,4 +213,4 @@ endModule(); } catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);} -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 0f4cc06..f37524d 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -162,7 +162,7 @@ var ObjectStore = Class("ObjectStore", StoreBase, { } }); -var sessionGlobal = Cu.import("resource://gre/modules/Services.jsm", {}) +var sessionGlobal = Cu.import("resource://gre/modules/Services.jsm", {}); var Storage = Module("Storage", { Local: function Local(dactyl, modules, window) ({ @@ -241,7 +241,6 @@ var Storage = Module("Storage", { }, newObject: function newObject(key, constructor, params) { - let self = this; if (params == null || !isObject(params)) throw Error("Invalid argument type"); @@ -261,10 +260,10 @@ var Storage = Module("Storage", { if (key in this && !reload) throw Error("Cannot add storage key with that name."); - let load = function () self._loadData(key, params.store, params.type || myObject); + let load = () => this._loadData(key, params.store, params.type || myObject); this.keys[key] = new constructor(key, params.store, load, params); - this.keys[key].timer = new Timer(1000, 10000, function () self.save(key)); + this.keys[key].timer = new Timer(1000, 10000, () => this.save(key)); this.__defineGetter__(key, function () this.keys[key]); } return this.keys[key]; @@ -762,7 +761,6 @@ var File = Class("File", { } }, - isAbsolutePath: function isAbsolutePath(path) { try { services.File().initWithPath(path); @@ -793,7 +791,7 @@ let (file = services.directory.get("ProfD", Ci.nsIFile)) { if (!(prop in File.prototype)) { let isFunction; try { - isFunction = callable(file[prop]) + isFunction = callable(file[prop]); } catch (e) {} @@ -814,4 +812,4 @@ endModule(); // catch(e){ dump(e + "\n" + (e.stack || Error().stack)); Components.utils.reportError(e) } -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index c89c281..ffa4c69 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -29,7 +29,7 @@ Sheet.liveProperty = function (name) { this[i] = val; this.enabled = this.enabled; }); -} +}; Sheet.liveProperty("agent"); Sheet.liveProperty("css"); Sheet.liveProperty("sites"); @@ -203,7 +203,6 @@ var Hive = Class("Hive", { * @param {number} index */ remove: function remove(name, filter, css, index) { - let self = this; if (arguments.length == 1) { var matches = [name]; name = null; @@ -211,7 +210,7 @@ var Hive = Class("Hive", { if (filter && filter.indexOf(",") > -1) return filter.split(",").reduce( - function (n, f) n + self.removeSheet(name, f, index), 0); + (n, f) => n + this.removeSheet(name, f, index), 0); if (filter == undefined) filter = ""; @@ -763,9 +762,9 @@ var Styles = Module("Styles", { ]); }), match.postSpace - ] - }) - } + ]; + }); + }; } }); @@ -773,4 +772,4 @@ endModule(); // catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);} -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 47fd94d..b9f5fda 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -168,7 +168,6 @@ var Template = Module("Template", { return res; }, - bookmarkDescription: function (item, text) [ !(item.extra && item.extra.length) ? [] : ["span", { highlight: "URLExtra" }, @@ -264,7 +263,6 @@ var Template = Module("Template", { })(), this[help ? "HelpLink" : "helpLink"]); }, - // Fixes some strange stack rewinds on NS_ERROR_OUT_OF_MEMORY // exceptions that we can't catch. stringify: function stringify(arg) { @@ -417,7 +415,6 @@ var Template = Module("Template", { util.losslessDecodeURI(val.URI.spec)]]])]; }, - options: function options(title, opts, verbose) { return ["table", {}, ["tr", { highlight: "Title", align: "left" }, @@ -459,26 +456,24 @@ var Template = Module("Template", { }, tabular: function tabular(headings, style, iter) { - let self = this; // TODO: This might be mind-bogglingly slow. We'll see. return ["table", {}, ["tr", { highlight: "Title", align: "left" }, this.map(headings, function (h) ["th", {}, h])], - this.map(iter, function (row) + this.map(iter, (row) => ["tr", {}, - self.map(Iterator(row), function ([i, d]) + this.map(Iterator(row), function ([i, d]) ["td", { style: style[i] || "" }, d])])]; }, usage: function usage(iter, format) { - let self = this; format = format || {}; - let desc = format.description || function (item) self.linkifyHelp(item.description); - let help = format.help || function (item) item.name; - function sourceLink(frame) { - let source = self.sourceLink(frame); + let desc = format.description || (item => this.linkifyHelp(item.description)); + let help = format.help || (item => item.name); + let sourceLink = (frame) => { + let source = this.sourceLink(frame); source[1]["dactyl:hint"] = source[2]; return source; } @@ -486,29 +481,29 @@ var Template = Module("Template", { format.headings ? ["thead", { highlight: "UsageHead" }, ["tr", { highlight: "Title", align: "left" }, - this.map(format.headings, function (h) ["th", {}, h])]] : + this.map(format.headings, (h) => ["th", {}, h])]] : [], format.columns ? ["colgroup", {}, - this.map(format.columns, function (c) ["col", { style: c }])] : + this.map(format.columns, (c) => ["col", { style: c }])] : [], ["tbody", { highlight: "UsageBody" }, - this.map(iter, function (item) + this.map(iter, (item) => // Urgh. let (name = item.name || item.names[0], frame = item.definedAt) ["tr", { highlight: "UsageItem" }, ["td", { style: "padding-right: 2em;" }, ["span", { highlight: "Usage Link" }, !frame ? name : - [self.helpLink(help(item), name, "Title"), + [this.helpLink(help(item), name, "Title"), ["span", { highlight: "LinkInfo" }, _("io.definedAt"), " ", sourceLink(frame)]]]], - item.columns ? self.map(item.columns, function (c) ["td", {}, c]) : [], - ["td", {}, desc(item)]])]] + item.columns ? this.map(item.columns, (c) => ["td", {}, c]) : [], + ["td", {}, desc(item)]])]]; } }); endModule(); -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 0e83efe..bf7b67e 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -467,7 +467,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), acc.push(vals); if (acc.length == pattern.length) - this.res.push(acc.join("")) + this.res.push(acc.join("")); else for (let val in values(vals)) this.rec(acc.concat(val)); @@ -492,7 +492,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } res.push(pattern.substr(end)); return res.map(function (s) util.dequote(s, dequote)); - } + }; let patterns = []; let substrings = split(pattern, /((?:[^\\{]|\\.)*)\{((?:[^\\}]|\\.)*)\}/gy, @@ -507,7 +507,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), else for (let [, pattern] in Iterator(patterns[acc.length])) rec(acc.concat(pattern)); - } + }; rec([]); return res; } @@ -659,7 +659,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), [hours, minutes] = div(minutes, 60); [days, hours] = div(hours, 24); if (days) - return /*L*/days + " days " + hours + " hours" + return /*L*/days + " days " + hours + " hours"; if (hours) return /*L*/hours + "h " + minutes + "m"; if (minutes) @@ -755,11 +755,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let async = params.callback || params.onload || params.onerror; if (async) { - xmlhttp.addEventListener("load", function handler(event) { util.trapErrors(params.onload || params.callback, params, xmlhttp, event) }, false); - xmlhttp.addEventListener("error", function handler(event) { util.trapErrors(params.onerror || params.callback, params, xmlhttp, event) }, false); + xmlhttp.addEventListener("load", function handler(event) { util.trapErrors(params.onload || params.callback, params, xmlhttp, event); }, false); + xmlhttp.addEventListener("error", function handler(event) { util.trapErrors(params.onerror || params.callback, params, xmlhttp, event); }, false); } - if (isObject(params.params)) { let data = [encodeURIComponent(k) + "=" + encodeURIComponent(v) for ([k, v] in iter(params.params))]; @@ -882,7 +881,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let (viewer = docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer) { if (viewer) yield viewer.DOMDocument; - } + }; } } }, @@ -1017,7 +1016,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } let keyIter = object; if ("__iterator__" in object && !callable(object.__iterator__)) - keyIter = keys(object) + keyIter = keys(object); for (let i in keyIter) { let value = Magic(""); @@ -1097,28 +1096,28 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), if (data.length == 0) res.push("[]"); else { - res.push("[\n") + res.push("[\n"); for (let [i, val] in Iterator(data)) { if (i) res.push(",\n"); - res.push(prefix) + res.push(prefix); rec(val, prefix, seen); } res.push("\n", level, "]"); } } else if (isObject(data)) { - res.push("{\n") + res.push("{\n"); let i = 0; for (let [key, val] in Iterator(data)) { if (i++) res.push(",\n"); - res.push(prefix, JSON.stringify(key), ": ") + res.push(prefix, JSON.stringify(key), ": "); rec(val, prefix, seen); } if (i > 0) - res.push("\n", level, "}") + res.push("\n", level, "}"); else res[res.length - 1] = "{}"; } @@ -1623,11 +1622,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * @param {function} func The function to call * @param {object} self The 'this' object for the function. */ - trapErrors: function trapErrors(func, self) { + trapErrors: function trapErrors(func, self, ...args) { try { if (!callable(func)) func = self[func]; - return func.apply(self || this, Array.slice(arguments, 2)); + return func.apply(self || this, args); } catch (e) { this.reportError(e); @@ -1709,9 +1708,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * @param {object} self The 'this' object of the method. * @param ... Arguments to pass to *meth*. */ - withProperErrors: function withProperErrors(meth, self) { + withProperErrors: function withProperErrors(meth, self, ...args) { try { - return (callable(meth) ? meth : self[meth]).apply(self, Array.slice(arguments, withProperErrors.length)); + return (callable(meth) ? meth : self[meth]).apply(self, args); } catch (e) { throw e.stack ? e : Error(e); @@ -1721,7 +1720,6 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), Array: array }); - /** * Math utility methods. * @singleton @@ -1743,4 +1741,4 @@ endModule(); } catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); } -// vim: set fdm=marker sw=4 ts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/tests/functional/dactyl.jsm b/common/tests/functional/dactyl.jsm index 5f7bda5..d738da6 100644 --- a/common/tests/functional/dactyl.jsm +++ b/common/tests/functional/dactyl.jsm @@ -40,7 +40,6 @@ function assertMessage(funcName, want, got, message) { * @param {MozMillController} controller The browser's MozMill controller. */ function Controller(controller) { - var self = this; this.controller = controller; /** @@ -51,13 +50,13 @@ function Controller(controller) { this.errorCount = 0; - this._countBeep = function countBeep() { - self.beepCount++; + this._countBeep = () => { + this.beepCount++; } this.errors = []; - this._countError = function countError(message, highlight) { + this._countError = (message, highlight) => { if (/\b(Error|Warning)Msg\b/.test(highlight)) - self.errors.push(String(message)); + this.errors.push(String(message)); } this.modules.dactyl.registerObserver("beep", this._countBeep); this.modules.dactyl.registerObserver("echoLine", this._countError); @@ -251,8 +250,7 @@ Controller.prototype = { * @param {string} message The message to display upon assertion failure. @optional */ wrapAssertNoErrors: function (func, message) { - let self = this; - return function wrapped() self.assertNoErrors(func, this, arguments, message); + return () => this.assertNoErrors(func, this, arguments, message); }, /** @@ -391,10 +389,10 @@ Controller.prototype = { * @param {...} Extra arguments are passed to the completion * function directly. */ - testCompleter: wrapAssertNoErrors(function testCompleter(self, func, string, message) { + testCompleter: wrapAssertNoErrors(function testCompleter(self, func, string, message, ...args) { var context = this.modules.CompletionContext(string || ""); context.tabPressed = true; - context.forkapply("completions", 0, self, func, Array.slice(arguments, testCompleter.length)); + context.forkapply("completions", 0, self, func, args); utils.assert("dactyl.runCompletions", context.wait(5000), message || "Completion failed: " + self + "." + func); diff --git a/common/tests/functional/testCommands.js b/common/tests/functional/testCommands.js index 2f98625..3382cd9 100644 --- a/common/tests/functional/testCommands.js +++ b/common/tests/functional/testCommands.js @@ -985,9 +985,9 @@ function _runCommands(cmdName, testName, commands) { }); } -function runTest(message, test) { +function runTest(message, test, ...args) { if (test) - var res = test.apply(null, Array.slice(arguments, runTest.length)); + var res = test.apply(null, args); if (res !== undefined) jumlib.assert(res, message); } diff --git a/debian/changelog b/debian/changelog index 0a296f4..e26a1c5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +dactyl (1.0+hg6948-1) UNRELEASED; urgency=low + + * New upstream revision 6948 from the upstream Mercurial repository at + . + - Supports Iceweasel/Firefox versions up to 24, closes: #720447. + + -- Michael Schutte Mon, 09 Sep 2013 10:23:40 +0200 + dactyl (1.0+hg6924-1) unstable; urgency=low * Upload to unstable. diff --git a/debian/rules b/debian/rules index 078f3f6..7fe16fc 100755 --- a/debian/rules +++ b/debian/rules @@ -32,7 +32,7 @@ override_dh_installchangelogs: done UPSTREAM_REPO=../upstream -UPSTREAM_REVISION=6924 +UPSTREAM_REVISION=6948 UPSTREAM_DEST=$(shell pwd)/dactyl.tar.gz get-orig-source: diff --git a/melodactyl/content/config.js b/melodactyl/content/config.js index 273a80c..20a1298 100644 --- a/melodactyl/content/config.js +++ b/melodactyl/content/config.js @@ -324,4 +324,4 @@ const Config = Module("config", ConfigBase, { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/melodactyl/content/library.js b/melodactyl/content/library.js index 95f1659..5ab691e 100644 --- a/melodactyl/content/library.js +++ b/melodactyl/content/library.js @@ -61,4 +61,4 @@ const Library = Module("library", { }, { }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/melodactyl/content/player.js b/melodactyl/content/player.js index 8a7bab2..96e97a0 100644 --- a/melodactyl/content/player.js +++ b/melodactyl/content/player.js @@ -715,7 +715,7 @@ const Player = Module("player", { mappings.add([modes.PLAYER], ["z"], "Previous track", - function (args) { ex.playerprev({ "#": args.count }); }, + function ({ count }) { ex.playerprev({ "#": count }); }, { count: true }); mappings.add([modes.PLAYER], @@ -724,7 +724,7 @@ const Player = Module("player", { mappings.add([modes.PLAYER], ["b"], "Next track", - function (args) { ex.playernext({ "#": args.count }); }, + function ({ count }) { ex.playernext({ "#": count }); }, { count: true }); mappings.add([modes.PLAYER], @@ -753,22 +753,22 @@ const Player = Module("player", { mappings.add([modes.PLAYER], ["h", ""], "Seek -10s", - function (args) { player.seekBackward(Math.max(1, args.count) * 10000); }, + function ({ count} ) { player.seekBackward(Math.max(1, count) * 10000); }, { count: true }); mappings.add([modes.PLAYER], ["l", ""], "Seek +10s", - function (args) { player.seekForward(Math.max(1, args.count) * 10000); }, + function ({ count} ) { player.seekForward(Math.max(1, count) * 10000); }, { count: true }); mappings.add([modes.PLAYER], ["H", ""], "Seek -1m", - function (args) { player.seekBackward(Math.max(1, args.count) * 60000); }, + function ({ count }) { player.seekBackward(Math.max(1, count) * 60000); }, { count: true }); mappings.add([modes.PLAYER], ["L", ""], "Seek +1m", - function (args) { player.seekForward(Math.max(1, args.count) * 60000); }, + function ({ count }) { player.seekForward(Math.max(1, count) * 60000); }, { count: true }); mappings.add([modes.PLAYER], @@ -830,4 +830,4 @@ const Player = Module("player", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index 8c10f83..183f6d1 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -79,16 +79,6 @@ var Config = Module("config", ConfigBase, { else dactyl.beep(); } - }, - - get tempFile() { - let prefix = this.name; - try { - prefix += "-" + window.content.document.location.hostname; - } - catch (e) {} - - return prefix + ".txt"; } }) @@ -221,7 +211,8 @@ var Config = Module("config", ConfigBase, { completion.sidebar = function sidebar(context) { let menu = document.getElementById("viewSidebarMenu"); context.title = ["Sidebar Panel"]; - context.completions = Array.map(menu.childNodes, function (n) [n.getAttribute("label"), ""]); + context.completions = Array.filter(menu.childNodes, function (n) n.hasAttribute("label")) + .map(function (n) [n.getAttribute("label"), ""]); }; }, events: function initEvents(dactyl, modules, window) { @@ -252,4 +243,4 @@ var Config = Module("config", ConfigBase, { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/pentadactyl/install.rdf b/pentadactyl/install.rdf index 51305ac..45fb553 100644 --- a/pentadactyl/install.rdf +++ b/pentadactyl/install.rdf @@ -31,8 +31,8 @@ + em:minVersion="22.0" + em:maxVersion="24.*"/> diff --git a/teledactyl/content/addressbook.js b/teledactyl/content/addressbook.js index cd9fe12..6171b41 100644 --- a/teledactyl/content/addressbook.js +++ b/teledactyl/content/addressbook.js @@ -152,4 +152,4 @@ var Addressbook = Module("addressbook", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/teledactyl/content/compose/compose.js b/teledactyl/content/compose/compose.js index 33c5f23..fd88333 100644 --- a/teledactyl/content/compose/compose.js +++ b/teledactyl/content/compose/compose.js @@ -80,4 +80,4 @@ var Compose = Module("compose", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/teledactyl/content/config.js b/teledactyl/content/config.js index 0fae1d2..72215c8 100644 --- a/teledactyl/content/config.js +++ b/teledactyl/content/config.js @@ -116,10 +116,7 @@ var Config = Module("config", ConfigBase, { modes.main = modes.MESSAGE; } } - }, - - // to allow Vim to :set ft=mail automatically - tempFile: "teledactyl.eml" + } }, { }, { commands: function initCommands(dactyl, modules, window) { @@ -165,4 +162,4 @@ var Config = Module("config", ConfigBase, { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: diff --git a/teledactyl/content/mail.js b/teledactyl/content/mail.js index cdfe22d..9c4502d 100644 --- a/teledactyl/content/mail.js +++ b/teledactyl/content/mail.js @@ -518,47 +518,47 @@ var Mail = Module("mail", { mappings.add(myModes, ["j", ""], "Select next message", - function (args) { mail.selectMessage(function (msg) true, false, false, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, false, false, count); }, { count: true }); mappings.add(myModes, ["gj"], "Select next message, including closed threads", - function (args) { mail.selectMessage(function (msg) true, false, true, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, true, false, count); }, { count: true }); mappings.add(myModes, ["J", ""], "Select next unread message", - function (args) { mail.selectMessage(function (msg) !msg.isRead, true, true, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) !msg.isRead, true, true, false, count); }, { count: true }); mappings.add(myModes, ["k", ""], "Select previous message", - function (args) { mail.selectMessage(function (msg) true, false, false, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, false, true, count); }, { count: true }); mappings.add(myModes, ["gk"], "Select previous message", - function (args) { mail.selectMessage(function (msg) true, false, true, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, true, true, count); }, { count: true }); mappings.add(myModes, ["K"], "Select previous unread message", - function (args) { mail.selectMessage(function (msg) !msg.isRead, true, true, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) !msg.isRead, true, true, true, count); }, { count: true }); mappings.add(myModes, ["*"], "Select next message from the same sender", - function (args) { + function ({ count }) { let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase(); - mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, args.count); + mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, count); }, { count: true }); mappings.add(myModes, ["#"], "Select previous message from the same sender", - function (args) { + function ({ count }) { let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase(); - mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, args.count); + mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, count); }, { count: true }); @@ -593,22 +593,22 @@ var Mail = Module("mail", { // SCROLLING mappings.add(myModes, [""], "Scroll message down", - function (args) { buffer.scrollLines(Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollLines(Math.max(count, 1)); }, { count: true }); mappings.add(myModes, [""], "Scroll message up", - function (args) { buffer.scrollLines(-Math.max(args.count, 1)); }, + function ({ count }) { buffer.scrollLines(-Math.max(count, 1)); }, { count: true }); mappings.add([modes.MESSAGE], [""], "Select previous message", - function (args) { mail.selectMessage(function (msg) true, false, false, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, false, true, count); }, { count: true }); mappings.add([modes.MESSAGE], [""], "Select next message", - function (args) { mail.selectMessage(function (msg) true, false, false, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) true, false, false, false, count); }, { count: true }); // UNDO/REDO @@ -657,29 +657,29 @@ var Mail = Module("mail", { mappings.add(myModes, ["]s"], "Select next starred message", - function (args) { mail.selectMessage(function (msg) msg.isFlagged, true, true, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) msg.isFlagged, true, true, false, count); }, { count: true }); mappings.add(myModes, ["[s"], "Select previous starred message", - function (args) { mail.selectMessage(function (msg) msg.isFlagged, true, true, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) msg.isFlagged, true, true, true, count); }, { count: true }); mappings.add(myModes, ["]a"], "Select next message with an attachment", - function (args) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, false, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, false, count); }, { count: true }); mappings.add(myModes, ["[a"], "Select previous message with an attachment", - function (args) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, true, args.count); }, + function ({ count }) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, true, count); }, { count: true }); // FOLDER SWITCHING mappings.add(myModes, ["gi"], "Go to inbox", - function (args) { - let folder = mail.getFolders("Inbox", false, true)[(args.count > 0) ? (args.count - 1) : 0]; + function ({ count }) { + let folder = mail.getFolders("Inbox", false, true)[(count > 0) ? (count - 1) : 0]; if (folder) SelectFolder(folder.URI); else @@ -689,8 +689,8 @@ var Mail = Module("mail", { mappings.add(myModes, [""], "Select next folder", - function (args) { - let newPos = mail._getCurrentFolderIndex() + Math.max(1, args.count); + function ({ count }) { + let newPos = mail._getCurrentFolderIndex() + Math.max(1, count); if (newPos >= gFolderTreeView.rowCount) { newPos = newPos % gFolderTreeView.rowCount; commandline.echo(_("finder.atBottom"), commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES); @@ -701,15 +701,15 @@ var Mail = Module("mail", { mappings.add(myModes, [""], "Go to next mailbox with unread messages", - function (args) { - mail._selectUnreadFolder(false, args.count); + function ({ count }) { + mail._selectUnreadFolder(false, count); }, { count: true }); mappings.add(myModes, [""], "Select previous folder", - function (args) { - let newPos = mail._getCurrentFolderIndex() - Math.max(1, args.count); + function ({ count }) { + let newPos = mail._getCurrentFolderIndex() - Math.max(1, count); if (newPos < 0) { newPos = (newPos % gFolderTreeView.rowCount) + gFolderTreeView.rowCount; commandline.echo(_("finder.atTop"), commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES); @@ -720,8 +720,8 @@ var Mail = Module("mail", { mappings.add(myModes, [""], "Go to previous mailbox with unread messages", - function (args) { - mail._selectUnreadFolder(true, args.count); + function ({ count }) { + mail._selectUnreadFolder(true, count); }, { count: true }); @@ -769,7 +769,7 @@ var Mail = Module("mail", { // tagging messages mappings.add(myModes, ["l"], "Label message", - function (arg) { + function ({ arg }) { if (!GetSelectedMessages()) return void dactyl.beep(); @@ -930,4 +930,4 @@ var Mail = Module("mail", { } }); -// vim: set fdm=marker sw=4 ts=4 et: +// vim: set fdm=marker sw=4 sts=4 ts=8 et: