diff options
Diffstat (limited to 'common/content')
-rw-r--r-- | common/content/abbreviations.js | 22 | ||||
-rw-r--r-- | common/content/autocommands.js | 20 | ||||
-rw-r--r-- | common/content/bookmarks.js | 20 | ||||
-rw-r--r-- | common/content/browser.js | 2 | ||||
-rw-r--r-- | common/content/commandline.js | 54 | ||||
-rw-r--r-- | common/content/dactyl.js | 105 | ||||
-rw-r--r-- | common/content/editor.js | 18 | ||||
-rw-r--r-- | common/content/events.js | 18 | ||||
-rw-r--r-- | common/content/hints.js | 62 | ||||
-rw-r--r-- | common/content/history.js | 12 | ||||
-rw-r--r-- | common/content/key-processors.js | 14 | ||||
-rw-r--r-- | common/content/mappings.js | 58 | ||||
-rw-r--r-- | common/content/marks.js | 12 | ||||
-rw-r--r-- | common/content/modes.js | 32 | ||||
-rw-r--r-- | common/content/mow.js | 20 | ||||
-rw-r--r-- | common/content/quickmarks.js | 8 | ||||
-rw-r--r-- | common/content/statusline.js | 2 | ||||
-rw-r--r-- | common/content/tabs.js | 24 |
18 files changed, 251 insertions, 252 deletions
diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js index 4013be29..2d97f7f0 100644 --- a/common/content/abbreviations.js +++ b/common/content/abbreviations.js @@ -64,7 +64,7 @@ var Abbreviation = Class("Abbreviation", { * @param {Mode} mode The mode to test. * @returns {boolean} The result of the comparison. */ - inMode: function (mode) this.modes.some(function (_mode) _mode == mode), + inMode: function (mode) this.modes.some(m => m == mode), /** * Returns true if this abbreviation is defined in any of *modes*. @@ -72,7 +72,7 @@ var Abbreviation = Class("Abbreviation", { * @param {[Modes]} modes The modes to test. * @returns {boolean} The result of the comparison. */ - inModes: function (modes) modes.some(function (mode) this.inMode(mode), this), + inModes: function (modes) modes.some(mode => this.inMode(mode)), /** * Remove *mode* from the list of supported modes for this abbreviation. @@ -80,7 +80,7 @@ var Abbreviation = Class("Abbreviation", { * @param {Mode} mode The mode to remove. */ removeMode: function (mode) { - this.modes = this.modes.filter(function (m) m != mode).sort(); + this.modes = this.modes.filter(m => m != mode).sort(); }, /** @@ -90,7 +90,7 @@ var Abbreviation = Class("Abbreviation", { get modeChar() Abbreviation.modeChar(this.modes) }, { modeChar: function (_modes) { - let result = array.uniq(_modes.map(function (m) m.char)).join(""); + let result = array.uniq(_modes.map(m => m.char)).join(""); if (result == "ci") result = "!"; return result; @@ -142,7 +142,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, { // Wth? --Kris; let map = values(this._store).map(Iterator).map(iter.toArray) .flatten().toObject(); - return Object.keys(map).sort().map(function (k) map[k]); + return Object.keys(map).sort().map(k => map[k]); }, /** @@ -244,7 +244,7 @@ var Abbreviations = Module("abbreviations", { match: function (mode, text) { let match = this._match.exec(text); if (match) - return this.hives.map(function (h) h.get(mode, match[2] || match[4] || match[6])).nth(util.identity, 0); + return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6])).nth(util.identity, 0); return null; }, @@ -257,10 +257,10 @@ var Abbreviations = Module("abbreviations", { * @optional */ list: function (modes, lhs, hives) { - let hives = hives || contexts.allGroups.abbrevs.filter(function (h) !h.empty); + let hives = hives || contexts.allGroups.abbrevs.filter(h => !h.empty); function abbrevs(hive) - hive.merged.filter(function (abbr) (abbr.inModes(modes) && abbr.lhs.indexOf(lhs) == 0)); + hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.indexOf(lhs) == 0)); let list = ["table", {}, ["tr", { highlight: "Title" }, @@ -269,9 +269,9 @@ var Abbreviations = Module("abbreviations", { ["td", { style: "padding-right: 1em;" }, _("title.Abbrev")], ["td", { style: "padding-right: 1em;" }, _("title.Replacement")]], ["col", { style: "min-width: 6em; padding-right: 1em;" }], - hives.map(function (hive) let (i = 0) [ + hives.map(hive => let (i = 0) [ ["tr", { style: "height: .5ex;" }], - abbrevs(hive).map(function (abbrev) + abbrevs(hive).map(abbrev => ["tr", {}, ["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""], ["td", {}, abbrev.modeChar], @@ -298,7 +298,7 @@ var Abbreviations = Module("abbreviations", { completion: function initCompletion() { completion.abbreviation = function abbreviation(context, modes, group) { group = group || abbreviations.user; - let fn = modes ? function (abbr) abbr.inModes(modes) : util.identity; + let fn = modes ? ab => ab.inModes(modes) : util.identity; context.keys = { text: "lhs" , description: "rhs" }; context.completions = group.merged.filter(fn); }; diff --git a/common/content/autocommands.js b/common/content/autocommands.js index eaaa1c78..889f063f 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -51,7 +51,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, { */ get: function (event, filter) { filter = filter && String(Group.compileFilter(filter)); - return this._store.filter(function (autoCmd) autoCmd.match(event, filter)); + return this._store.filter(cmd => cmd.match(event, filter)); }, /** @@ -62,7 +62,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, { */ remove: function (event, filter) { filter = filter && String(Group.compileFilter(filter)); - this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, filter)); + this._store = this._store.filter(cmd => !cmd.match(event, filter)); }, }); @@ -73,7 +73,7 @@ var AutoCommands = Module("autocommands", { init: function () { }, - get activeHives() contexts.allGroups.autocmd.filter(function (h) h._store.length), + get activeHives() contexts.allGroups.autocmd.filter(h => h._store.length), add: deprecated("group.autocmd.add", { get: function add() autocommands.user.closure.add }), get: deprecated("group.autocmd.get", { get: function get() autocommands.user.closure.get }), @@ -107,15 +107,15 @@ var AutoCommands = Module("autocommands", { ["table", {}, ["tr", { highlight: "Title" }, ["td", { colspan: "3" }, "----- Auto Commands -----"]], - hives.map(function (hive) [ + hives.map(hive => [ ["tr", {}, ["td", { colspan: "3" }, ["span", { highlight: "Title" }, hive.name], " ", hive.filter.toJSONXML(modules)]], ["tr", { style: "height: .5ex;" }], - iter(cmds(hive)).map(function ([event, items]) [ + iter(cmds(hive)).map(([event, items]) => [ ["tr", { style: "height: .5ex;" }], - items.map(function (item, i) + items.map((item, i) => ["tr", {}, ["td", { highlight: "Title", style: "padding-left: 1em; padding-right: 1em;" }, i == 0 ? event : ""], @@ -186,14 +186,14 @@ var AutoCommands = Module("autocommands", { validEvents.push("*"); events = Option.parse.stringlist(event); - dactyl.assert(events.every(function (event) validEvents.indexOf(event.toLowerCase()) >= 0), + dactyl.assert(events.every(e => validEvents.indexOf(e.toLowerCase()) >= 0), _("autocmd.noGroup", event)); } if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern if (args.bang) args["-group"].remove(event, filter); - cmd = contexts.bindMacro(args, "-ex", function (params) params); + cmd = contexts.bindMacro(args, "-ex", params => params); args["-group"].add(events, filter, cmd); } else { @@ -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.filter(uri)), + dactyl.assert(autocommands.get(event).some(c => c.filter(uri)), _("autocmd.noMatching")); if (this.name == "doautoall" && dactyl.has("tabs")) { @@ -283,7 +283,7 @@ var AutoCommands = Module("autocommands", { }; }, javascript: function initJavascript() { - JavaScript.setCompleter(AutoCmdHive.prototype.get, [function () Iterator(config.autocommands)]); + JavaScript.setCompleter(AutoCmdHive.prototype.get, [() => Iterator(config.autocommands)]); }, options: function initOptions() { options.add(["eventignore", "ei"], diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index d92c6247..f7fab5bd 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -349,8 +349,8 @@ var Bookmarks = Module("bookmarks", { else encodedParam = bookmarkcache.keywords[keyword.toLowerCase()].encodeURIComponent(param); - url = url.replace(/%s/g, function () encodedParam) - .replace(/%S/g, function () param); + url = url.replace(/%s/g, () => encodedParam) + .replace(/%S/g, () => param); if (/%s/i.test(data)) postData = window.getPostDataStream(data, param, encodedParam, "application/x-www-form-urlencoded"); } @@ -388,7 +388,7 @@ var Bookmarks = Module("bookmarks", { let items = completion.runCompleter("bookmark", filter, maxItems, tags, extra); if (items.length) - return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB); + return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB); if (filter.length > 0 && tags.length > 0) dactyl.echoerr(_("bookmark.noMatching", tags.map(String.quote), filter.quote())); @@ -408,7 +408,7 @@ var Bookmarks = Module("bookmarks", { names: ["-tags", "-T"], description: "A comma-separated list of tags", completer: function tags(context, args) { - context.generate = function () array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array; + context.generate = () => array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array; context.keys = { text: util.identity, description: util.identity }; }, type: CommandOption.LIST @@ -547,7 +547,7 @@ var Bookmarks = Module("bookmarks", { let context = CompletionContext(args.join(" ")); context.fork("bookmark", 0, completion, "bookmark", args["-tags"], { keyword: args["-keyword"], title: args["-title"] }); - deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id)); + deletedCount = bookmarks.remove(context.allItems.items.map(item => item.item.id)); } dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) }); @@ -574,7 +574,7 @@ var Bookmarks = Module("bookmarks", { let options = {}; let url = buffer.uri.spec; - let bmarks = bookmarks.get(url).filter(function (bmark) bmark.url == url); + let bmarks = bookmarks.get(url).filter(bmark => bmark.url == url); if (bmarks.length == 1) { let bmark = bmarks[0]; @@ -630,7 +630,7 @@ var Bookmarks = Module("bookmarks", { if (v != null) context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k])); }); - context.generate = function () values(bookmarkcache.bookmarks); + context.generate = () => values(bookmarkcache.bookmarks); completion.urls(context, tags); }; @@ -680,7 +680,7 @@ var Bookmarks = Module("bookmarks", { context.keys = { text: "keyword", description: "title", icon: "icon" }; context.completions = values(bookmarks.searchEngines); if (suggest) - context.filters.push(function ({ item }) item.supportsResponseType("application/x-suggestions+json")); + context.filters.push(({ item }) => item.supportsResponseType("application/x-suggestions+json")); }; @@ -712,13 +712,13 @@ var Bookmarks = Module("bookmarks", { return; let words = ctxt.filter.toLowerCase().split(/\s+/g); - ctxt.completions = ctxt.completions.filter(function (i) words.every(function (w) i.toLowerCase().indexOf(w) >= 0)); + ctxt.completions = ctxt.completions.filter(i => words.every(w => i.toLowerCase().indexOf(w) >= 0)); ctxt.hasItems = ctxt.completions.length; ctxt.incomplete = true; ctxt.cache.request = bookmarks.getSuggestions(name, ctxt.filter, function (compl) { ctxt.incomplete = false; - ctxt.completions = array.uniq(ctxt.completions.filter(function (c) compl.indexOf(c) >= 0) + ctxt.completions = array.uniq(ctxt.completions.filter(c => compl.indexOf(c) >= 0) .concat(compl), true); }); }); diff --git a/common/content/browser.js b/common/content/browser.js index 79d98d2d..b1d7e02b 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -194,7 +194,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { completer: function (context) completion.url(context), domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map( - function (url) util.getHost(url))), + url => util.getHost(url))), literal: 0, privateData: true }); diff --git a/common/content/commandline.js b/common/content/commandline.js index 9ea1fc33..8269208c 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -199,7 +199,7 @@ var CommandWidgets = Class("CommandWidgets", { highlight.highlightNode(elem, (val[0] != null ? val[0] : obj.defaultGroup) .split(/\s/).filter(util.identity) - .map(function (g) g + " " + nodeSet.group + g) + .map(g => g + " " + nodeSet.group + g) .join(" ")); elem.value = val[1]; if (obj.onChange) @@ -217,7 +217,7 @@ var CommandWidgets = Class("CommandWidgets", { let elem = nodeSet[obj.name]; if (elem) highlight.highlightNode(elem, obj.defaultGroup.split(/\s/) - .map(function (g) g + " " + nodeSet.group + g).join(" ")); + .map(g => g + " " + nodeSet.group + g).join(" ")); }); } }, @@ -253,7 +253,7 @@ var CommandWidgets = Class("CommandWidgets", { // choose which element to select. function check(node) { if (DOM(node).style.display === "-moz-stack") { - let nodes = Array.filter(node.children, function (n) !n.collapsed && n.boxObject.height); + let nodes = Array.filter(node.children, n => !n.collapsed && n.boxObject.height); nodes.forEach(function (node, i) { node.style.opacity = (i == nodes.length - 1) ? "" : "0" }); } Array.forEach(node.children, check); @@ -313,9 +313,9 @@ var CommandWidgets = Class("CommandWidgets", { highlight.highlightNode(elem.contentDocument.body, "MOW"); }), true), - multilineInput: Class.Memoize(function () document.getElementById("dactyl-multiline-input")), + multilineInput: Class.Memoize(() => document.getElementById("dactyl-multiline-input")), - mowContainer: Class.Memoize(function () document.getElementById("dactyl-multiline-output-container")) + mowContainer: Class.Memoize(() => document.getElementById("dactyl-multiline-output-container")) }, { getEditor: function getEditor(elem) { elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement); @@ -612,7 +612,7 @@ var CommandLine = Module("commandline", { }, this); }, - widgets: Class.Memoize(function () CommandWidgets()), + widgets: Class.Memoize(() => CommandWidgets()), runSilently: function runSilently(func, self) { this.withSavedValues(["silent"], function () { @@ -871,7 +871,7 @@ var CommandLine = Module("commandline", { readHeredoc: function readHeredoc(end) { let args; commandline.inputMultiline(end, function (res) { args = res; }); - util.waitFor(function () args !== undefined); + util.waitFor(() => args !== undefined); return args; }, @@ -916,7 +916,7 @@ var CommandLine = Module("commandline", { events: update( iter(CommandMode.prototype.events).map( - function ([event, handler]) [ + ([event, handler]) => [ event, function (event) { if (this.commandMode) handler.call(this.commandSession, event); @@ -967,7 +967,7 @@ var CommandLine = Module("commandline", { this.savingOutput = true; dactyl.trapErrors.apply(dactyl, [fn, self].concat(args)); this.savingOutput = false; - return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem) + return output.map(elem => elem instanceof Node ? DOM.stringify(elem) : elem) .join("\n"); } }, { @@ -1008,7 +1008,7 @@ var CommandLine = Module("commandline", { if (privateData == "never-save") return; - this.store = this.store.filter(function (line) (line.value || line) != str); + this.store = this.store.filter(line => (line.value || line) != str); dactyl.trapErrors(function () { this.store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData }); }, this); @@ -1162,7 +1162,7 @@ var CommandLine = Module("commandline", { }, get activeContexts() this.context.contextList - .filter(function (c) c.items.length || c.incomplete), + .filter(c => c.items.length || c.incomplete), /** * Returns the current completion string relative to the @@ -1693,7 +1693,7 @@ var CommandLine = Module("commandline", { } else if (commandline._messageHistory.length > 1) { commandline.commandOutput( - template.map(commandline._messageHistory.messages, function (message) + template.map(commandline._messageHistory.messages, message => ["div", { highlight: message.highlight + " Message" }, message.message])); } @@ -1708,7 +1708,7 @@ var CommandLine = Module("commandline", { commands.add(["sil[ent]"], "Run a command silently", function (args) { - commandline.runSilently(function () commands.execute(args[0] || "", null, true)); + commandline.runSilently(() => commands.execute(args[0] || "", null, true)); }, { completer: function (context) completion.ex(context), literal: 0, @@ -1759,7 +1759,7 @@ var CommandLine = Module("commandline", { text = text.substring(1, index); modes.pop(); - return function () self.callback.call(commandline, text); + return () => self.callback.call(commandline, text); } return Events.PASS; }); @@ -1893,10 +1893,10 @@ var CommandLine = Module("commandline", { let store = commandline._store; for (let [k, v] in store) { if (k == "command") - store.set(k, v.filter(function (item) + store.set(k, v.filter(item => !(timespan.contains(item.timestamp) && (!host || commands.hasDomain(item.value, host))))); else if (!host) - store.set(k, v.filter(function (item) !timespan.contains(item.timestamp))); + store.set(k, v.filter(item => !timespan.contains(item.timestamp))); } } }); @@ -1904,20 +1904,20 @@ var CommandLine = Module("commandline", { sanitizer.addItem("history", { action: function (timespan, host) { commandline._store.set("command", - commandline._store.get("command", []).filter(function (item) + commandline._store.get("command", []).filter(item => !(timespan.contains(item.timestamp) && (host ? commands.hasDomain(item.value, host) : item.privateData)))); - commandline._messageHistory.filter(function (item) !timespan.contains(item.timestamp * 1000) || + commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) || !item.domains && !item.privateData || - host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host)))); + host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host)))); } }); sanitizer.addItem("messages", { description: "Saved :messages", action: function (timespan, host) { - commandline._messageHistory.filter(function (item) !timespan.contains(item.timestamp * 1000) || - host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host)))); + commandline._messageHistory.filter(item => !timespan.contains(item.timestamp * 1000) || + host && (!item.domains || !item.domains.some(d => util.isSubdomain(d, host)))); } }); } @@ -1965,18 +1965,18 @@ var ItemList = Class("ItemList", { ["div", { key: "completions" }]], ["div", { highlight: "Completions" }, - template.map(util.range(0, options["maxitems"] * 2), function (i) + template.map(util.range(0, options["maxitems"] * 2), i => ["div", { highlight: "CompItem NonText" }, "~"])]], get itemCount() this.context.contextList - .reduce(function (acc, ctxt) acc + ctxt.items.length, 0), + .reduce((acc, ctxt) => acc + ctxt.items.length, 0), get visible() !this.container.collapsed, set visible(val) this.container.collapsed = !val, get activeGroups() this.context.contextList - .filter(function (c) c.items.length || c.message || c.incomplete) + .filter(c => c.items.length || c.message || c.incomplete) .map(this.getGroup, this), get selected() let (g = this.selectedGroup) g && g.selectedIdx != null @@ -2026,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, g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0); return [group.context, start - group.offsets.start]; }, @@ -2144,8 +2144,8 @@ var ItemList = Class("ItemList", { // We need to collect all of the rescrolling functions in // one go, as the height calculation that they need to do // would force a reflow after each DOM modification. - this.activeGroups.filter(function (g) !g.collapsed) - .map(function (g) g.rescrollFunc) + this.activeGroups.filter(g => !g.collapsed) + .map(g => g.rescrollFunc) .forEach(call); if (!this.selected) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 64aa9135..34ecfc31 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -211,7 +211,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { unregisterObserver: function unregisterObserver(type, callback) { if (type in this._observers) - this._observers[type] = this._observers[type].filter(function (c) c.get() != callback); + this._observers[type] = this._observers[type].filter(c => c.get() != callback); }, applyTriggerObserver: function triggerObserver(type, args) { @@ -245,12 +245,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { let name = commands.add(params.name, params.description, function (args) { let results = array(params.iterate(args)) - .sort(function (a, b) String.localeCompare(a.name, b.name)); + .sort((a, b) => String.localeCompare(a.name, b.name)); - let filters = args.map(function (arg) let (re = util.regexp.escape(arg)) + let filters = args.map(arg => let (re = util.regexp.escape(arg)) util.regexp("\\b" + re + "\\b|(?:^|[()\\s])" + re + "(?:$|[()\\s])", "i")); if (filters.length) - results = results.filter(function (item) filters.every(function (re) keys(item).some(re.closure.test))); + results = results.filter(item => filters.every(re => keys(item).some(re.closure.test))); commandline.commandOutput( template.usage(results, params.format)); @@ -276,7 +276,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (params.index) this.indices[params.index] = function () { let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs())) - .array.sort(function (a, b) String.localeCompare(a.name, b.name)); + .array.sort((a, b) => String.localeCompare(a.name, b.name)); let haveTag = Set.has(help.tags); for (let obj in values(results)) { @@ -667,22 +667,22 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { let args = null; if (obj instanceof Command) { - link = function (cmd) ["ex", {}, cmd]; + link = cmd => ["ex", {}, cmd]; args = obj.parseArgs("", CompletionContext(str || "")); - tag = function (cmd) DOM.DOMString(":" + cmd); - spec = function (cmd) [ + tag = cmd => DOM.DOMString(":" + cmd); + spec = cmd => [ obj.count ? ["oa", {}, "count"] : [], cmd, obj.bang ? ["oa", {}, "!"] : [] ]; } else if (obj instanceof Map) { - spec = function (map) obj.count ? [["oa", {}, "count"], map] : DOM.DOMString(map); - tag = function (map) [ + spec = map => obj.count ? [["oa", {}, "count"], map] : DOM.DOMString(map); + tag = map => [ let (c = obj.modes[0].char) c ? c + "_" : "", map ]; - link = function (map) { + link = map => { let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map); let k = ["k", {}, extra]; if (name) @@ -693,9 +693,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }; } else if (obj instanceof Option) { - spec = function () template.map(obj.names, tag, " "); - tag = function (name) DOM.DOMString("'" + name + "'"); - link = function (opt, name) ["o", {}, name]; + spec = () => template.map(obj.names, tag, " "); + tag = name => DOM.DOMString("'" + name + "'"); + link = (opt, name) => ["o", {}, name]; args = { value: "", values: [] }; } @@ -736,16 +736,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (obj.completer && false) add(completion._runCompleter(obj.closure.completer, "", null, args).items - .map(function (i) [i.text, i.description])); + .map(i => [i.text, i.description])); - if (obj.options && obj.options.some(function (o) o.description) && false) - add(obj.options.filter(function (o) o.description) - .map(function (o) [ + if (obj.options && obj.options.some(o => o.description) && false) + add(obj.options.filter(o => o.description) + .map(o => [ o.names[0], [o.description, o.names.length == 1 ? "" : ["", " (short name: ", - template.map(o.names.slice(1), function (n) ["em", {}, n], ", "), + template.map(o.names.slice(1), n => ["em", {}, n], ", "), ")"]] ])); @@ -960,7 +960,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { options.push("private"); let win = window.openDialog(document.documentURI, "_blank", options.join(",")); - util.waitFor(function () win.document.readyState === "complete"); + util.waitFor(() => win.document.readyState === "complete"); browser = win.dactyl && win.dactyl.modules.config.tabbrowser || win.getBrowser(); // FALLTHROUGH case dactyl.CURRENT_TAB: @@ -1037,7 +1037,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, this); }, stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"), - urlish: Class.Memoize(function () util.regexp(literal(/* + urlish: Class.Memoize(() => util.regexp(literal(/* ^ ( <domain>+ (:\d+)? (/ .*) | <domain>+ (:\d+) | @@ -1187,11 +1187,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { wrapCallback: function wrapCallback(callback, self) { self = self || this; let save = ["forceOpen"]; - let saved = save.map(function (p) dactyl[p]); + let saved = save.map(p => dactyl[p]); return function wrappedCallback() { let args = arguments; return dactyl.withSavedValues(save, function () { - saved.forEach(function (p, i) dactyl[save[i]] = p); + saved.forEach((p, i) => dactyl[save[i]] = p); try { return callback.apply(self, args); } @@ -1220,15 +1220,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { try { let info = contexts.getDocs(context); if (DOM.isJSONXML(info)) { - let langs = info.slice(2).filter(function (e) isArray(e) && isObject(e[1]) && e[1].lang); + let langs = info.slice(2).filter(e => isArray(e) && isObject(e[1]) && e[1].lang); if (langs) { let lang = config.bestLocale(l[1].lang for each (l in langs)); info = info.slice(0, 2).concat( - info.slice(2).filter(function (e) !isArray(e) || !isObject(e[1]) - || e[1].lang == lang)); + info.slice(2).filter(e => !isArray(e) || !isObject(e[1]) + || e[1].lang == lang)); - for each (let elem in info.slice(2).filter(function (e) isArray(e) && e[0] == "info" && isObject(e[1]))) + for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1]))) for (let attr in values(["name", "summary", "href"])) if (attr in elem[1]) info[attr] = elem[1][attr]; @@ -1256,7 +1256,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { cache.register("help/index.xml", function () { return '<?xml version="1.0"?>\n' + DOM.toXML(["overlay", { xmlns: "dactyl" }, - template.map(dactyl.indices, function ([name, iter]) + template.map(dactyl.indices, ([name, iter]) => ["dl", { insertafter: name + "-index" }, template.map(iter(), util.identity)], "\n\n")]); @@ -1266,7 +1266,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { return '<?xml version="1.0"?>\n' + DOM.toXML(["overlay", { xmlns: "dactyl" }, ["dl", { insertafter: "dialog-list" }, - template.map(config.dialogs, function ([name, val]) + template.map(config.dialogs, ([name, val]) => (!val[2] || val[2]()) ? [["dt", {}, name], ["dd", {}, val[0]]] @@ -1279,9 +1279,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { DOM.toXML(["overlay", { xmlns: "dactyl" }, ["dl", { insertafter: "sanitize-items" }, template.map(options.get("sanitizeitems").values - .sort(function (a, b) String.localeCompare(a.name, - b.name)), - function ({ name, description }) + .sort((a, b) => String.localeCompare(a.name, + b.name)), + ({ name, description }) => [["dt", {}, name], ["dd", {}, template.linkifyHelp(description, true)]], "\n")]]); @@ -1325,7 +1325,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, config.guioptions), setter: function (opts) { for (let [opt, [, ids]] in Iterator(this.opts)) { - ids.map(function (id) document.getElementById(id)) + ids.map(id => document.getElementById(id)) .forEach(function (elem) { if (elem) dactyl.setNodeVisible(elem, opts.indexOf(opt) >= 0); @@ -1341,10 +1341,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, setter: function (opts) { let dir = ["horizontal", "vertical"].filter( - function (dir) !Array.some(opts, - function (o) this.opts[o] && this.opts[o][1] == dir, this), - this); - let class_ = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]"); + dir => !Array.some(opts, + o => this.opts[o] && this.opts[o][1] == dir) + ); + let class_ = dir.map(dir => "html|html > xul|scrollbar[orient=" + dir + "]"); styles.system.add("scrollbar", "*", class_.length ? class_.join(", ") + " { visibility: collapse !important; }" : "", @@ -1369,7 +1369,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { classes.length ? classes.join(",") + "{ display: none; }" : ""); if (!dactyl.has("Gecko2")) { - tabs.tabBinding.enabled = Array.some(opts, function (k) k in this.opts, this); + tabs.tabBinding.enabled = Array.some(opts, k => k in this.opts); tabs.updateTabCount(); } if (config.tabbrowser.tabContainer._positionPinnedTabs) @@ -1380,7 +1380,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { Option.validIf(!/[nN]/.test(opts), "Tab numbering not available in this " + config.host + " version") */ } - ].filter(function (group) !group.feature || dactyl.has(group.feature)); + ].filter(group => !group.feature || dactyl.has(group.feature)); options.add(["guioptions", "go"], "Show or hide certain GUI elements like the menu or toolbar", @@ -1391,7 +1391,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { "rb" + [k for ([k, v] in iter(groups[1].opts)) if (!Dactyl.toolbarHidden(document.getElementById(v[1][0])))].join(""), - values: array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(), + values: array(groups).map(g => [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(), setter: function (value) { for (let group in values(groups)) @@ -1400,7 +1400,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { return value; }, validator: function (val) Option.validateCompleter.call(this, val) && - groups.every(function (g) !g.validator || g.validator(val)) + groups.every(g => !g.validator || g.validator(val)) }); options.add(["loadplugins", "lpl"], @@ -1504,7 +1504,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { let arg = args[0] || ""; let items = dactyl.getMenuItems(arg); - dactyl.assert(items.some(function (i) i.dactylPath == arg), + dactyl.assert(items.some(i => i.dactylPath == arg), _("emenu.notFound", arg)); for (let [, item] in Iterator(items)) { @@ -1684,13 +1684,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }; toolbarCommand(["toolbars[how]", "tbs[how]"], "Show the named toolbar", - function (toolbar) dactyl.setNodeVisible(toolbar, true), - function ({ item }) Dactyl.toolbarHidden(item)); + toolbar => dactyl.setNodeVisible(toolbar, true), + ({ item }) => Dactyl.toolbarHidden(item)); toolbarCommand(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar", - function (toolbar) dactyl.setNodeVisible(toolbar, false), - function ({ item }) !Dactyl.toolbarHidden(item)); + toolbar => dactyl.setNodeVisible(toolbar, false), + ({ item }) => !Dactyl.toolbarHidden(item)); toolbarCommand(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar", - function (toolbar) dactyl.setNodeVisible(toolbar, Dactyl.toolbarHidden(toolbar))); + toolbar => dactyl.setNodeVisible(toolbar, Dactyl.toolbarHidden(toolbar))); } commands.add(["time"], @@ -1701,7 +1701,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { args = args[0] || ""; if (args[0] == ":") - var func = function () commands.execute(args, null, false); + var func = () => commands.execute(args, null, false); else func = dactyl.userFunc(args); @@ -1836,7 +1836,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { completion: function initCompletion() { completion.dialog = function dialog(context) { context.title = ["Dialog"]; - context.filters.push(function ({ item }) !item[2] || item[2]()); + context.filters.push(({ item }) => !item[2] || item[2]()); context.completions = [[k, v[0], v[2]] for ([k, v] in Iterator(config.dialogs))]; }; @@ -1848,7 +1848,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { description: function (item) item.getAttribute("label"), highlight: function (item) item.disabled ? "Disabled" : "" }; - context.generate = function () dactyl.menuItems; + context.generate = () => dactyl.menuItems; }; var toolbox = document.getElementById("navigator-toolbox"); @@ -1880,9 +1880,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { && root._lightweightTheme._lastScreenWidth == null) { dactyl.withSavedValues.call(PrivateBrowsingUtils, - ["isWindowPrivate"], function () { - PrivateBrowsingUtils.isWindowPrivate = function () false; - + ["isWindowPrivate"], function () { + PrivateBrowsingUtils.isWindowPrivate = () => false; Cu.import("resource://gre/modules/LightweightThemeConsumer.jsm", {}) .LightweightThemeConsumer.call(root._lightweightTheme, document); }); diff --git a/common/content/editor.js b/common/content/editor.js index 01a25ebd..8a36df01 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -381,7 +381,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { textBox = null; let line, column; - let keepFocus = modes.stack.some(function (m) isinstance(m.main, modes.COMMAND_LINE)); + let keepFocus = modes.stack.some(m => isinstance(m.main, modes.COMMAND_LINE)); if (!forceEditing && textBox && textBox.type == "password") { commandline.input(_("editor.prompt.editPassword") + " ", @@ -400,7 +400,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { var editor_ = window.GetCurrentEditor ? GetCurrentEditor() : Editor.getEditor(document.commandDispatcher.focusedWindow); dactyl.assert(editor_); - text = Array.map(editor_.rootElement.childNodes, function (e) DOM.stringify(e, true)).join(""); + text = Array.map(editor_.rootElement.childNodes, e => DOM.stringify(e, true)).join(""); if (!editor_.selection.rangeCount) var sel = ""; @@ -1131,7 +1131,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { "<*-Home>", "<*-End>", "<*-PageUp>", "<*-PageDown>", "<M-c>", "<M-v>", "<*-Tab>"], "Handled by " + config.host, - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); mappings.add([modes.INSERT], ["<Space>", "<Return>"], "Expand Insert mode abbreviation", @@ -1327,19 +1327,19 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args)); bind(["<Esc>"], "Return to Insert mode", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind(["<C-[>"], "Return to Insert mode", function () { events.feedkeys("<Esc>", { skipmap: true }); }); bind(["<Up>"], "Select the previous autocomplete result", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind(["<C-p>"], "Select the previous autocomplete result", function () { events.feedkeys("<Up>", { skipmap: true }); }); bind(["<Down>"], "Select the next autocomplete result", - function () Events.PASS_THROUGH); + () => Events.PASS_THROUGH); bind(["<C-n>"], "Select the next autocomplete result", function () { events.feedkeys("<Down>", { skipmap: true }); }); @@ -1350,8 +1350,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { "string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', { format: function (obj, value) { let args = commands.parseArgs(value || this.value, { argCount: "*", allowUnknownOptions: true }) - .map(util.compileMacro).filter(function (fmt) fmt.valid(obj)) - .map(function (fmt) fmt(obj)); + .map(util.compileMacro).filter(fmt => fmt.valid(obj)) + .map(fmt => fmt(obj)); if (obj["file"] && !this.has("file")) args.push(obj["file"]); return args; @@ -1359,7 +1359,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { has: function (key) Set.has(util.compileMacro(this.value).seen, key), validator: function (value) { this.format({}, value); - return Object.keys(util.compileMacro(value).seen).every(function (k) ["column", "file", "line"].indexOf(k) >= 0); + return Object.keys(util.compileMacro(value).seen).every(k => ["column", "file", "line"].indexOf(k) >= 0); } }); diff --git a/common/content/events.js b/common/content/events.js index ffa279bb..e588894f 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -140,7 +140,7 @@ var Events = Module("events", { this.active.push(elem); } - this.active = this.active.filter(function (e) e.popupBoxObject && e.popupBoxObject.popupState != "closed"); + this.active = this.active.filter(e => e.popupBoxObject && e.popupBoxObject.popupState != "closed"); if (!this.active.length && !this.activeMenubar) modes.remove(modes.MENU, true); @@ -466,12 +466,12 @@ var Events = Module("events", { let access = iter({ 1: "shiftKey", 2: "ctrlKey", 4: "altKey", 8: "metaKey" }) .filter(function ([k, v]) this & k, prefs.get("ui.key.chromeAccess")) - .map(function ([k, v]) [v, true]) + .map(([k, v]) => [v, true]) .toObject(); outer: for (let [, key] in iter(elements)) - if (filters.some(function ([k, v]) key.getAttribute(k) == v)) { + if (filters.some(([k, v]) => key.getAttribute(k) == v)) { let keys = { ctrlKey: false, altKey: false, shiftKey: false, metaKey: false }; let needed = { ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey, metaKey: event.metaKey }; @@ -482,7 +482,7 @@ var Events = Module("events", { case "accel": keys[accel] = true; break; default: keys[modifier + "Key"] = true; break; case "any": - if (!iter.some(keys, function ([k, v]) v && needed[k])) + if (!iter.some(keys, ([k, v]) => v && needed[k])) continue outer; for (let [k, v] in iter(keys)) { if (v) @@ -492,7 +492,7 @@ var Events = Module("events", { break; } - if (iter(needed).every(function ([k, v]) v == keys[k])) + if (iter(needed).every(([k, v]) => v == keys[k])) return key; } @@ -797,8 +797,8 @@ var Events = Module("events", { && let (key = DOM.Event.stringify(event)) !(modes.main.count && /^\d$/.test(key) || modes.main.allBases.some( - function (mode) mappings.hives.some( - function (hive) hive.get(mode, key) || hive.getCandidates(mode, key)))); + mode => mappings.hives.some( + hive => hive.get(mode, key) || hive.getCandidates(mode, key)))); events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) + " passing: " + this.passing + " " + @@ -870,7 +870,7 @@ var Events = Module("events", { return; } - let haveInput = modes.stack.some(function (m) m.main.input); + let haveInput = modes.stack.some(m => m.main.input); if (DOM(elem || win).isEditable) { if (!haveInput) @@ -1104,7 +1104,7 @@ var Events = Module("events", { const Hive = Class("Hive", { init: function init(values, map) { this.name = "passkeys:" + map; - this.stack = MapHive.Stack(values.map(function (v) Map(v[map + "Keys"]))); + this.stack = MapHive.Stack(values.map(v => Map(v[map + "Keys"]))); function Map(keys) ({ execute: function () Events.PASS_THROUGH, keys: keys diff --git a/common/content/hints.js b/common/content/hints.js index d151c2c3..f510e856 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -281,7 +281,7 @@ var HintSession = Class("HintSession", CommandMode, { let doc = win.document; - memoize(doc, "dactylLabels", function () + memoize(doc, "dactylLabels", () => iter([l.getAttribute("for"), l] for (l in array.iterValues(doc.querySelectorAll("label[for]")))) .toObject()); @@ -300,7 +300,7 @@ var HintSession = Class("HintSession", CommandMode, { return false; if (!rect.width || !rect.height) - if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) + if (!Array.some(elem.childNodes, elem => elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) if (elem.textContent || !elem.name) return false; @@ -473,7 +473,7 @@ var HintSession = Class("HintSession", CommandMode, { if (!followFirst) { let firstHref = this.validHints[0].elem.getAttribute("href") || null; if (firstHref) { - if (this.validHints.some(function (h) h.elem.getAttribute("href") != firstHref)) + if (this.validHints.some(h => h.elem.getAttribute("href") != firstHref)) return; } else if (this.validHints.length > 1) @@ -496,7 +496,7 @@ var HintSession = Class("HintSession", CommandMode, { // Hint document has been unloaded. return; - let hinted = n || this.validHints.some(function (h) h.elem === elem); + let hinted = n || this.validHints.some(h => h.elem === elem); if (!hinted) hints.setClass(elem, null); else if (n) @@ -756,32 +756,32 @@ var Hints = Module("hints", { this.modes = {}; this.addMode(";", "Focus hint", buffer.closure.focusElement); - this.addMode("?", "Show information for hint", function (elem) buffer.showElementInfo(elem)); + this.addMode("?", "Show information for hint", elem => buffer.showElementInfo(elem)); // TODO: allow for ! override to overwrite existing paths -- where? --djk - this.addMode("s", "Save hint", function (elem) buffer.saveLink(elem, false)); - this.addMode("f", "Focus frame", function (elem) dactyl.focus(elem.ownerDocument.defaultView)); + this.addMode("s", "Save hint", elem => buffer.saveLink(elem, false)); + this.addMode("f", "Focus frame", elem => dactyl.focus(elem.ownerDocument.defaultView)); this.addMode("F", "Focus frame or pseudo-frame", buffer.closure.focusElement, isScrollable); - this.addMode("o", "Follow hint", function (elem) buffer.followLink(elem, dactyl.CURRENT_TAB)); - this.addMode("t", "Follow hint in a new tab", function (elem) buffer.followLink(elem, dactyl.NEW_TAB)); - this.addMode("b", "Follow hint in a background tab", function (elem) buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB)); - this.addMode("w", "Follow hint in a new window", function (elem) buffer.followLink(elem, dactyl.NEW_WINDOW)); - this.addMode("O", "Generate an ‘:open URL’ prompt", function (elem, loc) CommandExMode().open("open " + loc)); - this.addMode("T", "Generate a ‘:tabopen URL’ prompt", function (elem, loc) CommandExMode().open("tabopen " + loc)); - this.addMode("W", "Generate a ‘:winopen URL’ prompt", function (elem, loc) CommandExMode().open("winopen " + loc)); - this.addMode("a", "Add a bookmark", function (elem) bookmarks.addSearchKeyword(elem)); - this.addMode("S", "Add a search keyword", function (elem) bookmarks.addSearchKeyword(elem)); - this.addMode("v", "View hint source", function (elem, loc) buffer.viewSource(loc, false)); - this.addMode("V", "View hint source in external editor", function (elem, loc) buffer.viewSource(loc, true)); - this.addMode("y", "Yank hint location", function (elem, loc) editor.setRegister(null, loc, true)); - this.addMode("Y", "Yank hint description", function (elem) editor.setRegister(null, elem.textContent || "", true)); + this.addMode("o", "Follow hint", elem => buffer.followLink(elem, dactyl.CURRENT_TAB)); + this.addMode("t", "Follow hint in a new tab", elem => buffer.followLink(elem, dactyl.NEW_TAB)); + this.addMode("b", "Follow hint in a background tab", elem => buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB)); + this.addMode("w", "Follow hint in a new window", elem => buffer.followLink(elem, dactyl.NEW_WINDOW)); + this.addMode("O", "Generate an ‘:open URL’ prompt", (elem, loc) => CommandExMode().open("open " + loc)); + this.addMode("T", "Generate a ‘:tabopen URL’ prompt", (elem, loc) => CommandExMode().open("tabopen " + loc)); + this.addMode("W", "Generate a ‘:winopen URL’ prompt", (elem, loc) => CommandExMode().open("winopen " + loc)); + this.addMode("a", "Add a bookmark", elem => bookmarks.addSearchKeyword(elem)); + this.addMode("S", "Add a search keyword", elem => bookmarks.addSearchKeyword(elem)); + this.addMode("v", "View hint source", (elem, loc) => buffer.viewSource(loc, false)); + this.addMode("V", "View hint source in external editor", (elem, loc) => buffer.viewSource(loc, true)); + this.addMode("y", "Yank hint location", (elem, loc) => editor.setRegister(null, loc, true)); + this.addMode("Y", "Yank hint description", elem => editor.setRegister(null, elem.textContent || "", true)); this.addMode("A", "Yank hint anchor url", function (elem) { let uri = elem.ownerDocument.documentURIObject.clone(); uri.ref = elem.id || elem.name; dactyl.clipboardWrite(uri.spec, true); }); - this.addMode("c", "Open context menu", function (elem) DOM(elem).contextmenu()); - 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)); + this.addMode("c", "Open context menu", elem => DOM(elem).contextmenu()); + this.addMode("i", "Show image", elem => dactyl.open(elem.src)); + this.addMode("I", "Show image in a new tab", elem => dactyl.open(elem.src, dactyl.NEW_TAB)); function isScrollable(elem) isinstance(elem, [Ci.nsIDOMHTMLFrameElement, Ci.nsIDOMHTMLIFrameElement]) || @@ -812,7 +812,7 @@ var Hints = Module("hints", { let update = eht.isDefault; let value = eht.parse(Option.quote(util.regexp.escape(mode)) + ":" + tags.map(Option.quote))[0]; - eht.defaultValue = eht.defaultValue.filter(function (re) toString(re) != toString(value)) + eht.defaultValue = eht.defaultValue.filter(re => toString(re) != toString(value)) .concat(value); if (update) @@ -915,7 +915,7 @@ var Hints = Module("hints", { let tokens = tokenize(/\s+/, hintString); return function (linkText) { linkText = linkText.toLowerCase(); - return tokens.every(function (token) indexOf(linkText, token) >= 0); + return tokens.every(token => indexOf(linkText, token) >= 0); }; } //}}} @@ -1063,7 +1063,7 @@ var Hints = Module("hints", { commandline.input(["Normal", mode], null, { autocomplete: false, completer: function (context) { - context.compare = function () 0; + context.compare = () => 0; context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))]; }, onCancel: mappings.closure.popCommand, @@ -1073,7 +1073,7 @@ var Hints = Module("hints", { mappings.popCommand(); }, onChange: function (arg) { - if (Object.keys(hints.modes).some(function (m) m != arg && m.indexOf(arg) == 0)) + if (Object.keys(hints.modes).some(m => m != arg && m.indexOf(arg) == 0)) return; this.accepted = true; @@ -1111,7 +1111,7 @@ var Hints = Module("hints", { isVisible: function isVisible(elem, offScreen) { let rect = elem.getBoundingClientRect(); if (!rect.width || !rect.height) - if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) + if (!Array.some(elem.childNodes, elem => elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem))) return false; let win = elem.ownerDocument.defaultView; @@ -1300,7 +1300,7 @@ var Hints = Module("hints", { { keepQuotes: true, getKey: function (val, default_) - let (res = array.nth(this.value, function (re) let (match = re.exec(val)) match && match[0] == val, 0)) + let (res = array.nth(this.value, re => let (match = re.exec(val)) match && match[0] == val, 0)) res ? res.matcher : default_, parse: function parse(val) { let vals = parse.supercall(this, val); @@ -1308,7 +1308,7 @@ var Hints = Module("hints", { value.matcher = DOM.compileMatcher(Option.splitList(value.result)); return vals; }, - testValues: function testValues(vals, validator) vals.every(function (re) Option.splitList(re).every(validator)), + testValues: function testValues(vals, validator) vals.every(re => Option.splitList(re).every(validator)), validator: DOM.validateMatcher }); @@ -1368,7 +1368,7 @@ var Hints = Module("hints", { "transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., é ⇒ e)") }, validator: function (values) Option.validateCompleter.call(this, values) && - 1 === values.reduce(function (acc, v) acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0), 0) + 1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0), 0) }); options.add(["wordseparators", "wsp"], diff --git a/common/content/history.js b/common/content/history.js index f19b1e24..b3d62550 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -65,7 +65,7 @@ var History = Module("history", { let sh = webNav.sessionHistory; let obj = []; - obj.__defineGetter__("index", function () sh.index); + obj.__defineGetter__("index", () => sh.index); obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val); }); obj.__iterator__ = function () array.iterItems(this); @@ -111,7 +111,7 @@ var History = Module("history", { */ search: function search(item, steps) { var ctxt; - var filter = function (item) true; + var filter = item => true; if (item == "domain") var filter = function (item) { let res = item.URI.hostPort != ctxt; @@ -165,7 +165,7 @@ var History = Module("history", { let items = completion.runCompleter("history", filter, maxItems, maxItems, sort); if (items.length) - return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB); + return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB); if (filter.length > 0) dactyl.echoerr(_("history.noMatching", filter.quote())); @@ -284,7 +284,7 @@ var History = Module("history", { "title", "uri", "visitcount" - ].map(function (order) [ + ].map(order => [ ["+" + order.replace(" ", ""), /*L*/"Sort by " + order + " ascending"], ["-" + order.replace(" ", ""), /*L*/"Sort by " + order + " descending"] ])); @@ -324,12 +324,12 @@ var History = Module("history", { completion: function initCompletion() { completion.domain = function (context) { context.anchored = false; - context.compare = function (a, b) String.localeCompare(a.key, b.key); + context.compare = (a, b) => String.localeCompare(a.key, b.key); context.keys = { text: util.identity, description: util.identity, key: function (host) host.split(".").reverse().join(".") }; // FIXME: Schema-specific - context.generate = function () [ + context.generate = () => [ Array.slice(row.rev_host).reverse().join("").slice(1) for (row in iter(services.history.DBConnection .createStatement("SELECT DISTINCT rev_host FROM moz_places WHERE rev_host IS NOT NULL;"))) diff --git a/common/content/key-processors.js b/common/content/key-processors.js index 08cc401a..2a34e668 100644 --- a/common/content/key-processors.js +++ b/common/content/key-processors.js @@ -20,11 +20,11 @@ var ProcessorStack = Class("ProcessorStack", { this.modes = array([mode.params.keyModes, main, mode.main.allBases.slice(1)]).flatten().compact(); if (builtin) - hives = hives.filter(function (h) h.name === "builtin"); + hives = hives.filter(h => h.name === "builtin"); - this.processors = this.modes.map(function (m) hives.map(function (h) KeyProcessor(m, h))) + this.processors = this.modes.map(m => hives.map(h => KeyProcessor(m, h))) .flatten().array; - this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer); + this.ownsBuffer = !this.processors.some(p => p.main.ownsBuffer); for (let [i, input] in Iterator(this.processors)) { let params = input.main.params; @@ -134,17 +134,17 @@ var ProcessorStack = Class("ProcessorStack", { events.passing = true; if (result === Events.PASS_THROUGH && this.keyEvents.length) - events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(function (e) [e.type, DOM.Event.stringify(e)]).join("\n\t")); + events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(e => [e.type, DOM.Event.stringify(e)]).join("\n\t")); if (result === Events.PASS_THROUGH) events.feedevents(null, this.keyEvents, { skipmap: true, isMacro: true, isReplay: true }); else { - let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented); + let list = this.events.filter(e => e.getPreventDefault() && !e.dactylDefaultPrevented); if (result === Events.PASS) - events.dbg("PASS THROUGH: " + list.slice(0, length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify)); + events.dbg("PASS THROUGH: " + list.slice(0, length).filter(e => e.type === "keypress").map(DOM.Event.closure.stringify)); if (list.length > length) - events.dbg("REFEED: " + list.slice(length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify)); + events.dbg("REFEED: " + list.slice(length).filter(e => e.type === "keypress").map(DOM.Event.closure.stringify)); if (result === Events.PASS) events.feedevents(null, list.slice(0, length), { skipmap: true, isMacro: true, isReplay: true }); diff --git a/common/content/mappings.js b/common/content/mappings.js index 68bba94c..d1c60f7b 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -50,7 +50,7 @@ var Map = Class("Map", { /** @property {[string]} All of this mapping's names (key sequences). */ names: Class.Memoize(function () this._keys.map(function (k) DOM.Event.canonicalKeys(k))), - get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)], + get toStringParams() [this.modes.map(m => m.name), this.names.map(String.quote)], get identifier() [this.modes[0].name, this.hive.prefix + this.names[0]].join("."), @@ -171,9 +171,9 @@ var MapHive = Class("MapHive", Contexts.Hive, { */ iterate: function (modes) { let stacks = Array.concat(modes).map(this.closure.getStack); - return values(stacks.shift().sort(function (m1, m2) String.localeCompare(m1.name, m2.name)) - .filter(function (map) map.rhs && - stacks.every(function (stack) stack.some(function (m) m.rhs && m.rhs === map.rhs && m.name === map.name)))); + return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name)) + .filter(map => map.rhs && + stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name)))); }, /** @@ -263,7 +263,7 @@ var MapHive = Class("MapHive", Contexts.Hive, { map.names.splice(j, 1); if (map.names.length == 0) // FIX ME. for (let [mode, stack] in Iterator(this.stacks)) - this.stacks[mode] = MapHive.Stack(stack.filter(function (m) m != map)); + this.stacks[mode] = MapHive.Stack(stack.filter(m => m != map)); return; } } @@ -352,15 +352,15 @@ var Mappings = Module("mappings", { get allHives() contexts.allGroups.mappings, - get userHives() this.allHives.filter(function (h) h !== this.builtin, this), + get userHives() this.allHives.filter(h => h !== this.builtin), expandLeader: deprecated("your brain", function expandLeader(keyString) keyString), prefixes: Class.Memoize(function () { - let list = Array.map("CASM", function (s) s + "-"); + let list = Array.map("CASM", s => s + "-"); - return iter(util.range(0, 1 << list.length)).map(function (mask) - list.filter(function (p, i) mask & (1 << i)).join("")).toArray().concat("*-"); + return iter(util.range(0, 1 << list.length)).map(mask => + list.filter((p, i) => mask & (1 << i)).join("")).toArray().concat("*-"); }), expand: function expand(keys) { @@ -371,7 +371,7 @@ var Mappings = Module("mappings", { if (/^<\*-/.test(key)) return ["<", this.prefixes, key.slice(3)]; return key; - }, this).flatten().array).map(function (k) DOM.Event.canonicalKeys(k)); + }, this).flatten().array).map(k => DOM.Event.canonicalKeys(k)); if (keys != arguments[0]) return [arguments[0]].concat(keys); @@ -442,7 +442,7 @@ var Mappings = Module("mappings", { * @param {string} cmd The map name to match. * @returns {Map} */ - get: function get(mode, cmd) this.hives.map(function (h) h.get(mode, cmd)).compact()[0] || null, + get: function get(mode, cmd) this.hives.map(h => h.get(mode, cmd)).compact()[0] || null, /** * Returns a count of maps with names starting with but not equal to @@ -453,8 +453,8 @@ var Mappings = Module("mappings", { * @returns {[Map]} */ getCandidates: function (mode, prefix) - this.hives.map(function (h) h.getCandidates(mode, prefix)) - .reduce(function (a, b) a + b, 0), + this.hives.map(h => h.getCandidates(mode, prefix)) + .reduce((a, b) => a + b, 0), /** * Lists all user-defined mappings matching *filter* for the specified @@ -465,17 +465,17 @@ var Mappings = Module("mappings", { * @param {[MapHive]} hives The map hives to list. @optional */ list: function (modes, filter, hives) { - let modeSign = modes.map(function (m) m.char || "").join("") - + modes.map(function (m) !m.char ? " " + m.name : "").join(""); + let modeSign = modes.map(m => m.char || "").join("") + + modes.map(m => !m.char ? " " + m.name : "").join(""); modeSign = modeSign.replace(/^ /, ""); - hives = (hives || mappings.userHives).map(function (h) [h, maps(h)]) - .filter(function ([h, m]) m.length); + hives = (hives || mappings.userHives).map(h => [h, maps(h)]) + .filter(([h, m]) => m.length); function maps(hive) { let maps = iter.toArray(hive.iterate(modes)); if (filter) - maps = maps.filter(function (m) m.names[0] === filter); + maps = maps.filter(m => m.names[0] === filter); return maps; } @@ -486,10 +486,10 @@ var Mappings = Module("mappings", { ["td", { style: "padding-right: 1em;" }, _("title.Command")], ["td", { style: "padding-right: 1em;" }, _("title.Action")]], ["col", { style: "min-width: 6em; padding-right: 1em;" }], - hives.map(function ([hive, maps]) let (i = 0) [ + hives.map(([hive, maps]) => let (i = 0) [ ["tr", { style: "height: .5ex;" }], - maps.map(function (map) - map.names.map(function (name) + maps.map(map => + map.names.map(name => ["tr", {}, ["td", { highlight: "Title" }, !i++ ? hive.name : ""], ["td", {}, modeSign], @@ -526,7 +526,7 @@ var Mappings = Module("mappings", { if (args[1] && !/^<nop>$/i.test(args[1]) && !args["-count"] && !args["-ex"] && !args["-javascript"] - && mapmodes.every(function (m) m.count)) + && mapmodes.every(m => m.count)) args[1] = "<count>" + args[1]; let [lhs, rhs] = args; @@ -541,7 +541,7 @@ var Mappings = Module("mappings", { args["-group"].add(mapmodes, [lhs], args["-description"], - contexts.bindMacro(args, "-keys", function (params) params), + contexts.bindMacro(args, "-keys", params => params), { arg: args["-arg"], count: args["-count"] || !(args["-ex"] || args["-javascript"]), @@ -614,8 +614,8 @@ var Mappings = Module("mappings", { serialize: function () { return this.name != "map" ? [] : array(mappings.userHives) - .filter(function (h) h.persist) - .map(function (hive) [ + .filter(h => h.persist) + .map(hive => [ { command: "map", options: { @@ -711,9 +711,9 @@ var Mappings = Module("mappings", { } function uniqueModes(modes) { let chars = [k for ([k, v] in Iterator(modules.modes.modeChars)) - if (v.every(function (mode) modes.indexOf(mode) >= 0))]; - return array.uniq(modes.filter(function (m) chars.indexOf(m.char) < 0) - .map(function (m) m.name.toLowerCase()) + if (v.every(mode => modes.indexOf(mode) >= 0))]; + return array.uniq(modes.filter(m => chars.indexOf(m.char) < 0) + .map(m => m.name.toLowerCase()) .concat(chars)); } @@ -773,7 +773,7 @@ var Mappings = Module("mappings", { : [], template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : "")) ], - help: function (map) let (char = array.compact(map.modes.map(function (m) m.char))[0]) + help: function (map) let (char = array.compact(map.modes.map(m => m.char))[0]) char === "n" ? map.name : char ? char + "_" + map.name : "", headings: ["Command", "Mode", "Group", "Description"] } diff --git a/common/content/marks.js b/common/content/marks.js index 8131e296..c7329595 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -30,7 +30,7 @@ var Marks = Module("marks", { */ get all() iter(this._localMarks.get(this.localURI) || {}, this._urlMarks - ).sort(function (a, b) String.localeCompare(a[0], b[0])), + ).sort((a, b) => String.localeCompare(a[0], b[0])), get localURI() buffer.focusedFrame.document.documentURI.replace(/#.*/, ""), @@ -137,7 +137,7 @@ var Marks = Module("marks", { let store = buffer.localStore; return { index: store.jumpsIndex, - locations: store.jumps.map(function (j) j.mark) + locations: store.jumps.map(j => j.mark) }; }, @@ -260,7 +260,7 @@ var Marks = Module("marks", { if (filter.length > 0) { let pattern = util.charListToRegexp(filter, "a-zA-Z"); - marks = marks.filter(function ([k, ]) pattern.test(k)); + marks = marks.filter(([k, ]) => pattern.test(k)); dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote())); } @@ -376,9 +376,9 @@ var Marks = Module("marks", { function percent(i) Math.round(i * 100); context.title = ["Mark", "HPos VPos File"]; - context.keys.description = function ([, m]) (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y) - : percent(m.position.x) + "% " + percent(m.position.y) + "%" - ) + " " + m.location; + context.keys.description = ([, m]) => (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y) + : percent(m.position.x) + "% " + percent(m.position.y) + "%" + ) + " " + m.location; context.completions = marks.all; }; }, diff --git a/common/content/modes.js b/common/content/modes.js index fc33fd7f..401df031 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -237,7 +237,7 @@ var Modes = Module("modes", { if (this._modeMap[mode.mode] == mode) delete this._modeMap[mode.mode]; - this._mainModes = this._mainModes.filter(function (m) m != mode); + this._mainModes = this._mainModes.filter(m => m != mode); }, dumpStack: function dumpStack() { @@ -254,11 +254,11 @@ var Modes = Module("modes", { getCharModes: function getCharModes(chr) (this.modeChars[chr] || []).slice(), - have: function have(mode) this._modeStack.some(function (m) isinstance(m.main, mode)), + have: function have(mode) this._modeStack.some(m => isinstance(m.main, mode)), matchModes: function matchModes(obj) - this._modes.filter(function (mode) Object.keys(obj) - .every(function (k) obj[k] == (mode[k] || false))), + this._modes.filter(mode => Object.keys(obj) + .every(k => obj[k] == (mode[k] || false))), // show the current mode string in the command line show: function show() { @@ -274,7 +274,7 @@ var Modes = Module("modes", { remove: function remove(mode, covert) { if (covert && this.topOfStack.main != mode) { util.assert(mode != this.NORMAL); - for (let m; m = array.nth(this.modeStack, function (m) m.main == mode, 0);) + for (let m; m = array.nth(this.modeStack, m => m.main == mode, 0);) this._modeStack.splice(this._modeStack.indexOf(m)); } else if (this.stack.some(function (m) m.main == mode)) { @@ -361,7 +361,7 @@ var Modes = Module("modes", { push ? { push: push } : stack || {}, prev); - delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self)); + delayed.forEach(([fn, self]) => dactyl.trapErrors(fn, self)); dactyl.triggerObserver("modes.change", [oldMain, oldExtended], [this._main, this._extended], stack); this.show(); @@ -465,11 +465,11 @@ var Modes = Module("modes", { hidden: false, - input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)), + input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(b => b.input)), - insert: Class.Memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)), + insert: Class.Memoize(function insert() this.bases.length && this.bases.some(b => b.insert)), - ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)), + ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(b => b.ownsFocus)), passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey), @@ -491,8 +491,8 @@ var Modes = Module("modes", { update(StackElement.prototype, { get toStringParams() !loaded.modes ? this.main.name : [ this.main.name, - ["(", modes.all.filter(function (m) this.extended & m, this) - .map(function (m) m.name).join("|"), + ["(", modes.all.filter(m => this.extended & m) + .map(m => m.name).join("|"), ")"].join("") ] }); @@ -525,7 +525,7 @@ var Modes = Module("modes", { }, { cache: function initCache() { function makeTree() { - let list = modes.all.filter(function (m) m.name !== m.description); + let list = modes.all.filter(m => m.name !== m.description); let tree = {}; @@ -558,7 +558,7 @@ var Modes = Module("modes", { return rec(roots); } - cache.register("modes.dtd", function () + cache.register("modes.dtd", () => util.makeDTD(iter({ "modes.tree": makeTree() }, config.dtd))); }, @@ -599,7 +599,7 @@ var Modes = Module("modes", { getKey: function getKey(val, default_) { if (isArray(val)) - return (array.nth(this.value, function (v) val.some(function (m) m.name === v.mode), 0) + return (array.nth(this.value, v => val.some(m => m.name === v.mode), 0) || { result: default_ }).result; return Set.has(this.valueMap, val) ? this.valueMap[val] : default_; @@ -613,11 +613,11 @@ var Modes = Module("modes", { result: v[0] !== "!" })); - this.valueMap = values(vals).map(function (v) [v.mode, v.result]).toObject(); + this.valueMap = values(vals).map(v => [v.mode, v.result]).toObject(); return vals; }, - validator: function validator(vals) vals.map(function (v) v.replace(/^!/, "")).every(Set.has(this.values)), + validator: function validator(vals) vals.map(v => v.replace(/^!/, "")).every(Set.has(this.values)), get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)]) }; diff --git a/common/content/mow.js b/common/content/mow.js index 6ef53f8f..6945a4d2 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -199,7 +199,7 @@ var MOW = Module("mow", { for (let node in array.iterValues(menu.children)) { let group = node.getAttributeNS(NS, "group"); - node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]); + node.hidden = group && !group.split(/\s+/).every(g => enabled[g]); } } }, @@ -346,36 +346,36 @@ var MOW = Module("mow", { bind(["j", "<C-e>", "<Down>"], "Scroll down one line", function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); }, - function () mow.canScroll(1), BEEP); + () => mow.canScroll(1), BEEP); bind(["k", "<C-y>", "<Up>"], "Scroll up one line", function ({ count }) { mow.scrollVertical("lines", -1 * (count || 1)); }, - function () mow.canScroll(-1), BEEP); + () => mow.canScroll(-1), BEEP); bind(["<C-j>", "<C-m>", "<Return>"], "Scroll down one line, exit on last line", function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); }, - function () mow.canScroll(1), DROP); + () => mow.canScroll(1), DROP); // half page down bind(["<C-d>"], "Scroll down half a page", function ({ count }) { mow.scrollVertical("pages", .5 * (count || 1)); }, - function () mow.canScroll(1), BEEP); + () => mow.canScroll(1), BEEP); bind(["<C-f>", "<PageDown>"], "Scroll down one page", function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); }, - function () mow.canScroll(1), BEEP); + () => mow.canScroll(1), BEEP); bind(["<Space>"], "Scroll down one page", function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); }, - function () mow.canScroll(1), DROP); + () => mow.canScroll(1), DROP); bind(["<C-u>"], "Scroll up half a page", function ({ count }) { mow.scrollVertical("pages", -.5 * (count || 1)); }, - function () mow.canScroll(-1), BEEP); + () => mow.canScroll(-1), BEEP); bind(["<C-b>", "<PageUp>"], "Scroll up half a page", function ({ count }) { mow.scrollVertical("pages", -1 * (count || 1)); }, - function () mow.canScroll(-1), BEEP); + () => mow.canScroll(-1), BEEP); bind(["gg"], "Scroll to the beginning of output", function () { mow.scrollToPercent(null, 0); }); @@ -390,7 +390,7 @@ var MOW = Module("mow", { // close the window bind(["q"], "Close the output window", function () {}, - function () false, DROP); + () => false, DROP); }, options: function initOptions() { options.add(["more"], diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js index f2c10399..534d71cc 100644 --- a/common/content/quickmarks.js +++ b/common/content/quickmarks.js @@ -40,7 +40,7 @@ var QuickMarks = Module("quickmarks", { find: function find(url) { let res = []; for (let [k, v] in this._qmarks) - if (dactyl.parseURLs(v).some(function (u) String.replace(u, /#.*/, "") == url)) + if (dactyl.parseURLs(v).some(u => String.replace(u, /#.*/, "") == url)) res.push(k); return res; }, @@ -109,7 +109,7 @@ var QuickMarks = Module("quickmarks", { if (filter.length > 0) { let pattern = util.charListToRegexp(filter, "a-zA-Z0-9"); - marks = marks.filter(function (qmark) pattern.test(qmark)); + marks = marks.filter(qmark => pattern.test(qmark)); dactyl.assert(marks.length >= 0, _("quickmark.noMatching", filter.quote())); } @@ -158,7 +158,7 @@ var QuickMarks = Module("quickmarks", { context.title = ["Extra Completions"]; context.completions = [ [quickmarks.get(args[0]), _("option.currentValue")] - ].filter(function ([k, v]) k); + ].filter(([k, v]) => k); }); context.fork("url", 0, completion, "url"); } @@ -178,7 +178,7 @@ var QuickMarks = Module("quickmarks", { completion: function initCompletion() { completion.quickmark = function (context) { context.title = ["QuickMark", "URL"]; - context.generate = function () Iterator(quickmarks._qmarks); + context.generate = () => Iterator(quickmarks._qmarks); }; }, mappings: function initMappings() { diff --git a/common/content/statusline.js b/common/content/statusline.js index 4cf50c47..f5460b37 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -245,7 +245,7 @@ var StatusLine = Module("statusline", { url = _("buffer.noName"); } else { - url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help")) + url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), (m, n1, n2) => n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help")) .replace(RegExp("^dactyl://help/(\\S+)"), "$1 " + _("buffer.help")); } diff --git a/common/content/tabs.js b/common/content/tabs.js index 016355fa..1a9b6c75 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -37,7 +37,7 @@ var Tabs = Module("tabs", { this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", literal(/* xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; } - */).replace(/tab-./g, function (m) config.OS.isMacOSX ? "tab-mac" : m), + */).replace(/tab-./g, m => config.OS.isMacOSX ? "tab-mac" : m), false, true); this.timeout(function () { @@ -57,7 +57,7 @@ var Tabs = Module("tabs", { } }, - _alternates: Class.Memoize(function () [config.tabbrowser.mCurrentTab, null]), + _alternates: Class.Memoize(() => [config.tabbrowser.mCurrentTab, null]), cleanup: function cleanup() { for (let [i, tab] in Iterator(this.allTabs)) { @@ -139,7 +139,7 @@ var Tabs = Module("tabs", { */ get options() this.localStore.options, - get visibleTabs() config.tabbrowser.visibleTabs || this.allTabs.filter(function (tab) !tab.hidden), + get visibleTabs() config.tabbrowser.visibleTabs || this.allTabs.filter(tab => !tab.hidden), /** * Returns the local state store for the tab at the specified *tabIndex*. @@ -552,7 +552,7 @@ var Tabs = Module("tabs", { if (matches) return tabs.select(matches, false); - matches = completion.runCompleter("buffer", buffer).map(function (obj) obj.tab); + matches = completion.runCompleter("buffer", buffer).map(obj => obj.tab); if (matches.length == 0) dactyl.echoerr(_("buffer.noMatching", buffer)); @@ -650,7 +650,7 @@ var Tabs = Module("tabs", { count: true, completer: function (context, args) { if (!args.bang) - context.filters.push(function ({ item }) !item.tab.pinned); + context.filters.push(({ item }) => !item.tab.pinned); completion.buffer(context); } }); @@ -665,7 +665,7 @@ var Tabs = Module("tabs", { argCount: "?", count: true, completer: function (context, args) { - context.filters.push(function ({ item }) item.tab.pinned); + context.filters.push(({ item }) => item.tab.pinned); completion.buffer(context); } }); @@ -730,7 +730,7 @@ var Tabs = Module("tabs", { commands.add(["tabl[ast]", "bl[ast]"], "Switch to the last tab", - function () tabs.select("$", false), + function () { tabs.select("$", false); }, { argCount: "0" }); // TODO: "Zero count" if 0 specified as arg @@ -893,10 +893,10 @@ var Tabs = Module("tabs", { commands.add(["taba[ttach]"], "Attach the current tab to another window", function (args) { - dactyl.assert(args.length <= 2 && !args.some(function (i) !/^\d+(?:$|:)/.test(i)), + dactyl.assert(args.length <= 2 && !args.some(i => !/^\d+(?:$|:)/.test(i)), _("error.trailingCharacters")); - let [winIndex, tabIndex] = args.map(function (arg) parseInt(arg)); + let [winIndex, tabIndex] = args.map(arg => parseInt(arg)); if (args["-group"]) { util.assert(args.length == 1); window.TabView.moveTabTo(tabs.getTab(), winIndex); @@ -940,7 +940,7 @@ var Tabs = Module("tabs", { if (args["-group"]) completion.tabGroup(context); else { - context.filters.push(function ({ item }) item != window); + context.filters.push(({ item }) => item != window); completion.window(context); } break; @@ -1061,7 +1061,7 @@ var Tabs = Module("tabs", { for (let [id, vals] in Iterator(tabGroups)) context.fork(id, 0, this, function (context, [name, browsers]) { context.title = [name || "Buffers"]; - context.generate = function () + context.generate = () => Array.map(browsers, function ([i, browser]) { let indicator = " "; if (i == tabs.index()) @@ -1089,7 +1089,7 @@ var Tabs = Module("tabs", { context.keys = { text: "id", description: function (group) group.getTitle() || - group.getChildren().map(function (t) t.tab.label).join(", ") + group.getChildren().map(t => t.tab.label).join(", ") }; context.generate = function () { context.incomplete = true; |