diff --git a/content/addressbook.js b/content/addressbook.js index 7b0674b5..985d36ef 100644 --- a/content/addressbook.js +++ b/content/addressbook.js @@ -193,10 +193,9 @@ liberator.Addressbook = function () //{{{ { // Now we have to create a new message var args = {}; - args.to = addresses.map(function (address) - { - return "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""; - }).join(", "); + args.to = addresses.map( + function (address) "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\"" + ).join(", "); liberator.mail.composeNewMail(args); } diff --git a/content/bookmarks.js b/content/bookmarks.js index 9a588249..e4d61d12 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -191,10 +191,7 @@ liberator.Bookmarks = function () //{{{ "Set the default search engine", "string", "google", { - completer: function (filter) - { - return liberator.completion.url("", "s")[1]; - }, + completer: function (filter) liberator.completion.url("", "s")[1], validator: function (value) { return liberator.completion.url("", "s")[1].some(function (s) s[0] == value); @@ -290,7 +287,7 @@ liberator.Bookmarks = function () //{{{ liberator.bookmarks.list(args.arguments.join(" "), args["-tags"] || [], special); }, { - completer: function (filter) { return [0, liberator.bookmarks.get(filter)]; }, + completer: function (filter) [0, liberator.bookmarks.get(filter)], options: [[["-tags", "-T"], liberator.commands.OPTION_LIST]] }); @@ -306,7 +303,7 @@ liberator.Bookmarks = function () //{{{ liberator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", liberator.commandline.FORCE_SINGLELINE); }, { - completer: function (filter) { return [0, liberator.bookmarks.get(filter)]; } + completer: function (filter) [0, liberator.bookmarks.get(filter)] }); /////////////////////////////////////////////////////////////////////////////}}} @@ -431,7 +428,7 @@ liberator.Bookmarks = function () //{{{ var newAlias = alias; for (let j = 1; j <= 10; j++) // <=10 is intentional { - if (!searchEngines.some(function (item) { return (item[0] == newAlias); })) + if (!searchEngines.some(function (item) (item[0] == newAlias))) break; newAlias = alias + j; @@ -551,7 +548,7 @@ liberator.History = function () //{{{ var cachedHistory = []; // add pages here after loading the initial Places history if (liberator.options["preload"]) - setTimeout(function () { load(); }, 100); + setTimeout(function () load(), 100); function load() { @@ -704,7 +701,9 @@ liberator.History = function () //{{{ liberator.commands.add(["hist[ory]", "hs"], "Show recently visited URLs", function (args, special) { liberator.history.list(args, special); }, - { completer: function (filter) { return [0, liberator.history.get(filter)]; } }); + { + completer: function (filter) [0, liberator.history.get(filter)] + }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -735,7 +734,7 @@ liberator.History = function () //{{{ cachedHistory = []; } else - cachedHistory = cachedHistory.filter(function (elem) { return elem[0] != url; }); + cachedHistory = cachedHistory.filter(function (elem) elem[0] != url); cachedHistory.unshift([url, title || "[No title]"]); return true; diff --git a/content/buffer.js b/content/buffer.js index 7aca5fef..9f60ab24 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -154,7 +154,7 @@ liberator.Buffer = function () //{{{ window.fullScreen = value; return value; }, - getter: function () { return window.fullScreen; } + getter: function () window.fullScreen }); liberator.options.add(["nextpattern"], @@ -175,21 +175,21 @@ liberator.Buffer = function () //{{{ ["m", "Meta tags"] ]; }, - validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); } + validator: function (value) !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1) }); liberator.options.add(["scroll", "scr"], "Number of lines to scroll with and commands", "number", 0, { - validator: function (value) { return value >= 0; } + validator: function (value) value >= 0 }); liberator.options.add(["showstatuslinks", "ssli"], "Show the destination of the link under the cursor in the status bar", "number", 1, { - validator: function (value) { return (value >= 0 && value <= 2); }, + validator: function (value) value >= 0 && value <= 2, completer: function (filter) { return [ @@ -509,7 +509,7 @@ liberator.Buffer = function () //{{{ "Select the author style sheet to apply", function (args) { - var titles = liberator.buffer.alternateStyleSheets.map(function (stylesheet) { return stylesheet.title; }); + var titles = liberator.buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title); if (args && titles.indexOf(args) == -1) { @@ -523,7 +523,7 @@ liberator.Buffer = function () //{{{ stylesheetSwitchAll(window.content, args); }, { - completer: function (filter) { return liberator.completion.stylesheet(filter); } + completer: function (filter) liberator.completion.stylesheet(filter) }); liberator.commands.add(["re[load]"], @@ -611,9 +611,9 @@ liberator.Buffer = function () //{{{ { var stylesheets = getAllStyleSheets(window.content); - stylesheets = stylesheets.filter(function (stylesheet) { - return /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title); - }); + stylesheets = stylesheets.filter( + function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title) + ); return stylesheets; }, @@ -1011,8 +1011,7 @@ liberator.Buffer = function () //{{{ var frames = []; // find all frames - depth-first search - (function (frame) - { + (function (frame) { if (frame.document.body.localName.toLowerCase() == "body") frames.push(frame); Array.forEach(frame.frames, arguments.callee); @@ -1025,9 +1024,9 @@ liberator.Buffer = function () //{{{ // TODO: find a better way to do this - walking the tree is too slow var start = document.commandDispatcher.focusedWindow; frames = frames.filter(function (frame) { - frame.focus(); - if (document.commandDispatcher.focusedWindow == frame) - return frame; + frame.focus(); + if (document.commandDispatcher.focusedWindow == frame) + return frame; }); start.focus(); @@ -1089,7 +1088,7 @@ liberator.Buffer = function () //{{{ doc.body.appendChild(indicator); // remove the frame indicator - setTimeout(function () { doc.body.removeChild(indicator); }, 500); + setTimeout(function () doc.body.removeChild(indicator), 500); }, // similar to pageInfo @@ -1301,7 +1300,7 @@ liberator.Buffer = function () //{{{ } // sort: ignore-case - tmpSort.sort(function (a, b) { return a.toLowerCase() > b.toLowerCase() ? 1 : -1; }); + tmpSort.sort(function (a, b) a.toLowerCase() > b.toLowerCase() ? 1 : -1); for (let i = 0; i < tmpSort.length; i++) pageMeta.push([tmpDict[tmpSort[i]][0], liberator.util.highlightURL(tmpDict[tmpSort[i]][1], false)]); } @@ -1745,8 +1744,8 @@ liberator.Marks = function () //{{{ if (filter.length > 0) { marks = marks.filter(function (mark) { - if (filter.indexOf(mark[0]) > -1) - return mark; + if (filter.indexOf(mark[0]) > -1) + return mark; }); if (marks.length == 0) { diff --git a/content/commands.js b/content/commands.js index d67a6428..18061c94 100644 --- a/content/commands.js +++ b/content/commands.js @@ -184,7 +184,7 @@ liberator.Commands = function () //{{{ __iterator__: function () { - var sorted = exCommands.sort(function (cmd1, cmd2) { return cmd1.name > cmd2.name; }); + var sorted = exCommands.sort(function (cmd1, cmd2) cmd1.name > cmd2.name); for (let i = 0; i < sorted.length; i++) yield sorted[i]; }, @@ -713,19 +713,14 @@ liberator.Commands = function () //{{{ /*options: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }], [["-bang"], OPTION_NOARG], [["-bar"], OPTION_NOARG]] */ - completer: function (filter) - { - return liberator.completion.userCommand(filter); - } + completer: function (filter) liberator.completion.userCommand(filter) }); commandManager.add(["comc[lear]"], "Delete all user-defined commands", function () { - liberator.commands.getUserCommands().forEach(function (cmd) { - liberator.commands.removeUserCommand(cmd.name); - }); + liberator.commands.getUserCommands().forEach(function (cmd) liberator.commands.removeUserCommand(cmd.name)); }, { argCount: "0" }); @@ -749,10 +744,7 @@ liberator.Commands = function () //{{{ }, { argCount: "1", - completer: function (filter) - { - return liberator.completion.userCommand(filter); - } + completer: function (filter) liberator.completion.userCommand(filter) }); //}}} diff --git a/content/completion.js b/content/completion.js index d12f6c9c..26721d33 100644 --- a/content/completion.js +++ b/content/completion.js @@ -79,9 +79,7 @@ liberator.Completion = function () //{{{ } else { - substrings = substrings.filter(function ($_) { - return complist[j].indexOf($_) >= 0; - }); + substrings = substrings.filter(function ($_) complist[j].indexOf($_) >= 0); } } break; @@ -119,9 +117,7 @@ liberator.Completion = function () //{{{ } else { - substrings = substrings.filter(function ($_) { - return complist[j].indexOf($_) == 0; - }); + substrings = substrings.filter(function ($_) complist[j].indexOf($_) == 0); } } break; @@ -199,7 +195,7 @@ liberator.Completion = function () //{{{ } if (!filter) - return [0, items.map(function ($_) { return [$_[0][0], $_[1]]; })]; + return [0, items.map(function ($_) [$_[0][0], $_[1]])]; return [0, buildLongestCommonSubstring(items, filter)]; }, @@ -365,8 +361,7 @@ liberator.Completion = function () //{{{ .getService(Components.interfaces.nsIBrowserSearchService); var completions = []; - engineList.forEach (function (name) - { + engineList.forEach(function (name) { var query = filter; var queryURI; var engine = ss.getEngineByAlias(name); @@ -390,8 +385,7 @@ liberator.Completion = function () //{{{ if (!results) return [0, []]; - results.forEach(function (item) - { + results.forEach(function (item) { // make sure we receive strings, otherwise a man-in-the-middle attack // could return objects which toString() method could be called to // execute untrusted code @@ -407,9 +401,9 @@ liberator.Completion = function () //{{{ stylesheet: function (filter) { - var completions = liberator.buffer.alternateStyleSheets.map(function (stylesheet) { - return [stylesheet.title, stylesheet.href || "inline"]; - }); + var completions = liberator.buffer.alternateStyleSheets.map( + function (stylesheet) [stylesheet.title, stylesheet.href || "inline"] + ); // unify split style sheets completions.forEach(function (stylesheet) { @@ -491,7 +485,7 @@ liberator.Completion = function () //{{{ userCommand: function (filter) { var commands = liberator.commands.getUserCommands(); - commands = commands.map(function (command) { return [command.name, ""]; }); + commands = commands.map(function (command) [command.name, ""]); return [0, this.filter(commands, filter)]; }, @@ -559,9 +553,9 @@ liberator.Completion = function () //{{{ { // no direct match of filter in the url, but still accept this item // if _all_ tokens of filter match either the url or the title - if (filter.split(/\s+/).every(function (token) { - return (url.indexOf(token) > -1 || title.indexOf(token) > -1); - })) + if (filter.split(/\s+/).every( + function (token) url.indexOf(token) > -1 || title.indexOf(token) > -1 + )) additionalCompletions.push(elem); continue; @@ -583,9 +577,7 @@ liberator.Completion = function () //{{{ } else { - substrings = substrings.filter(function ($_) { - return url.indexOf($_) >= 0; - }); + substrings = substrings.filter(function ($_) url.indexOf($_) >= 0); } filtered.push(elem); @@ -608,7 +600,7 @@ liberator.Completion = function () //{{{ itemsStr = itemsStr.toLowerCase(); } - if (filter.split(/\s+/).every(function (str) { return itemsStr.indexOf(str) > -1; })) + if (filter.split(/\s+/).every(function (str) itemsStr.indexOf(str) > -1)) return true; return false; diff --git a/content/events.js b/content/events.js index bbb64432..192d736a 100644 --- a/content/events.js +++ b/content/events.js @@ -225,12 +225,10 @@ liberator.AutoCommands = function () //{{{ trigger: function (auEvent, url) { - if (liberator.options["eventignore"].split(",").some(function (event) { - return event == "all" || event == auEvent; - })) - { + let events = liberator.options["eventignore"].split(","); + + if (events.some(function (event) event == "all" || event == auEvent)) return; - } if (autoCommands[auEvent]) { @@ -286,7 +284,7 @@ liberator.Events = function () //{{{ liberator.tabs.updateSelectionHistory(); if (liberator.options["focuscontent"]) - setTimeout(function () { liberator.focusContent(true); }, 10); // just make sure, that no widget has focus + setTimeout(function () liberator.focusContent(true), 10); // just make sure, that no widget has focus }, false); } @@ -642,7 +640,7 @@ liberator.Events = function () //{{{ liberator.events.deleteMacros(args); }, { - completer: function (filter) { return liberator.completion.macro(filter); } + completer: function (filter) liberator.completion.macro(filter) }); liberator.commands.add(["macros"], @@ -660,7 +658,7 @@ liberator.Events = function () //{{{ liberator.echo(str, liberator.commandline.FORCE_MULTILINE); }, { - completer: function (filter) { return liberator.completion.macro(filter); } + completer: function (filter) liberator.completion.macro(filter) }); liberator.commands.add(["pl[ay]"], @@ -673,7 +671,7 @@ liberator.Events = function () //{{{ liberator.events.playMacro(args); }, { - completer: function (filter) { return liberator.completion.macro(filter); } + completer: function (filter) liberator.completion.macro(filter) }); /////////////////////////////////////////////////////////////////////////////}}} @@ -1036,8 +1034,7 @@ liberator.Events = function () //{{{ { // FIXME: currently this hack is disabled to make macros work // this.wantsModeReset = true; - // setTimeout(function () - // { + // setTimeout(function () { // liberator.dump("cur: " + liberator.mode + "\n"); // if (liberator.events.wantsModeReset) // { @@ -1450,7 +1447,7 @@ liberator.Events = function () //{{{ // is not the focused frame if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow) { - setTimeout (function () { liberator.modes.reset(false); }, + setTimeout(function () liberator.modes.reset(false), liberator.mode == liberator.modes.HINTS ? 500 : 0); } } @@ -1489,7 +1486,7 @@ liberator.Events = function () //{{{ liberator.autocommands.trigger("LocationChange", liberator.buffer.URL); // if this is not delayed we get the position of the old buffer - setTimeout(function () { liberator.statusline.updateBufferPosition(); }, 100); + setTimeout(function () liberator.statusline.updateBufferPosition(), 100); }, // called at the very end of a page load asyncUpdateUI: function () diff --git a/content/find.js b/content/find.js index cb3a997a..422e42c4 100644 --- a/content/find.js +++ b/content/find.js @@ -346,7 +346,7 @@ liberator.Search = function () //{{{ found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; if (!found) - setTimeout(function () { liberator.echoerr("E486: Pattern not found: " + searchPattern); }, 0); + setTimeout(function () liberator.echoerr("E486: Pattern not found: " + searchPattern), 0); return found; }, @@ -417,7 +417,7 @@ liberator.Search = function () //{{{ // TODO: move to find() when reverse incremental searching is kludged in // need to find again for reverse searching if (backwards) - setTimeout(function () { liberator.search.findAgain(false); }, 0); + setTimeout(function () liberator.search.findAgain(false), 0); if (liberator.options["hlsearch"]) this.highlight(searchString); diff --git a/content/hints.js b/content/hints.js index 5a393488..e281fc7f 100644 --- a/content/hints.js +++ b/content/hints.js @@ -292,8 +292,8 @@ liberator.Hints = function () //{{{ // } // }, 100); setTimeout(function () { - firstElem.style.backgroundColor = firstElemBgColor; - firstElem.style.color = firstElemColor; + firstElem.style.backgroundColor = firstElemBgColor; + firstElem.style.color = firstElemColor; }, timeout); } } @@ -340,8 +340,8 @@ liberator.Hints = function () //{{{ case "V": liberator.buffer.viewSource(loc, true); break; case "w": liberator.buffer.followLink(elem, liberator.NEW_WINDOW); break; case "W": liberator.commandline.open(":", "winopen " + loc, liberator.modes.EX); break; - case "y": setTimeout(function () { liberator.util.copyToClipboard(loc, true); }, timeout + 50); break; - case "Y": setTimeout(function () { liberator.util.copyToClipboard(elem.textContent || "", true); }, timeout + 50); break; + case "y": setTimeout(function () liberator.util.copyToClipboard(loc, true), timeout + 50); break; + case "Y": setTimeout(function () liberator.util.copyToClipboard(elem.textContent || "", true), timeout + 50); break; default: liberator.echoerr("INTERNAL ERROR: unknown submode: " + submode); } @@ -568,7 +568,7 @@ liberator.Hints = function () //{{{ "Automatically follow non unique numerical hint", "number", 0, { - validator: function (value) { return value >= 0; } + validator: function (value) value >= 0 }); liberator.options.add(["linkfgcolor", "lfc"], @@ -591,11 +591,10 @@ liberator.Hints = function () //{{{ "How links are matched", "string", "contains", { - validator: function (value) { return /^(?:contains|wordstartswith|firstletters|custom)$/.test(value); }, + validator: function (value) /^(?:contains|wordstartswith|firstletters|custom)$/.test(value), completer: function (filter) { - return ["contains", "wordstartswith", "firstletters", "custom"] - .map(function (m){ return [m, ""]; }); + return ["contains", "wordstartswith", "firstletters", "custom"].map(function (m) [m, ""]); } }); @@ -807,7 +806,7 @@ liberator.Hints = function () //{{{ { var timeout = liberator.options["hinttimeout"]; if (timeout > 0) - activeTimeout = setTimeout(function () { processHints(true); }, timeout); + activeTimeout = setTimeout(function () processHints(true), timeout); return false; } diff --git a/content/io.js b/content/io.js index f429c9dd..039f8112 100644 --- a/content/io.js +++ b/content/io.js @@ -51,8 +51,8 @@ liberator.IO = function () //{{{ if (WINDOWS) { shell = "cmd.exe"; - // TODO: does setting 'shell' to "something containing sh" - // automatically update 'shellcmdflag' on Windows in Vim? + // TODO: setting 'shell' to "something containing sh" updates + // 'shellcmdflag' appropriately at startup on Windows in Vim shellcmdflag = "/c"; } else @@ -107,10 +107,7 @@ liberator.IO = function () //{{{ "Shell to use for executing :! and :run commands", "string", shell, { - setter: function (value) - { - return liberator.io.expandPath(value); - } + setter: function (value) liberator.io.expandPath(value) }); liberator.options.add(["shellcmdflag", "shcf"], @@ -155,9 +152,9 @@ liberator.IO = function () //{{{ var directories = liberator.options["cdpath"].replace(/^,$|^,,|,,$/, "").split(","); // empty 'cdpath' items mean the current directory - directories = directories.map(function (directory) { - return directory == "" ? liberator.io.getCurrentDirectory() : directory; - }); + directories = directories.map( + function (directory) directory == "" ? liberator.io.getCurrentDirectory() : directory + ); var directoryFound = false; @@ -183,7 +180,7 @@ liberator.IO = function () //{{{ } }, { - completer: function (filter) { return liberator.completion.file(filter, true); } + completer: function (filter) liberator.completion.file(filter, true) }); liberator.commands.add(["fini[sh]"], @@ -326,7 +323,7 @@ liberator.IO = function () //{{{ liberator.io.source(args, special); }, { - completer: function (filter) { return liberator.completion.file(filter, true); } + completer: function (filter) liberator.completion.file(filter, true) }); liberator.commands.add(["!", "run"], diff --git a/content/liberator.js b/content/liberator.js index 34114929..90b25221 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -55,8 +55,7 @@ const liberator = (function () //{{{ for (let option in guioptions) { - guioptions[option].forEach(function (elem) - { + guioptions[option].forEach(function (elem) { try { document.getElementById(elem).collapsed = (value.indexOf(option.toString()) < 0); @@ -98,7 +97,7 @@ const liberator = (function () //{{{ "Define which type of messages are logged", "number", 0, { - validator: function (value) { return (value >= 0 && value <= 9); } + validator: function (value) value >= 0 && value <= 9 }); liberator.options.add(["visualbell", "vb"], @@ -220,7 +219,7 @@ const liberator = (function () //{{{ var item = args.string; var items = getMenuItems(); - if (!items.some(function (i) { return i.fullMenuPath == item; })) + if (!items.some(function (i) i.fullMenuPath == item)) { liberator.echoerr("E334: Menu not found: " + item); return; @@ -236,9 +235,9 @@ const liberator = (function () //{{{ argCount: "+", // NOTE: single arg may contain unescaped whitespace completer: function (filter) { - var completions = getMenuItems().map(function (item) { - return [item.fullMenuPath, item.label]; - }); + var completions = getMenuItems().map( + function (item) [item.fullMenuPath, item.label] + ); return [0, liberator.completion.filter(completions, filter)]; } }); @@ -302,7 +301,7 @@ const liberator = (function () //{{{ liberator.help(args); }, { - completer: function (filter) { return getHelpCompletions(filter); } + completer: function (filter) getHelpCompletions(filter) }); liberator.commands.add(["javas[cript]", "js"], @@ -349,7 +348,7 @@ const liberator = (function () //{{{ } }, { - completer: function (filter) { return liberator.completion.javascript(filter); } + completer: function (filter) liberator.completion.javascript(filter) }); liberator.commands.add(["norm[al]"], @@ -545,8 +544,7 @@ const liberator = (function () //{{{ var guioptions = liberator.config.guioptions || {}; for (let option in guioptions) { - guioptions[option].forEach(function (elem) - { + guioptions[option].forEach(function (elem) { try { document.getElementById(elem).collapsed = true; @@ -625,7 +623,7 @@ const liberator = (function () //{{{ popup.height = box.height; popup.width = box.width; popup.openPopup(win, "overlap", 0, 0, false, false); - setTimeout(function () { popup.hidePopup(); }, 50); + setTimeout(function () popup.hidePopup(), 50); } } else @@ -793,7 +791,7 @@ const liberator = (function () //{{{ has: function (feature) { var features = liberator.config.features || []; - return features.some (function (feat) { return feat == feature; }); + return features.some(function (feat) feat == feature); }, help: function (topic) diff --git a/content/mail.js b/content/mail.js index 17e065aa..c17b9d10 100644 --- a/content/mail.js +++ b/content/mail.js @@ -139,12 +139,12 @@ liberator.Mail = function () //{{{ if (copy) { MsgCopyMessage(folders[0]); - setTimeout(function () { liberator.echo(count + " message(s) copied to " + folders[0].prettyName); }, 100); + setTimeout(function () liberator.echo(count + " message(s) copied to " + folders[0].prettyName), 100); } else { MsgMoveMessage(folders[0]); - setTimeout(function () { liberator.echo(count + " message(s) moved to " + folders[0].prettyName); }, 100); + setTimeout(function () liberator.echo(count + " message(s) moved to " + folders[0].prettyName), 100); } return true; } @@ -207,7 +207,7 @@ liberator.Mail = function () //{{{ "Set the layout of the mail window", "string", "inherit", { - validator: function (value) { return /^(classic|wide|vertical|inherit)$/.test(value); }, + validator: function (value) /^(classic|wide|vertical|inherit)$/.test(value), setter: function (value) { switch (value) @@ -276,32 +276,32 @@ liberator.Mail = function () //{{{ liberator.mappings.add(modes, ["j", ""], "Select next message", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, false, false, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["gj"], "Select next message, including closed threads", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, true, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, true, false, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["J", ""], "Select next unread message", - function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) !msg.isRead, true, true, false, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["k", ""], "Select previous message", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, false, true, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["gk"], "Select previous message", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, true, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, true, true, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["K"], "Select previous unread message", - function (count) { liberator.mail.selectMessage(function (msg) { return !msg.isRead; }, true, true, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) !msg.isRead, true, true, true, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["*"], @@ -311,7 +311,7 @@ liberator.Mail = function () //{{{ try { var author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase(); - liberator.mail.selectMessage(function (msg) { return msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0; }, true, true, false, count); + liberator.mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, count); } catch (e) { liberator.beep(); } }, @@ -324,7 +324,7 @@ liberator.Mail = function () //{{{ try { var author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase(); - liberator.mail.selectMessage(function (msg) { return msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0; }, true, true, true, count); + liberator.mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, count); } catch (e) { liberator.beep(); } }, @@ -376,12 +376,12 @@ liberator.Mail = function () //{{{ liberator.mappings.add([liberator.modes.MESSAGE], [""], "Select previous message", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, false, true, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add([liberator.modes.MESSAGE], [""], "Select next message", - function (count) { liberator.mail.selectMessage(function (msg) { return true; }, false, false, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) true, false, false, false, count); }, { flags: liberator.Mappings.flags.COUNT }); // UNDO/REDO @@ -432,22 +432,22 @@ liberator.Mail = function () //{{{ liberator.mappings.add(modes, ["]s"], "Select next starred message", - function (count) { liberator.mail.selectMessage(function (msg) { return msg.isFlagged; }, true, true, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) msg.isFlagged, true, true, false, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["[s"], "Select previous starred message", - function (count) { liberator.mail.selectMessage(function (msg) { return msg.isFlagged; }, true, true, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) msg.isFlagged, true, true, true, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["]a"], "Select next message with an attachment", - function (count) { liberator.mail.selectMessage(function (msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, false, count); }, + function (count) { liberator.mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, false, count); }, { flags: liberator.Mappings.flags.COUNT }); liberator.mappings.add(modes, ["[a"], "Select previous message with an attachment", - function (count) { liberator.mail.selectMessage(function (msg) { return gDBView.db.HasAttachments(msg.messageKey); }, true, true, true, count); }, + function (count) { liberator.mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, true, count); }, { flags: liberator.Mappings.flags.COUNT }); // FOLDER SWITCHING @@ -591,9 +591,7 @@ liberator.Mail = function () //{{{ "Mark all messages as read", function () { - liberator.mail.getFolders("", false).forEach(function (folder) { - folder.markAllMessagesRead(); - }); + liberator.mail.getFolders("", false).forEach(function (folder) folder.markAllMessagesRead()); }); // DISPLAY OPTIONS @@ -675,7 +673,7 @@ liberator.Mail = function () //{{{ SelectFolder(folder.URI); }, { - completer: function (filter) { return getFolderCompletions(filter); } + completer: function (filter) getFolderCompletions(filter) }); liberator.commands.add(["m[essage]"], @@ -697,7 +695,7 @@ liberator.Mail = function () //{{{ addresses = addresses.concat(mailargs.cc); // TODO: is there a better way to check for validity? - if (addresses.some(function (recipient) { return !(/\S@\S+\.\S/.test(recipient)); })) + if (addresses.some(function (recipient) !(/\S@\S+\.\S/.test(recipient)))) { liberator.echoerr("Exxx: Invalid e-mail address"); return; @@ -717,14 +715,14 @@ liberator.Mail = function () //{{{ "Copy selected messages", function (args, special) { moveOrCopy(true, args); }, { - completer: function (filter) { return getFolderCompletions(filter); } + completer: function (filter) getFolderCompletions(filter) }); liberator.commands.add(["move[to]"], "Move selected messages", function (args, special) { moveOrCopy(false, args); }, { - completer: function (filter) { return getFolderCompletions(filter); } + completer: function (filter) getFolderCompletions(filter) }); liberator.commands.add(["empty[trash]"], diff --git a/content/mappings.js b/content/mappings.js index ea84fbc7..60530e26 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -88,7 +88,7 @@ liberator.Mappings = function () //{{{ function addMap(map, userMap) { var where = userMap ? user : main; - map.modes.forEach(function (mode) { where[mode].push(map); }); + map.modes.forEach(function (mode) where[mode].push(map)); } function getMap(mode, cmd, stack) @@ -204,10 +204,7 @@ liberator.Mappings = function () //{{{ "Map a key sequence" + modeDescription, function (args) { map(args, modes, false); }, { - completer: function (filter) - { - return liberator.completion.userMapping(filter, modes); - } + completer: function (filter) liberator.completion.userMapping(filter, modes) }); liberator.commands.add([ch + "no[remap]"], @@ -246,10 +243,7 @@ liberator.Mappings = function () //{{{ liberator.echoerr("E31: No such mapping"); }, { - completer: function (filter) - { - return liberator.completion.userMapping(filter, modes); - } + completer: function (filter) liberator.completion.userMapping(filter, modes) }); } @@ -291,12 +285,12 @@ liberator.Mappings = function () //{{{ add: function (modes, keys, description, action, extra) { - addMap (new liberator.Map(modes, keys, description, action, extra), false); + addMap(new liberator.Map(modes, keys, description, action, extra), false); }, addUserMap: function (modes, keys, description, action, extra) { - keys = keys.map(function (key) { return expandLeader(key); }); + keys = keys.map(function (key) expandLeader(key)); var map = new liberator.Map(modes, keys, description || "User defined mapping", action, extra); // remove all old mappings to this key sequence @@ -306,7 +300,7 @@ liberator.Mappings = function () //{{{ removeMap(map.modes[j], map.names[i]); } - addMap (map, true); + addMap(map, true); }, get: function (mode, cmd) @@ -353,7 +347,7 @@ liberator.Mappings = function () //{{{ // returns whether the user added a custom user map hasMap: function (mode, cmd) { - return user[mode].some(function (map) { return map.hasName(cmd); }); + return user[mode].some(function (map) map.hasName(cmd)); }, remove: function (mode, cmd) diff --git a/content/options.js b/content/options.js index 06268fac..50244d34 100644 --- a/content/options.js +++ b/content/options.js @@ -901,8 +901,7 @@ liberator.Options = function () //{{{ " Options ---"; var name, value, defaultValue; - prefArray.forEach(function (pref) - { + prefArray.forEach(function (pref) { var userValue = prefService.prefHasUserValue(pref); if ((!onlyNonDefault || userValue) && pref.indexOf(filter) >= 0) { diff --git a/content/tabs.js b/content/tabs.js index 944ba531..a1b3efdf 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -142,7 +142,7 @@ liberator.Tabs = function () //{{{ return value; }, - validator: function (value) { return (value >= 0 && value <= 2); }, + validator: function (value) (value >= 0 && value <= 2), completer: function (filter) { return [ @@ -170,7 +170,9 @@ liberator.Tabs = function () //{{{ }, validator: function (value) { - return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); }); + return value.split(",").every( + function (item) /^(homepage|quickmark|tabopen|paste|)$/.test(item) + ); } }); @@ -191,7 +193,9 @@ liberator.Tabs = function () //{{{ }, validator: function (value) { - return value == "all" || value.split(",").every(function (item) { return /^(addons|downloads|help|javascript|prefs|)$/.test(item); }); + return value == "all" || value.split(",").every( + function (item) /^(addons|downloads|help|javascript|prefs|)$/.test(item) + ); } }); @@ -222,7 +226,7 @@ liberator.Tabs = function () //{{{ ["4", "Open in the same tab unless it has a specific requested size"] ]; }, - validator: function (value) { return (value >= 0 && value <= 4); } + validator: function (value) value >= 0 && value <= 4 }); } @@ -339,7 +343,9 @@ liberator.Tabs = function () //{{{ else // just remove the current tab liberator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); }, - { completer: function (filter) { return liberator.completion.buffer(filter); } }); + { + completer: function (filter) liberator.completion.buffer(filter) + }); // TODO: this should open in a new tab positioned directly after the current one, not at the end liberator.commands.add(["tab"], @@ -351,7 +357,7 @@ liberator.Tabs = function () //{{{ liberator.forceNewTab = false; }, { - completer: function (filter) { return liberator.completion.ex(filter); } + completer: function (filter) liberator.completion.ex(filter) }); liberator.commands.add(["tabl[ast]", "bl[ast]"], @@ -456,7 +462,9 @@ liberator.Tabs = function () //{{{ liberator.tabs.switchTo(args, special); } }, - { completer: function (filter) { return liberator.completion.buffer(filter); } }); + { + completer: function (filter) liberator.completion.buffer(filter) + }); liberator.commands.add(["buffers", "files", "ls", "tabs"], "Show a list of all buffers", @@ -521,7 +529,9 @@ liberator.Tabs = function () //{{{ else liberator.open("about:blank", where); }, - { completer: function (filter) { return liberator.completion.url(filter); } }); + { + completer: function (filter) liberator.completion.url(filter) + }); liberator.commands.add(["tabde[tach]"], "Detach current tab to its own window", diff --git a/content/ui.js b/content/ui.js index 65b941cd..5057f67c 100644 --- a/content/ui.js +++ b/content/ui.js @@ -300,7 +300,7 @@ liberator.CommandLine = function () //{{{ ["S", "Suggest engines"] ]; }, - validator: function (value) { return !/[^sfbhSl]/.test(value); } + validator: function (value) !/[^sfbhSl]/.test(value) }); liberator.options.add(["suggestengines"], @@ -311,8 +311,7 @@ liberator.CommandLine = function () //{{{ { var ss = Components.classes["@mozilla.org/browser/search-service;1"] .getService(Components.interfaces.nsIBrowserSearchService); - return value.split(",").every(function (item) - { + return value.split(",").every(function (item) { var e = ss.getEngineByAlias(item); return (e && e.supportsResponseType("application/x-suggestions+json")) ? true : false; }); @@ -329,7 +328,9 @@ liberator.CommandLine = function () //{{{ { validator: function (value) { - return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); }); + return value.split(",").every( + function (item) /^(full|longest|list|list:full|list:longest|)$/.test(item) + ); }, completer: function (filter) { @@ -376,7 +377,7 @@ liberator.CommandLine = function () //{{{ }, validator: function (value) { - return value.split(",").every(function (item) { return /^(sort|auto|)$/.test(item); }); + return value.split(",").every(function (item) /^(sort|auto|)$/.test(item)); } }); @@ -416,7 +417,9 @@ liberator.CommandLine = function () //{{{ if (res != null) liberator.echo(res); }, - { completer: function (filter) { return liberator.completion.javascript(filter); } }); + { + completer: function (filter) liberator.completion.javascript(filter) + }); liberator.commands.add(["echoe[rr]"], "Display an error string at the bottom of the window", @@ -426,7 +429,9 @@ liberator.CommandLine = function () //{{{ if (res != null) liberator.echoerr(res); }, - { completer: function (filter) { return liberator.completion.javascript(filter); } }); + { + completer: function (filter) liberator.completion.javascript(filter) + }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -575,9 +580,7 @@ liberator.CommandLine = function () //{{{ multilineInputWidget.value = ""; autosizeMultilineInputWidget(); - setTimeout(function () { - multilineInputWidget.focus(); - }, 10); + setTimeout(function () multilineInputWidget.focus(), 10); }, onEvent: function (event) @@ -827,7 +830,7 @@ liberator.CommandLine = function () //{{{ else if (event.type == "blur") { if (liberator.modes.extended & liberator.modes.INPUT_MULTILINE) - setTimeout(function () { multilineInputWidget.inputField.focus(); }, 0); + setTimeout(function () multilineInputWidget.inputField.focus(), 0); } else if (event.type == "input") { @@ -1188,7 +1191,7 @@ liberator.ItemList = function (id) //{{{ var height = getHeight(); if (height == 0) // sometimes we don't have the correct size at this point - setTimeout(function () { container.height = getHeight(); }, 10); + setTimeout(function () container.height = getHeight(), 10); else container.height = height; } @@ -1399,7 +1402,7 @@ liberator.StatusLine = function () //{{{ return value; }, - validator: function (value) { return (value >= 0 && value <= 2); }, + validator: function (value) value >= 0 && value <= 2, completer: function (filter) { return [ diff --git a/content/vimperator.js b/content/vimperator.js index ee596491..82c1ffd4 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -282,7 +282,7 @@ liberator.config = { //{{{ } }, { - completer: function (filter) { return liberator.completion.url(filter); } + completer: function (filter) liberator.completion.url(filter) }); liberator.commands.add(["redr[aw]"], @@ -359,7 +359,7 @@ liberator.config = { //{{{ liberator.open("about:blank", liberator.NEW_WINDOW); }, { - completer: function (filter) { return liberator.completion.url(filter); } + completer: function (filter) liberator.completion.url(filter) }); /////////////////////////////////////////////////////////////////////////////}}}