mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-15 21:05:48 +01:00
Replace expression closures (function declarations).
Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
@@ -287,7 +287,9 @@ var Bookmarks = Module("bookmarks", {
|
||||
if (!queryURI)
|
||||
return Promise.reject();
|
||||
|
||||
function parse(req) JSON.parse(req.responseText)[1].filter(isString);
|
||||
function parse(req) {
|
||||
return JSON.parse(req.responseText)[1].filter(isString);
|
||||
}
|
||||
return this.makeSuggestions(queryURI, parse, callback);
|
||||
},
|
||||
|
||||
|
||||
@@ -243,9 +243,11 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
CommandExMode().open(mode + "open " + (args || ""));
|
||||
}
|
||||
|
||||
function decode(uri) util.losslessDecodeURI(uri)
|
||||
.replace(/%20(?!(?:%20)*$)/g, " ")
|
||||
.replace(RegExp(options["urlseparator"], "g"), encodeURIComponent);
|
||||
function decode(uri) {
|
||||
return util.losslessDecodeURI(uri)
|
||||
.replace(/%20(?!(?:%20)*$)/g, " ")
|
||||
.replace(RegExp(options["urlseparator"], "g"), encodeURIComponent);
|
||||
}
|
||||
|
||||
mappings.add([modes.NORMAL],
|
||||
["o"], "Open one or more URLs",
|
||||
|
||||
@@ -165,7 +165,9 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
const self = this;
|
||||
this.elements[obj.name] = obj;
|
||||
|
||||
function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id));
|
||||
function get(prefix, map, id) {
|
||||
return (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id));
|
||||
}
|
||||
|
||||
this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]);
|
||||
this.activeGroup.__defineGetter__(obj.name, () => this.getGroup(obj.name));
|
||||
|
||||
@@ -231,7 +231,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
},
|
||||
|
||||
addUsageCommand: function (params) {
|
||||
function keys(item) (item.names || [item.name]).concat(item.description, item.columns || []);
|
||||
function keys(item) {
|
||||
return (item.names || [item.name]).concat(item.description, item.columns || []);
|
||||
}
|
||||
|
||||
let name = commands.add(params.name, params.description,
|
||||
function (args) {
|
||||
@@ -1667,10 +1669,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
options: startupOptions
|
||||
});
|
||||
|
||||
function findToolbar(name) DOM.XPath(
|
||||
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
||||
"@toolbarname=" + util.escapeString(name.trim(), "'") + "]",
|
||||
document).snapshotItem(0);
|
||||
function findToolbar(name) {
|
||||
return DOM.XPath(
|
||||
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
||||
"@toolbarname=" + util.escapeString(name.trim(), "'") + "]",
|
||||
document).snapshotItem(0);
|
||||
}
|
||||
|
||||
var toolbox = document.getElementById("navigator-toolbox");
|
||||
if (toolbox) {
|
||||
|
||||
@@ -299,7 +299,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
// Find the *count*th occurance of *char* before a non-collapsed
|
||||
// \n, ignoring the character at the caret.
|
||||
let i = 0;
|
||||
function test(c) (collapse || c != "\n") && !!(!i++ || c != char || --count)
|
||||
function test(c) {
|
||||
return (collapse || c != "\n") && !!(!i++ || c != char || --count);
|
||||
}
|
||||
|
||||
Editor.extendRange(range, !backward, { test: test }, true);
|
||||
dactyl.assert(count == 0);
|
||||
|
||||
@@ -861,7 +861,10 @@ 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 Ci.nsIDOMHTMLDocument
|
||||
function hasHTMLDocument(win) {
|
||||
return win && win.document && win.document instanceof Ci.nsIDOMHTMLDocument;
|
||||
}
|
||||
|
||||
if (dactyl.ignoreFocus)
|
||||
return;
|
||||
|
||||
@@ -1129,10 +1132,12 @@ var Events = Module("events", {
|
||||
init: function init(values, map) {
|
||||
this.name = "passkeys:" + map;
|
||||
this.stack = MapHive.Stack(values.map(v => Map(v[map + "Keys"])));
|
||||
function Map(keys) ({
|
||||
execute: function () Events.PASS_THROUGH,
|
||||
keys: keys
|
||||
});
|
||||
function Map(keys) {
|
||||
return {
|
||||
execute: function () Events.PASS_THROUGH,
|
||||
keys: keys
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
get active() this.stack.length,
|
||||
|
||||
@@ -798,9 +798,11 @@ var Hints = Module("hints", {
|
||||
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]) ||
|
||||
Buffer.isScrollable(elem, 0, true) || Buffer.isScrollable(elem, 0, false);
|
||||
function isScrollable(elem) {
|
||||
return isinstance(elem, [Ci.nsIDOMHTMLFrameElement, Ci.nsIDOMHTMLIFrameElement]) ||
|
||||
Buffer.isScrollable(elem, 0, true) ||
|
||||
Buffer.isScrollable(elem, 0, false);
|
||||
}
|
||||
},
|
||||
|
||||
hintSession: Modes.boundProperty(),
|
||||
@@ -820,7 +822,9 @@ var Hints = Module("hints", {
|
||||
* @optional
|
||||
*/
|
||||
addMode: function (mode, prompt, action, filter, tags) {
|
||||
function toString(regexp) RegExp.prototype.toString.call(regexp);
|
||||
function toString(regexp) {
|
||||
return RegExp.prototype.toString.call(regexp);
|
||||
}
|
||||
|
||||
if (tags != null) {
|
||||
let eht = options.get("extendedhinttags");
|
||||
@@ -912,7 +916,9 @@ var Hints = Module("hints", {
|
||||
* @param {string} str The string to split.
|
||||
* @returns {Array(string)} The lowercased splits of the splitting.
|
||||
*/
|
||||
function tokenize(pat, str) str.split(pat).map(String.toLowerCase);
|
||||
function tokenize(pat, str) {
|
||||
return str.split(pat).map(String.toLowerCase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a hint matcher for hintmatching=contains
|
||||
|
||||
@@ -354,7 +354,9 @@ var History = Module("history", {
|
||||
completion.addUrlCompleter("history", "History", completion.history);
|
||||
},
|
||||
mappings: function initMappings() {
|
||||
function bind(...args) apply(mappings, "add", [config.browserModes].concat(args));
|
||||
function bind(...args) {
|
||||
return apply(mappings, "add", [config.browserModes].concat(args));
|
||||
}
|
||||
|
||||
bind(["<C-o>"], "Go to an older position in the jump list",
|
||||
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },
|
||||
|
||||
@@ -373,7 +373,9 @@ var Marks = Module("marks", {
|
||||
|
||||
completion: function initCompletion() {
|
||||
completion.mark = function mark(context) {
|
||||
function percent(i) Math.round(i * 100);
|
||||
function percent(i) {
|
||||
return Math.round(i * 100);
|
||||
}
|
||||
|
||||
context.title = ["Mark", "HPos VPos File"];
|
||||
context.keys.description = ([, m]) => (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y)
|
||||
@@ -388,10 +390,14 @@ var Marks = Module("marks", {
|
||||
persistent: true,
|
||||
contains: ["history"],
|
||||
action: function (timespan, host) {
|
||||
function matchhost(url) !host || util.isDomainURL(url, host);
|
||||
function match(marks) (k
|
||||
for ([k, v] of iter(marks))
|
||||
if (timespan.contains(v.timestamp) && matchhost(v.location)));
|
||||
function matchhost(url) {
|
||||
return !host || util.isDomainURL(url, host);
|
||||
}
|
||||
function match(marks) {
|
||||
return (k
|
||||
for ([k, v] of iter(marks))
|
||||
if (timespan.contains(v.timestamp) && matchhost(v.location)));
|
||||
}
|
||||
|
||||
for (let [url, local] of marks._localMarks)
|
||||
if (matchhost(url)) {
|
||||
|
||||
Reference in New Issue
Block a user