diff --git a/common/content/autocommands.js b/common/content/autocommands.js
index 82b7e0cd..55b53173 100755
--- a/common/content/autocommands.js
+++ b/common/content/autocommands.js
@@ -213,8 +213,10 @@ const AutoCommands = Module("autocommands", {
// TODO: Perhaps this should take -args to pass to the command?
function (args) {
// Vim compatible
- if (args.length == 0)
- return void liberator.echomsg("No matching autocommands");
+ if (args.length == 0) {
+ liberator.echomsg("No matching autocommands");
+ return;
+ }
let [event, url] = args;
let defaultURL = url || buffer.URL;
diff --git a/common/content/base.js b/common/content/base.js
index bd3e7d21..8c47a0af 100644
--- a/common/content/base.js
+++ b/common/content/base.js
@@ -135,7 +135,7 @@ function isinstance(targ, src) {
boolean: Boolean,
string: String,
function: Function,
- number: Number,
+ number: Number
}
src = Array.concat(src);
for (var i=0; i < src.length; i++) {
@@ -372,7 +372,7 @@ function Class() {
var superc = superclass;
superclass = function Shim() {}
extend(superclass, superc, {
- init: superc,
+ init: superc
});
}
diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js
index e8d4766b..cdd61d78 100644
--- a/common/content/bookmarks.js
+++ b/common/content/bookmarks.js
@@ -335,12 +335,13 @@ const Bookmarks = Module("bookmarks", {
catch (e) {}
if (!callback)
return results;
- callback(results);
+ return callback(results);
}
let resp = util.httpGet(queryURI, callback && process);
if (!callback)
return process(resp);
+ return null;
},
// TODO: add filtering
@@ -440,6 +441,7 @@ const Bookmarks = Module("bookmarks", {
liberator.echoerr("E283: No bookmarks matching tags: \"" + tags + "\"");
else
liberator.echoerr("No bookmarks set");
+ return null;
}
}, {
}, {
@@ -644,6 +646,7 @@ const Bookmarks = Module("bookmarks", {
item.url = decodeURIComponent(query.replace(/#.*/, ""));
return item;
}
+ return null;
}).filter(util.identity);
};
});
diff --git a/common/content/browser.js b/common/content/browser.js
index 9ff670ee..3bc70b38 100644
--- a/common/content/browser.js
+++ b/common/content/browser.js
@@ -16,8 +16,7 @@ const Browser = Module("browser", {
// TODO: support 'nrformats'? -> probably not worth it --mst
incrementURL: function (count) {
let matches = buffer.URL.match(/(.*?)(\d+)(\D*)$/);
- if (!matches)
- return void liberator.beep();
+ liberator.assert(matches);
let [, pre, number, post] = matches;
let newNumber = parseInt(number, 10) + count;
@@ -48,6 +47,7 @@ const Browser = Module("browser", {
getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
}
catch (e) { liberator.reportError(e); }
+ return null;
},
completer: function (context) completion.charset(context)
});
@@ -189,8 +189,7 @@ const Browser = Module("browser", {
"Go to the root of the website",
function () {
let uri = content.document.location;
- if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
- return void liberator.beep();
+ liberator.assert(!/(about|mailto):/.test(uri.protocol)); // exclude these special protocols for now
liberator.open(uri.protocol + "//" + (uri.host || "") + "/");
});
@@ -221,7 +220,7 @@ const Browser = Module("browser", {
}, {
completer: function (context) completion.url(context),
literal: 0,
- privateData: true,
+ privateData: true
});
commands.add(["redr[aw]"],
diff --git a/common/content/buffer.js b/common/content/buffer.js
index 748e2b1f..23322cd2 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -480,23 +480,23 @@ const Buffer = Module("buffer", {
focusElement: function (elem) {
let doc = window.content.document;
if (elem instanceof HTMLFrameElement || elem instanceof HTMLIFrameElement)
- return void elem.contentWindow.focus();
+ elem.contentWindow.focus();
else if (elem instanceof HTMLInputElement && elem.type == "file") {
Buffer.openUploadPrompt(elem);
buffer.lastInputField = elem;
- return;
}
+ else {
+ elem.focus();
- elem.focus();
+ // for imagemap
+ if (elem instanceof HTMLAreaElement) {
+ try {
+ let [x, y] = elem.getAttribute("coords").split(",").map(parseFloat);
- // for imagemap
- if (elem instanceof HTMLAreaElement) {
- try {
- let [x, y] = elem.getAttribute("coords").split(",").map(parseFloat);
-
- elem.dispatchEvent(events.create(doc, "mouseover", { screenX: x, screenY: y }));
+ elem.dispatchEvent(events.create(doc, "mouseover", { screenX: x, screenY: y }));
+ }
+ catch (e) {}
}
- catch (e) {}
}
},
@@ -881,8 +881,7 @@ const Buffer = Module("buffer", {
let option = sections || options["pageinfo"];
let list = template.map(option, function (option) {
let opt = buffer.pageInfo[option];
- if (opt)
- return template.table(opt[1], opt[0](true));
+ return opt ? template.table(opt[1], opt[0](true)) : undefined;
},
);
liberator.echo(list, commandline.FORCE_MULTILINE);
},
@@ -1037,7 +1036,6 @@ const Buffer = Module("buffer", {
scrollVertical: function scrollVertical(elem, increment, number) {
elem = elem || Buffer.findScrollable(number, false);
let fontSize = parseInt(util.computedStyle(elem).fontSize);
- let increment;
if (increment == "lines")
increment = fontSize;
else if (increment == "pages")
@@ -1050,7 +1048,6 @@ const Buffer = Module("buffer", {
scrollHorizontal: function scrollHorizontal(elem, increment, number) {
elem = elem || Buffer.findScrollable(number, true);
let fontSize = parseInt(util.computedStyle(elem).fontSize);
- let increment;
if (increment == "columns")
increment = fontSize; // Good enough, I suppose.
else if (increment == "pages")
@@ -1093,8 +1090,7 @@ const Buffer = Module("buffer", {
openUploadPrompt: function openUploadPrompt(elem) {
commandline.input("Upload file: ", function (path) {
let file = io.File(path);
- if (!file.exists())
- return void liberator.beep();
+ liberator.assert(file.exists());
elem.value = file.path;
}, {
@@ -1411,10 +1407,8 @@ const Buffer = Module("buffer", {
mappings.add(myModes, ["%"],
"Scroll to {count} percent of the document",
function (count) {
- if (count > 0 && count <= 100)
- buffer.scrollToPercent(buffer.scrollXPercent, count);
- else
- liberator.beep();
+ liberator.assert(count > 0 && count <= 100);
+ buffer.scrollToPercent(buffer.scrollXPercent, count);
},
{ count: true });
@@ -1484,10 +1478,8 @@ const Buffer = Module("buffer", {
return computedStyle.visibility != "hidden" && computedStyle.display != "none";
});
- if (elements.length > 0)
- buffer.focusElement(elements[util.Math.constrain(count, 1, elements.length) - 1]);
- else
- liberator.beep();
+ liberator.assert(elements.length > 0);
+ buffer.focusElement(elements[util.Math.constrain(count, 1, elements.length) - 1]);
}
},
{ count: true });
@@ -1503,20 +1495,16 @@ const Buffer = Module("buffer", {
"Open (put) a URL based on the current clipboard contents in the current buffer",
function () {
let url = util.readFromClipboard();
- if (url)
- liberator.open(url);
- else
- liberator.beep();
+ liberator.assert(url);
+ liberator.open(url);
});
mappings.add(myModes, ["P"],
"Open (put) a URL based on the current clipboard contents in a new buffer",
function () {
let url = util.readFromClipboard();
- if (url)
- liberator.open(url, { from: "activate", where: liberator.NEW_TAB });
- else
- liberator.beep();
+ liberator.assert(url);
+ liberator.open(url, { from: "activate", where: liberator.NEW_TAB });
});
// reloading
@@ -1533,11 +1521,8 @@ const Buffer = Module("buffer", {
"Copy selected text or current word",
function () {
let sel = buffer.getCurrentWord();
-
- if (sel)
- util.copyToClipboard(sel, true);
- else
- liberator.beep();
+ liberator.assert(sel);
+ util.copyToClipboard(sel, true);
});
// zooming
diff --git a/common/content/commandline.js b/common/content/commandline.js
index 9dc07444..5faa94b6 100644
--- a/common/content/commandline.js
+++ b/common/content/commandline.js
@@ -179,7 +179,7 @@ const CommandLine = Module("commandline", {
if (self._input.complete)
self._autocompleteTimer.tell(false);
if (self._input.change)
- return self._input.change.call(commandline, str);
+ self._input.change.call(commandline, str);
});
this.registerCallback("complete", modes.PROMPT, function (context) {
if (self._input.complete)
@@ -647,10 +647,8 @@ const CommandLine = Module("commandline", {
event.preventDefault();
event.stopPropagation();
- if (this._history)
- this._history.select(/Up/.test(key), !/(Page|S-)/.test(key));
- else
- liberator.beep();
+ liberator.assert(this._history);
+ this._history.select(/Up/.test(key), !/(Page|S-)/.test(key));
}
// user pressed to get completions of a command
else if (key == "" || key == "") {
@@ -937,8 +935,10 @@ const CommandLine = Module("commandline", {
* and what they do.
*/
updateMorePrompt: function updateMorePrompt(force, showHelp) {
- if (this._outputContainer.collapsed)
- return this._echoLine("", this.HL_NORMAL);
+ if (this._outputContainer.collapsed) {
+ this._echoLine("", this.HL_NORMAL);
+ return;
+ }
let win = this._multilineOutputWidget.contentWindow;
function isScrollable() !win.scrollMaxY == 0;
@@ -1489,10 +1489,8 @@ const CommandLine = Module("commandline", {
mappings.add([modes.NORMAL],
["g<"], "Redisplay the last command output",
function () {
- if (this._lastMowOutput)
- this._echoMultiline(this._lastMowOutput, commandline.HL_NORMAL);
- else
- liberator.beep();
+ liberator.assert(this._lastMowOutput);
+ this._echoMultiline(this._lastMowOutput, commandline.HL_NORMAL);
});
},
options: function () {
@@ -1853,7 +1851,7 @@ const ItemList = Class("ItemList", {
onEvent: function onEvent(event) false
}, {
- WAITING_MESSAGE: "Generating results...",
+ WAITING_MESSAGE: "Generating results..."
});
// vim: set fdm=marker sw=4 ts=4 et:
diff --git a/common/content/commands.js b/common/content/commands.js
index 2cfbbbfc..66e4d874 100644
--- a/common/content/commands.js
+++ b/common/content/commands.js
@@ -371,9 +371,9 @@ const Commands = Module("commands", {
function quote(str) Commands.quoteArg[/[\s"'\\]|^$/.test(str) ? '"' : ""](str);
for (let [opt, val] in Iterator(args.options || {})) {
- let char = /^-.$/.test(opt) ? " " : "=";
+ let chr = /^-.$/.test(opt) ? " " : "=";
if (val != null)
- opt += char + quote(val)
+ opt += chr + quote(val)
res.push(opt);
}
for (let [, arg] in Iterator(args.arguments || []))
@@ -816,31 +816,31 @@ const Commands = Module("commands", {
break;
case "vimperator":
- if (res = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/))
+ if ((res = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/)))
arg += res[2].replace(/\\(.)/g, "$1");
- else if (res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/))
+ else if ((res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/)))
arg += eval(res[0] + (res[3] ? "" : '"'));
- else if (res = str.match(/^(')((?:[^\\']|\\.)*)('?)/))
+ else if ((res = str.match(/^(')((?:[^\\']|\\.)*)('?)/)))
arg += res[2].replace(/\\(.)/g, function (n0, n1) /[\\']/.test(n1) ? n1 : n0);
break;
case "rc-ish":
- if (res = str.match = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/))
+ if ((res = str.match = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/)))
arg += res[2].replace(/\\(.)/g, "$1");
- else if (res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/))
+ else if ((res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/)))
arg += eval(res[0] + (res[3] ? "" : '"'));
- else if (res = str.match(/^(')((?:[^']|'')*)('?)/))
+ else if ((res = str.match(/^(')((?:[^']|'')*)('?)/)))
arg += res[2].replace("''", "'", "g");
break;
case "pythonesque":
- if (res = str.match = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/))
+ if ((res = str.match = str.match(/^()((?:[^\\\s"']|\\.)+)((?:\\$)?)/)))
arg += res[2].replace(/\\(.)/g, "$1");
- else if (res = str.match(/^(""")((?:.?.?[^"])*)((?:""")?)/))
+ else if ((res = str.match(/^(""")((?:.?.?[^"])*)((?:""")?)/)))
arg += res[2];
- else if (res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/))
+ else if ((res = str.match(/^(")((?:[^\\"]|\\.)*)("?)/)))
arg += eval(res[0] + (res[3] ? "" : '"'));
- else if (res = str.match(/^(')((?:[^\\']|\\.)*)('?)/))
+ else if ((res = str.match(/^(')((?:[^\\']|\\.)*)('?)/)))
arg += res[2].replace(/\\(.)/g, function (n0, n1) /[\\']/.test(n1) ? n1 : n0);
break;
}
@@ -887,8 +887,10 @@ const Commands = Module("commands", {
let [count, cmd, bang, args] = commands.parseCommand(context.filter);
let [, prefix, junk] = context.filter.match(/^(:*\d*)\w*(.?)/) || [];
context.advance(prefix.length);
- if (!junk)
- return void context.fork("", 0, this, "command");
+ if (!junk) {
+ context.fork("", 0, this, "command");
+ return;
+ }
// dynamically get completions as specified with the command's completer function
let command = commands.get(cmd);
diff --git a/common/content/completion.js b/common/content/completion.js
index c047da82..8dd2e05a 100644
--- a/common/content/completion.js
+++ b/common/content/completion.js
@@ -180,6 +180,7 @@ const CompletionContext = Class("CompletionContext", {
this.getKey = function (item, key) (typeof self.keys[key] == "function") ? self.keys[key].call(this, item.item) :
key in self.keys ? item.item[self.keys[key]]
: item.item[key];
+ return this;
},
// Temporary
/**
@@ -1008,7 +1009,7 @@ const Completion = Module("completion", {
if (e.message != "Invalid JS")
liberator.reportError(e);
lastIdx = 0;
- return;
+ return null;
}
let cache = this.context.cache;
@@ -1023,7 +1024,7 @@ const Completion = Module("completion", {
for (let [, v] in Iterator(get(0)[FULL_STATEMENTS])) {
let key = str.substring(prev, v + 1);
if (checkFunction(prev, v, key))
- return;
+ return null;
this.eval(key);
prev = v + 1;
}
@@ -1210,11 +1211,11 @@ const Completion = Module("completion", {
// Does the opening "(" mark a function call?
if (get(-3, 0, FUNCTIONS) != get(-2)[OFFSET])
- return; // No. We're done.
+ return null; // No. We're done.
let [offset, obj, func] = getObjKey(-3);
if (!obj.length)
- return;
+ return null;
obj = obj.slice(0, 1);
try {
@@ -1224,7 +1225,7 @@ const Completion = Module("completion", {
if (!completer)
completer = this.completers[func];
if (!completer)
- return;
+ return null;
// Split up the arguments
let prev = get(-2)[OFFSET];
@@ -1249,7 +1250,7 @@ const Completion = Module("completion", {
// In a string that's not an obj key or a function arg.
// Nothing to do.
- return;
+ return null;
}
//
@@ -1268,11 +1269,11 @@ const Completion = Module("completion", {
if (!this.context.tabPressed && key == "" && obj.length > 1) {
this.context.waitingForTab = true;
this.context.message = "Waiting for key press";
- return;
+ return null;
}
if (!/^(?:[a-zA-Z_$][\w$]*)?$/.test(key))
- return; // Not a word. Forget it. Can this even happen?
+ return null; // Not a word. Forget it. Can this even happen?
try { // FIXME
var o = top[OFFSET];
@@ -1282,11 +1283,12 @@ const Completion = Module("completion", {
finally {
top[OFFSET] = o;
}
+ return null;
}
}
}, {
- EVAL_TMP: "__liberator_eval_tmp",
- }),
+ EVAL_TMP: "__liberator_eval_tmp"
+ })
});
// vim: set fdm=marker sw=4 ts=4 et:
diff --git a/common/content/editor.js b/common/content/editor.js
index 5f0d7cea..70414226 100644
--- a/common/content/editor.js
+++ b/common/content/editor.js
@@ -258,7 +258,7 @@ const Editor = Module("editor", {
if (forward) {
if (pos <= Editor.getEditor().selectionEnd || pos > Editor.getEditor().value.length)
- return false;
+ return;
do { // TODO: test code for endless loops
this.executeCommand("cmd_selectCharNext", 1);
@@ -267,7 +267,7 @@ const Editor = Module("editor", {
}
else {
if (pos >= Editor.getEditor().selectionStart || pos < 0)
- return false;
+ return;
do { // TODO: test code for endless loops
this.executeCommand("cmd_selectCharPrevious", 1);
@@ -339,7 +339,7 @@ const Editor = Module("editor", {
// TODO: clean up with 2 functions for textboxes and currentEditor?
editFieldExternally: function (forceEditing) {
if (!options["editor"])
- return false;
+ return;
let textBox = null;
if (!(config.isComposeWindow))
@@ -349,7 +349,7 @@ const Editor = Module("editor", {
commandline.input("Editing a password field externally will reveal the password. Would you like to continue? (yes/[no]): ",
function (resp) {
if (resp && resp.match(/^y(es)?$/i))
- return editor.editFieldExternally(true);
+ editor.editFieldExternally(true);
});
return;
}
@@ -360,7 +360,7 @@ const Editor = Module("editor", {
else if (typeof GetCurrentEditor == "function") // Thunderbird composer
text = GetCurrentEditor().outputToString("text/plain", 2);
else
- return false;
+ return;
let oldBg, tmpBg;
try {
@@ -395,7 +395,7 @@ const Editor = Module("editor", {
}
}, this);
if (res == false)
- throw "Couldn't create temporary file";
+ throw Error("Couldn't create temporary file");
}
catch (e) {
// Errors are unlikely, and our error messages won't
@@ -415,7 +415,7 @@ const Editor = Module("editor", {
})();
}
- return true;
+ return;
},
// Abbreviations {{{
@@ -520,7 +520,7 @@ const Editor = Module("editor", {
expandAbbreviation: function (filter) {
let textbox = Editor.getEditor();
if (!textbox)
- return;
+ return false;
let text = textbox.value;
let currStart = textbox.selectionStart;
let currEnd = textbox.selectionEnd;
@@ -648,8 +648,7 @@ const Editor = Module("editor", {
return null;
return ed.controllers.getControllerForCommand("cmd_beginLine");
- },
-
+ }
}, {
commands: function () {
// mode = "i" -> add :iabbrev, :iabclear and :iunabbrev commands
@@ -861,7 +860,7 @@ const Editor = Module("editor", {
[""], "Insert clipboard/selection",
function () { editor.pasteClipboard(); });
- mappings.add([modes.INSERT, modes.TEXTAREA, modes.COMPOSE],
+ mappings.add(modes.getCharModes("i"),
[""], "Edit text field with an external editor",
function () { editor.editFieldExternally(); });
@@ -950,12 +949,9 @@ const Editor = Module("editor", {
mappings.add([modes.VISUAL],
["c", "s"], "Change selected text",
function (count) {
- if (modes.extended & modes.TEXTAREA) {
- editor.executeCommand("cmd_cut");
- modes.set(modes.INSERT, modes.TEXTAREA);
- }
- else
- liberator.beep();
+ liberator.assert(modes.extended & modes.TEXTAREA);
+ editor.executeCommand("cmd_cut");
+ modes.set(modes.INSERT, modes.TEXTAREA);
});
mappings.add([modes.VISUAL],
@@ -978,24 +974,20 @@ const Editor = Module("editor", {
}
else {
let sel = window.content.document.getSelection();
- if (sel)
- util.copyToClipboard(sel, true);
- else
- liberator.beep();
+ liberator.assert(sel);
+ util.copyToClipboard(sel, true);
}
});
mappings.add([modes.VISUAL, modes.TEXTAREA],
["p"], "Paste clipboard contents",
function (count) {
- if (!(modes.extended & modes.CARET)) {
- if (!count) count = 1;
- while (count--)
- editor.executeCommand("cmd_paste");
- liberator.mode = modes.TEXTAREA;
- }
- else
- liberator.beep();
+ liberator.assert(!(modes.extended & modes.CARET));
+ if (!count)
+ count = 1;
+ while (count--)
+ editor.executeCommand("cmd_paste");
+ liberator.mode = modes.TEXTAREA;
});
// finding characters
@@ -1047,8 +1039,8 @@ const Editor = Module("editor", {
while (count-- > 0) {
let text = Editor.getEditor().value;
let pos = Editor.getEditor().selectionStart;
- if (pos >= text.length)
- return void liberator.beep();
+ liberator.assert(pos < text.length);
+
let chr = text[pos];
Editor.getEditor().value = text.substring(0, pos) +
(chr == chr.toLocaleLowerCase() ? chr.toLocaleUpperCase() : chr.toLocaleLowerCase()) +
diff --git a/common/content/events.js b/common/content/events.js
index fdad17bf..09fbbdb2 100644
--- a/common/content/events.js
+++ b/common/content/events.js
@@ -417,8 +417,7 @@ const Events = Module("events", {
let re = RegExp("<.*?>?>|[^<]|<(?!.*>)", "g");
let match;
-
- while (match = re.exec(input)) {
+ while ((match = re.exec(input))) {
let evt_str = match[0];
let evt_obj = { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false,
keyCode: 0, charCode: 0, type: "keypress" };
@@ -560,7 +559,7 @@ const Events = Module("events", {
}
}
if (key == null)
- return;
+ return null;
}
else if (event.type == "click" || event.type == "dblclick") {
if (event.shiftKey)
@@ -697,8 +696,10 @@ const Events = Module("events", {
return;
}
- if (config.focusChange)
- return void config.focusChange(win);
+ if (config.focusChange) {
+ config.focusChange(win);
+ return;
+ }
let urlbar = document.getElementById("urlbar");
if (elem == null && urlbar && urlbar.inputField == this._lastFocus)
@@ -828,7 +829,8 @@ const Events = Module("events", {
modes.isRecording = false;
liberator.log("Recorded " + this._currentMacro + ": " + this._macros.get(this._currentMacro), 9);
liberator.echomsg("Recorded macro '" + this._currentMacro + "'");
- return void killEvent();
+ killEvent();
+ return;
}
else if (!mappings.hasMap(liberator.mode, this._input.buffer + key))
this._macros.set(this._currentMacro, this._macros.get(this._currentMacro) + key);
@@ -852,14 +854,15 @@ const Events = Module("events", {
else
events.duringFeed.push(event);
- return void killEvent();
+ killEvent();
+ return;
}
try {
let stop = false;
let win = document.commandDispatcher.focusedWindow;
- if (win && win.document && win.document.designMode == "on" && !config.isComposeWindow)
+ if (win && win.document && "designMode" in win.document && win.document.designMode == "on" && !config.isComposeWindow)
stop = true;
// menus have their own command handlers
if (modes.extended & modes.MENU)
@@ -889,7 +892,7 @@ const Events = Module("events", {
// just forward event without checking any mappings when the MOW is open
if (liberator.mode == modes.COMMAND_LINE && (modes.extended & modes.OUTPUT_MULTILINE)) {
commandline.onMultilineOutputEvent(event);
- return void killEvent();
+ throw killEvent();
}
// XXX: ugly hack for now pass certain keys to the host app as
@@ -907,7 +910,7 @@ const Events = Module("events", {
// custom mode...
if (liberator.mode == modes.CUSTOM) {
plugins.onEvent(event);
- return void killEvent();
+ throw killEvent();
}
// All of these special cases for hint mode are driving
@@ -920,7 +923,7 @@ const Events = Module("events", {
|| (/^[0-9]$/.test(key) && !hints.escNumbers)) {
hints.onEvent(event);
this._input.buffer = "";
- return void killEvent();
+ throw killEvent();
}
// others are left to generate the 'input' event or handled by the host app
@@ -992,7 +995,7 @@ const Events = Module("events", {
}
else {
if (modes.isReplaying && !this.waitForPageLoad())
- return void killEvent();
+ throw killEvent();
let ret = map.execute(null, this._input.count);
if (map.route && ret)
@@ -1031,7 +1034,8 @@ const Events = Module("events", {
killEvent();
}
catch (e) {
- liberator.reportError(e);
+ if (e !== undefined)
+ liberator.reportError(e);
}
finally {
let motionMap = (this._input.pendingMotionMap && this._input.pendingMotionMap.names[0]) || "";
@@ -1084,8 +1088,7 @@ const Events = Module("events", {
elem instanceof HTMLIsIndexElement ||
elem instanceof HTMLObjectElement ||
elem instanceof HTMLEmbedElement);
- },
-
+ }
}, {
commands: function () {
commands.add(["delmac[ros]"],
@@ -1124,7 +1127,7 @@ const Events = Module("events", {
function () { events.onEscape(); });
// add the ":" mapping in all but insert mode mappings
- mappings.add([modes.NORMAL, modes.PLAYER, modes.VISUAL, modes.HINTS, modes.MESSAGE, modes.COMPOSE, modes.CARET, modes.TEXTAREA],
+ mappings.add(modes.matchModes({ extended: false, input: false }),
[":"], "Enter command line mode",
function () { commandline.open(":", "", modes.EX); });
diff --git a/common/content/finder.js b/common/content/finder.js
index e67038c2..24efdc34 100644
--- a/common/content/finder.js
+++ b/common/content/finder.js
@@ -89,7 +89,7 @@ const Finder = Module("finder", {
let parent = elem.parentNode;
let child;
- while (child = elem.firstChild)
+ while ((child = elem.firstChild))
docfrag.appendChild(child);
parent.removeChild(elem);
@@ -783,7 +783,7 @@ const RangeFind = Class("RangeFind", {
this.lastRange = null;
this.lastString = word
var res;
- while (res = this.search(null, this.reverse, true))
+ while ((res = this.search(null, this.reverse, true)))
yield res;
}
finally {
@@ -791,7 +791,7 @@ const RangeFind = Class("RangeFind", {
}
},
- search: function (word, reverse, private) {
+ search: function (word, reverse, private_) {
this.wrapped = false;
this.finder.findBackwards = reverse ? !this.reverse : this.reverse;
let again = word == null;
@@ -801,7 +801,7 @@ const RangeFind = Class("RangeFind", {
word = word.toLowerCase();
if (!again && (word == "" || word.indexOf(this.lastString) != 0 || this.backward)) {
- if (!private)
+ if (!private_)
this.range.deselect();
if (word == "")
this.range.descroll()
@@ -816,7 +816,7 @@ const RangeFind = Class("RangeFind", {
let idx = this.range.index;
for (let i in this.backward ? util.range(idx + 1, 0, -1) : util.range(idx, this.ranges.length))
yield i;
- if (private)
+ if (private_)
return;
this.wrapped = true;
this.lastRange = null;
@@ -835,7 +835,7 @@ const RangeFind = Class("RangeFind", {
var range = this.finder.Find(word, this.range.range, start, this.range.range);
if (range)
break;
- if (!private) {
+ if (!private_) {
this.range.descroll();
this.range.deselect();
}
@@ -844,7 +844,7 @@ const RangeFind = Class("RangeFind", {
if (range)
this.lastRange = range.cloneRange();
- if (private)
+ if (private_)
return range;
this.lastString = word;
@@ -983,12 +983,13 @@ const RangeFind = Class("RangeFind", {
for (let shell in iter(config.browser.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem.typeAll, Ci.nsIDocShell.ENUMERATE_FORWARDS)))
if (shell.QueryInterface(nsIWebNavigation).document == this.document)
return this._docShell = shell;
+ throw Error();
},
get selectionController() this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Ci.nsISelectionController),
- get selection() this.selectionController.getSelection(Ci.nsISelectionController.SELECTION_NORMAL),
+ get selection() this.selectionController.getSelection(Ci.nsISelectionController.SELECTION_NORMAL)
}),
endpoint: function (range, before) {
range = range.cloneRange();
diff --git a/common/content/hints.js b/common/content/hints.js
index f3629a9b..757c7790 100644
--- a/common/content/hints.js
+++ b/common/content/hints.js
@@ -460,14 +460,15 @@ const Hints = Module("hints", {
return false;
}
+ // This "followhints" option is *too* confusing. For me, and
+ // presumably for users, too. --Kris
if (options["followhints"] > 0) {
if (!followFirst)
return false; // no return hit; don't examine uniqueness
// OK. return hit. But there's more than one hint, and
// there's no tab-selected current link. Do not follow in mode 2
- if (options["followhints"] == 2 && this._validHints.length > 1 && !this._hintNumber)
- return liberator.beep();
+ liberator.assert(options["followhints"] != 2 || this._validHints.length == 1 || this._hintNumber)
}
if (!followFirst) {
@@ -499,8 +500,7 @@ const Hints = Module("hints", {
_checkUnique: function () {
if (this._hintNumber == 0)
return;
- if (this._hintNumber > this._validHints.length)
- return void liberator.beep();
+ liberator.assert(this._hintNumber <= this._validHints.length);
// if we write a numeric part like 3, but we have 45 hints, only follow
// the hint after a timeout, as the user might have wanted to follow link 34
@@ -735,8 +735,8 @@ const Hints = Module("hints", {
*/
show: function (minor, filter, win) {
this._hintMode = this._hintModes[minor];
- if (!this._hintMode)
- return void liberator.beep();
+ liberator.assert(this._hintMode);
+
commandline.input(this._hintMode.prompt + ": ", null, { onChange: this.closure._onInput });
modes.extended = modes.HINTS;
@@ -820,7 +820,8 @@ const Hints = Module("hints", {
else {
this._usedTabKey = false;
this._hintNumber = 0;
- return void liberator.beep();
+ liberator.beep();
+ return;
}
break;
@@ -855,8 +856,7 @@ const Hints = Module("hints", {
}
this._showActiveHint(this._hintNumber, oldHintNumber || 1);
- if (this._hintNumber == 0)
- return void liberator.beep();
+ liberator.assert(this._hintNumber != 0);
this._checkUnique();
}
@@ -1022,7 +1022,8 @@ const Hints = Module("hints", {
return -1;
}
})(),
- Mode: new Struct("prompt", "action", "tags"),
+
+ Mode: new Struct("prompt", "action", "tags")
}, {
mappings: function () {
var myModes = config.browserModes;
diff --git a/common/content/history.js b/common/content/history.js
index 93a47cfb..8f3ae5c8 100644
--- a/common/content/history.js
+++ b/common/content/history.js
@@ -104,6 +104,7 @@ const History = Module("history", {
liberator.echoerr("E283: No history matching \"" + filter + "\"");
else
liberator.echoerr("No history set");
+ return null;
}
}, {
}, {
@@ -129,6 +130,7 @@ const History = Module("history", {
else
history.stepTo(-Math.max(args.count, 1));
}
+ return null;
},
{
argCount: "?",
@@ -167,6 +169,7 @@ const History = Module("history", {
else
history.stepTo(Math.max(args.count, 1));
}
+ return null;
},
{
argCount: "?",
diff --git a/common/content/io.js b/common/content/io.js
index c6550ba4..8e79ada6 100644
--- a/common/content/io.js
+++ b/common/content/io.js
@@ -28,6 +28,7 @@ const Script = Class("Script", {
if (dir.contains(file, false))
plugins[this.NAME] = this;
}
+ return this;
}
});
@@ -1038,6 +1039,7 @@ lookup:
return File(dir).readDirectory();
}
catch (e) {}
+ return [];
};
};
diff --git a/common/content/liberator.js b/common/content/liberator.js
index 1579e94d..433287fd 100644
--- a/common/content/liberator.js
+++ b/common/content/liberator.js
@@ -386,13 +386,12 @@ const Liberator = Module("liberator", {
// description --Kris
evalExpression: function (string) {
string = string.toString().replace(/^\s*/, "").replace(/\s*$/, "");
- let matches = string.match(/^&(\w+)/);
+ let matches = string.match(/^&(\w+)/);
if (matches) {
let opt = this.options.get(matches[1]);
- if (!opt)
- return void this.echoerr("E113: Unknown option: " + matches[1]);
+ liberator.assert(opt, "E113: Unknown option: " + matches[1]);
let type = opt.type;
let value = opt.getter();
@@ -403,14 +402,11 @@ const Liberator = Module("liberator", {
return value;
}
// String
- else if (matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/)) {
- if (matches)
- return matches[2].toString();
- else
- return void this.echoerr("E115: Missing quote: " + string);
+ else if ((matches = string.match(/^(['"])([^\1]*?[^\\]?)\1/))) {
+ return matches[2].toString();
}
// Number
- else if (matches = string.match(/^(\d+)$/))
+ else if ((matches = string.match(/^(\d+)$/)))
return parseInt(matches[1], 10);
let reference = this.variableReference(string);
@@ -419,8 +415,7 @@ const Liberator = Module("liberator", {
this.echoerr("E121: Undefined variable: " + string);
else
return reference[0][reference[1]];
-
- return;
+ return null;
},
/**
@@ -733,6 +728,9 @@ const Liberator = Module("liberator", {
open: function (urls, params, force) {
// convert the string to an array of converted URLs
// -> see util.stringToURLArray for more details
+ //
+ // This is strange. And counterintuitive. Is it really
+ // necessary? --Kris
if (typeof urls == "string") {
// rather switch to the tab instead of opening a new url in case of "12: Tab Title" like "urls"
if (liberator.has("tabs")) {
@@ -752,7 +750,7 @@ const Liberator = Module("liberator", {
if (resp && resp.match(/^y(es)?$/i))
liberator.open(urls, params, true);
});
- return true;
+ return;
}
let flags = 0;
@@ -777,40 +775,42 @@ const Liberator = Module("liberator", {
}
if (urls.length == 0)
- return false;
+ return;
let browser = config.browser;
function open(urls, where) {
- let url = Array.concat(urls)[0];
- let postdata = Array.concat(urls)[1];
+ try {
+ let url = Array.concat(urls)[0];
+ let postdata = Array.concat(urls)[1];
- // decide where to load the first url
- switch (where) {
- case liberator.CURRENT_TAB:
- browser.loadURIWithFlags(url, flags, null, null, postdata);
- break;
+ // decide where to load the first url
+ switch (where) {
+ case liberator.CURRENT_TAB:
+ browser.loadURIWithFlags(url, flags, null, null, postdata);
+ break;
- case liberator.NEW_BACKGROUND_TAB:
- case liberator.NEW_TAB:
- if (!liberator.has("tabs"))
- return open(urls, liberator.NEW_WINDOW);
+ case liberator.NEW_BACKGROUND_TAB:
+ case liberator.NEW_TAB:
+ if (!liberator.has("tabs")) {
+ open(urls, liberator.NEW_WINDOW);
+ return;
+ }
- options.withContext(function () {
- options.setPref("browser.tabs.loadInBackground", true);
- browser.loadOneTab(url, null, null, postdata, where == liberator.NEW_BACKGROUND_TAB);
- });
- break;
+ options.withContext(function () {
+ options.setPref("browser.tabs.loadInBackground", true);
+ browser.loadOneTab(url, null, null, postdata, where == liberator.NEW_BACKGROUND_TAB);
+ });
+ break;
- case liberator.NEW_WINDOW:
- window.open();
- let win = services.get("windowMediator").getMostRecentWindow("navigator:browser");
- win.loadURI(url, null, postdata);
- browser = win.getBrowser();
- break;
-
- default:
- throw Error("Invalid 'where' directive in liberator.open(...)");
+ case liberator.NEW_WINDOW:
+ window.open();
+ let win = services.get("windowMediator").getMostRecentWindow("navigator:browser");
+ win.loadURI(url, null, postdata);
+ browser = win.getBrowser();
+ break;
+ }
}
+ catch(e) {}
}
if (liberator.forceNewTab)
@@ -824,8 +824,6 @@ const Liberator = Module("liberator", {
open(url, where);
where = liberator.NEW_BACKGROUND_TAB;
}
-
- return true;
},
pluginFiles: {},
@@ -881,10 +879,15 @@ const Liberator = Module("liberator", {
return func.apply(self || this, Array.slice(arguments, 2));
}
catch (e) {
- if (e instanceof FailedAssertion)
- liberator.echoerr(e.message);
+ if (e instanceof FailedAssertion) {
+ if (e.message)
+ liberator.echoerr(e.message);
+ else
+ liberator.beep();
+ }
else
liberator.reportError(e);
+ return undefined;
}
},
@@ -1011,6 +1014,7 @@ const Liberator = Module("liberator", {
else
return [null, string, "g"];
}
+ throw Error("What the fuck?");
},
/**
@@ -1113,10 +1117,10 @@ const Liberator = Module("liberator", {
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 + "]");
+ let class_ = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
- if (class.length)
- styles.addSheet(true, "scrollbar", "*", class.join(", ") + " { visibility: collapse !important; }", true);
+ if (class_.length)
+ styles.addSheet(true, "scrollbar", "*", class_.join(", ") + " { visibility: collapse !important; }", true);
else
styles.removeSheet(true, "scrollbar");
options.safeSetPref("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2,
@@ -1247,7 +1251,7 @@ const Liberator = Module("liberator", {
{ argCount: "0" });
commands.add(["beep"],
- "Play a system beep",
+ "Play a system beep", // Play? Wrong word. Implies some kind of musicality. --Kris
function () { liberator.beep(); },
{ argCount: "0" });
diff --git a/common/content/mappings.js b/common/content/mappings.js
index 661075d1..bbe3fe8c 100644
--- a/common/content/mappings.js
+++ b/common/content/mappings.js
@@ -29,7 +29,7 @@
*/
const Map = Class("Map", {
init: function (modes, keys, description, action, extraInfo) {
- modes = Array.concat(modes);
+ modes = Array.concat(modes).map(function (m) isobject(m) ? m.mask : m);
if (!extraInfo)
extraInfo = {};
diff --git a/common/content/marks.js b/common/content/marks.js
index fa10259e..ab4c4789 100644
--- a/common/content/marks.js
+++ b/common/content/marks.js
@@ -223,7 +223,7 @@ const Marks = Module("marks", {
for (let [mark, value] in this._localMarks)
for (let [, val] in Iterator(value))
yield [mark, val];
- },
+ }
}, {
markToString: function markToString(name, mark) {
@@ -234,7 +234,8 @@ const Marks = Module("marks", {
},
isLocalMark: function isLocalMark(mark) /^['`a-z]$/.test(mark),
- isURLMark: function isURLMark(mark) /^[A-Z0-9]$/.test(mark),
+
+ isURLMark: function isURLMark(mark) /^[A-Z0-9]$/.test(mark)
}, {
events: function () {
let appContent = document.getElementById("appcontent");
@@ -247,9 +248,7 @@ const Marks = Module("marks", {
mappings.add(myModes,
["m"], "Set mark at the cursor position",
function (arg) {
- if (/[^a-zA-Z]/.test(arg))
- return void liberator.beep();
-
+ liberator.assert(/^[a-zA-Z]$/.test(arg));
marks.add(arg);
},
{ arg: true });
@@ -271,28 +270,18 @@ const Marks = Module("marks", {
liberator.assert( special || args, "E471: Argument required");
liberator.assert(!special || !args, "E474: Invalid argument");
- let matches;
- if (matches = args.match(/(?:(?:^|[^a-zA-Z0-9])-|-(?:$|[^a-zA-Z0-9])|[^a-zA-Z0-9 -]).*/)) {
- // NOTE: this currently differs from Vim's behavior which
- // deletes any valid marks in the arg list, up to the first
- // invalid arg, as well as giving the error message.
- liberator.echoerr("E475: Invalid argument: " + matches[0]);
- return;
- }
+ let matches = args.match(/(?:(?:^|[^a-zA-Z0-9])-|-(?:$|[^a-zA-Z0-9])|[^a-zA-Z0-9 -]).*/);
+ // NOTE: this currently differs from Vim's behavior which
+ // deletes any valid marks in the arg list, up to the first
+ // invalid arg, as well as giving the error message.
+ liberator.assert(!matches, "E475: Invalid argument: " + matches[0]);
+
// check for illegal ranges - only allow a-z A-Z 0-9
- if (matches = args.match(/[a-zA-Z0-9]-[a-zA-Z0-9]/g)) {
- for (let i = 0; i < matches.length; i++) {
- let start = matches[i][0];
- let end = matches[i][2];
- if (/[a-z]/.test(start) != /[a-z]/.test(end) ||
- /[A-Z]/.test(start) != /[A-Z]/.test(end) ||
- /[0-9]/.test(start) != /[0-9]/.test(end) ||
- start > end)
- {
- liberator.echoerr("E475: Invalid argument: " + args.match(matches[i] + ".*")[0]);
- return;
- }
- }
+ if ((matches = args.match(/[a-zA-Z0-9]-[a-zA-Z0-9]/g))) {
+ for (let match in values(matches))
+ liberator.assert(/[a-z]-[a-z]|[A-Z]-[A-Z]|[0-9]-[0-9]/.test(match) &&
+ match[0] <= match[2],
+ "E475: Invalid argument: " + args.match(match + ".*")[0]);
}
marks.remove(args, special);
diff --git a/common/content/modes.js b/common/content/modes.js
index 3de622f1..e6048bea 100644
--- a/common/content/modes.js
+++ b/common/content/modes.js
@@ -21,7 +21,7 @@ const Modes = Module("modes", {
this._modeStack = [];
- this._mainModes = [self.NONE];
+ this._mainModes = [this.NONE];
this._lastMode = 0;
this._modeMap = {};
@@ -153,6 +153,10 @@ const Modes = Module("modes", {
getMode: function (name) this._modeMap[name],
+ getCharModes: function (chr) [m for (m in values(this._modeMap)) if (m.char == chr)],
+
+ matchModes: function (obj) [m for (m in values(this._modeMap)) if (array(keys(obj)).every(function (k) obj[k] == (m[k] || false)))],
+
// show the current mode string in the command line
show: function () {
let msg = "";
diff --git a/common/content/modules.js b/common/content/modules.js
index 5a5513da..40deeca9 100644
--- a/common/content/modules.js
+++ b/common/content/modules.js
@@ -14,7 +14,7 @@ const ModuleBase = Class("ModuleBase", {
*/
requires: [],
- toString: function () "[module " + this.constructor.name + "]",
+ toString: function () "[module " + this.constructor.name + "]"
});
/**
@@ -87,11 +87,17 @@ window.addEventListener("load", function () {
load(Module.constructors[dep], module.name);
dump("Load" + (isstring(prereq) ? " " + prereq + " dependency: " : ": ") + module.name);
- loaded.push(module.name);
modules[module.name] = module();
+ loaded.push(module.name);
function init(mod, module)
function () module.INIT[mod].call(modules[module.name], modules[mod]);
+ function init(mod, module)
+ function () {
+ if (!(mod in modules))
+ dump(mod + " not in modules");
+ return module.INIT[mod].call(modules[module.name], modules[mod]);
+ }
for (let mod in values(loaded)) {
try {
if (mod in module.INIT)
diff --git a/common/content/options.js b/common/content/options.js
index f55bce5f..d6197288 100644
--- a/common/content/options.js
+++ b/common/content/options.js
@@ -150,7 +150,7 @@ const Option = Class("Option", {
set: function (newValue, scope) {
scope = scope || this.scope;
if ((scope & this.scope) == 0) // option doesn't exist in this scope
- return null;
+ return;
if (this.setter)
newValue = liberator.trapErrors(this.setter, this, newValue);
@@ -308,6 +308,7 @@ const Option = Class("Option", {
if (!this.isValidValue(newValue))
return "E474: Invalid argument: " + values;
this.setValues(newValue, scope);
+ return null;
},
// Properties {{{2
@@ -903,7 +904,7 @@ const Options = Module("options", {
}
}, {
SAVED: "extensions.liberator.saved.",
- OLD_SAVED: "liberator.saved.",
+ OLD_SAVED: "liberator.saved."
}, {
commandline: function () {
// TODO: maybe reset in .destroy()?
@@ -1035,7 +1036,7 @@ const Options = Module("options", {
[options._loadPreference(filter, null, false), "Current Value"],
[options._loadPreference(filter, null, true), "Default Value"]
].filter(function ([k]) k != null);
- return;
+ return null;
}
return completion.preference(context);
@@ -1050,7 +1051,7 @@ const Options = Module("options", {
return completion.option(context, opt.scope);
}
else if (prefix == "no")
- return;
+ return null;
if (prefix)
context.advance(prefix.length);
@@ -1064,7 +1065,7 @@ const Options = Module("options", {
}
if (opt.get || opt.reset || !option || prefix)
- return;
+ return null;
if (!opt.value) {
context.fork("default", 0, this, function (context) {
@@ -1076,7 +1077,7 @@ const Options = Module("options", {
});
}
- context.fork("values", 0, completion, "optionValue", opt.name, opt.operator);
+ return context.fork("values", 0, completion, "optionValue", opt.name, opt.operator);
}
commands.add(["let"],
@@ -1106,16 +1107,17 @@ const Options = Module("options", {
return;
}
- let matches;
// 1 - type, 2 - name, 3 - +-., 4 - expr
- if (matches = args.match(/([$@&])?([\w:]+)\s*([-+.])?=\s*(.+)/)) {
- if (!matches[1]) {
- let reference = liberator.variableReference(matches[2]);
- liberator.assert(reference[0] || !matches[3],
- "E121: Undefined variable: " + matches[2]);
+ let matches = args.match(/([$@&])?([\w:]+)\s*([-+.])?=\s*(.+)/);
+ if (matches) {
+ let [, type, name, stuff, expr] = matches;
+ if (!type) {
+ let reference = liberator.variableReference(name);
+ liberator.assert(reference[0] || !stuff,
+ "E121: Undefined variable: " + name);
- let expr = liberator.evalExpression(matches[4]);
- liberator.assert(expr !== undefined, "E15: Invalid expression: " + matches[4]);
+ let expr = liberator.evalExpression(expr);
+ liberator.assert(expr !== undefined, "E15: Invalid expression: " + expr);
if (!reference[0]) {
if (reference[2] == "g")
@@ -1124,12 +1126,12 @@ const Options = Module("options", {
return; // for now
}
- if (matches[3]) {
- if (matches[3] == "+")
+ if (stuff) {
+ if (stuff == "+")
reference[0][reference[1]] += expr;
- else if (matches[3] == "-")
+ else if (stuff == "-")
reference[0][reference[1]] -= expr;
- else if (matches[3] == ".")
+ else if (stuff == ".")
reference[0][reference[1]] += expr.toString();
}
@@ -1138,7 +1140,7 @@ const Options = Module("options", {
}
}
// 1 - name
- else if (matches = args.match(/^\s*([\w:]+)\s*$/)) {
+ else if ((matches = args.match(/^\s*([\w:]+)\s*$/))) {
let reference = liberator.variableReference(matches[1]);
liberator.assert(reference[0], "E121: Undefined variable: " + matches[1]);
diff --git a/common/content/quickmarks.js b/common/content/quickmarks.js
index 68823f07..b6d6914b 100644
--- a/common/content/quickmarks.js
+++ b/common/content/quickmarks.js
@@ -161,9 +161,7 @@ const QuickMarks = Module("quickmarks", {
mappings.add(myModes,
["M"], "Add new QuickMark for current URL",
function (arg) {
- if (/[^a-zA-Z0-9]/.test(arg))
- return void liberator.beep();
-
+ liberator.assert(/^[a-zA-Z0-9]$/.test(arg));
quickmarks.add(arg, buffer.URL);
},
{ arg: true });
diff --git a/common/content/sanitizer.js b/common/content/sanitizer.js
index 12a04d18..05765508 100644
--- a/common/content/sanitizer.js
+++ b/common/content/sanitizer.js
@@ -79,24 +79,23 @@ const Sanitizer = Module("sanitizer", {
return errors;
},
- get prefNames() util.Array.flatten([this.prefDomain, this.prefDomain2].map(options.allPrefs)),
+ get prefNames() util.Array.flatten([this.prefDomain, this.prefDomain2].map(options.allPrefs))
}, {
prefArgList: [["commandLine", "commandline"],
["offlineApps", "offlineapps"],
["siteSettings", "sitesettings"]],
prefToArg: function (pref) {
- let pref = pref.replace(/.*\./, "");
+ pref = pref.replace(/.*\./, "");
return util.Array.toObject(Sanitizer.prefArgList)[pref] || pref;
},
- argToPref: function (arg) [k for ([k, v] in values(Sanitizer.prefArgList)) if (v == arg)][0] || arg,
+ argToPref: function (arg) [k for ([k, v] in values(Sanitizer.prefArgList)) if (v == arg)][0] || arg
}, {
commands: function () {
commands.add(["sa[nitize]"],
"Clear private data",
function (args) {
- if (options['private'])
- return void liberator.echomsg("Cannot sanitize items in private mode");
+ liberator.assert(!options['private'], "Cannot sanitize items in private mode");
let timespan = args["-timespan"] || options["sanitizetimespan"];
diff --git a/common/content/services.js b/common/content/services.js
index 8b5a4189..61d86959 100644
--- a/common/content/services.js
+++ b/common/content/services.js
@@ -61,6 +61,7 @@ const Services = Module("services", {
catch (e) {
// liberator.log() is not defined at this time, so just dump any error
dump("Service creation failed for '" + classes + "': " + e + "\n");
+ return null;
}
},
@@ -74,8 +75,8 @@ const Services = Module("services", {
* @param {string} meth The name of the function used to instanciate
* the service.
*/
- add: function (name, class, ifaces, meth) {
- return this.services[name] = this._create(class, ifaces, meth);
+ add: function (name, class_, ifaces, meth) {
+ return this.services[name] = this._create(class_, ifaces, meth);
},
/**
@@ -86,9 +87,9 @@ const Services = Module("services", {
* @param {nsISupports|nsISupports[]} ifaces The interface or array of
* interfaces implemented by this class.
*/
- addClass: function (name, class, ifaces) {
+ addClass: function (name, class_, ifaces) {
const self = this;
- return this.classes[name] = function () self._create(class, ifaces, "createInstance");
+ return this.classes[name] = function () self._create(class_, ifaces, "createInstance");
},
/**
diff --git a/common/content/statusline.js b/common/content/statusline.js
index 3cdf3e0f..9214b75d 100644
--- a/common/content/statusline.js
+++ b/common/content/statusline.js
@@ -173,8 +173,10 @@ const StatusLine = Module("statusline", {
*/
updateTabCount: function updateTabCount(delayed) {
if (liberator.has("tabs")) {
- if (delayed)
- return void this.setTimeout(function () this.updateTabCount(false), 0);
+ if (delayed) {
+ this.setTimeout(function () this.updateTabCount(false), 0);
+ return;
+ }
// update the ordinal which is used for numbered tabs
if (options.get("guioptions").has("n", "N"))
diff --git a/common/content/style.js b/common/content/style.js
index 233527ae..2fb64d64 100644
--- a/common/content/style.js
+++ b/common/content/style.js
@@ -256,10 +256,10 @@ function Highlights(name, store) {
this.get = function (k) highlight[k];
this.set = function (key, newStyle, force, append) {
- let [, class, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/);
+ let [, class_, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/);
- if (!(class in highlight))
- return "Unknown highlight keyword: " + class;
+ if (!(class_ in highlight))
+ return "Unknown highlight keyword: " + class_;
let style = highlight[key] || new Highlight(key);
styles.removeSheet(true, style.selector);
@@ -289,6 +289,7 @@ function Highlights(name, store) {
}
style.value = newStyle;
highlight[style.class] = style;
+ return null;
};
/**
@@ -296,10 +297,10 @@ function Highlights(name, store) {
*
* @param {string} class
*/
- this.selector = function (class) {
- let [, hl, rest] = class.match(/^(\w*)(.*)/);
+ this.selector = function (class_) {
+ let [, hl, rest] = class_.match(/^(\w*)(.*)/);
let pattern = "[liberator|highlight~=" + hl + "]"
- if (highlight[hl] && highlight[hl].class != class)
+ if (highlight[hl] && highlight[hl].class != class_)
pattern = highlight[hl].selector;
return pattern + rest;
};
@@ -331,9 +332,9 @@ function Highlights(name, store) {
if (old && old.value != old.default)
style.value = old.value;
});
- for (let [class, hl] in Iterator(highlight)) {
+ for (let [class_, hl] in Iterator(highlight)) {
if (hl.value == hl.default)
- this.set(class);
+ this.set(class_);
}
};
this.loadCSS(this.CSS);
@@ -509,7 +510,7 @@ function Styles(name, store) {
if (!matches)
matches = this.findSheets(system, name, filter, css, index);
if (matches.length == 0)
- return;
+ return null;
for (let [, sheet] in Iterator(matches.reverse())) {
sheet.enabled = false;
@@ -755,8 +756,7 @@ Module("highlight", {
args.shift();
let [key, css] = args;
- if (clear && css)
- return liberator.echo("E488: Trailing characters");
+ liberator.assert(!(clear && css), "E488: Trailing characters");
if (!css && !clear) {
// List matching keys
@@ -772,10 +772,12 @@ Module("highlight", {
return;
}
if (!key && clear)
- return highlight.clear();
- let error = highlight.set(key, css, clear, "-append" in args);
- if (error)
- liberator.echoerr(error);
+ highlight.clear();
+ else {
+ let error = highlight.set(key, css, clear, "-append" in args);
+ if (error)
+ liberator.echoerr(error);
+ }
},
{
// TODO: add this as a standard highlight completion function?
diff --git a/common/content/tabs.js b/common/content/tabs.js
index 5b44d4a2..3d02e627 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -310,8 +310,9 @@ const Tabs = Module("tabs", {
let index = Tabs.indexFromSpec(spec, wrap);
// FIXME:
if (index == -1)
- return void liberator.beep();
- config.tabbrowser.mTabContainer.selectedIndex = index;
+ liberator.beep();
+ else
+ config.tabbrowser.mTabContainer.selectedIndex = index;
},
/**
@@ -885,13 +886,15 @@ const Tabs = Module("tabs", {
else
args = args.count || 0;
- let m;
- if (m = /^(\d+)(:|$)/.exec(args || '1'))
+ let m = /^(\d+)(:|$)/.exec(args || '1');
+ if (m)
window.undoCloseTab(Number(m[1]) - 1);
else if (args) {
for (let [i, item] in Iterator(tabs.closedTabs))
- if (item.state.entries[item.state.index - 1].url == args)
- return void window.undoCloseTab(i);
+ if (item.state.entries[item.state.index - 1].url == args) {
+ window.undoCloseTab(i);
+ return;
+ }
liberator.echoerr("Exxx: No matching closed tab");
}
@@ -1064,7 +1067,7 @@ const Tabs = Module("tabs", {
["quickmark", "go and gn mappings"],
["tabopen", ":tabopen[!] command"],
["paste", "P and gP mappings"]
- ],
+ ]
});
options.add(["newtab"],
diff --git a/common/content/template.js b/common/content/template.js
index 116f0d54..bd5edf76 100644
--- a/common/content/template.js
+++ b/common/content/template.js
@@ -263,6 +263,7 @@ const Template = Module("template", {
//
if (table.tr.length() > 1)
return table;
+ return XML();
},
tabular: function tabular(headings, style, iter) {
diff --git a/common/content/util.js b/common/content/util.js
index c02dfce2..65420f9b 100644
--- a/common/content/util.js
+++ b/common/content/util.js
@@ -343,7 +343,7 @@ const Util = Module("util", {
addDataEntry("help.css", data.replace(/chrome:[^ ")]+\//g, ""));
let re = /(chrome:[^ ");]+\/)([^ ");]+)/g;
- while (m = re.exec(data))
+ while ((m = re.exec(data)))
chrome[m[0]] = m[2];
for (let [uri, leaf] in Iterator(chrome))
@@ -378,6 +378,7 @@ const Util = Module("util", {
}
catch (e) {
liberator.log("Error opening " + url + ": " + e, 1);
+ return null;
}
},
@@ -407,7 +408,6 @@ const Util = Module("util", {
return {
xhtml: "http://www.w3.org/1999/xhtml",
xhtml2: "http://www.w3.org/2002/06/xhtml2",
- liberator: NS.uri,
liberator: NS.uri
}[prefix] || null;
},
@@ -756,6 +756,8 @@ const Util = Module("util", {
if (nodes && node.@key)
nodes[node.@key] = domnode;
return domnode;
+ default:
+ return null;
}
}
}, {
@@ -860,7 +862,7 @@ const Util = Module("util", {
}
return ret;
}
- }),
+ })
});
// vim: set fdm=marker sw=4 ts=4 et:
diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm
index 6bf0bd7a..287c6189 100644
--- a/common/modules/storage.jsm
+++ b/common/modules/storage.jsm
@@ -201,7 +201,7 @@ function ObjectStore(name, store, load, options) {
return ret;
};
- this.get = function get(val) object[val];
+ this.get = function get(val, default_) val in object ? object[val] : default_;
this.clear = function () {
object = {};
@@ -334,8 +334,9 @@ var storage = {
return;
this.removeDeadObservers();
// Safe, since we have our own Array object here.
- for each (let observer in observers[key])
- observer.callback.get()(key, event, arg);
+ if (key in observers)
+ for each (let observer in observers[key])
+ observer.callback.get()(key, event, arg);
timers[key].tell();
},