1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 08:52:27 +01:00

whitespace fixes and revert some overly aggressive use of expression closures

This commit is contained in:
Doug Kearns
2008-10-04 10:18:53 +00:00
parent 156fa5d56f
commit 6ef73cf313
16 changed files with 84 additions and 71 deletions

View File

@@ -82,7 +82,10 @@ liberator.Addressbook = function () //{{{
{
to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
}
catch (e) { liberator.beep(); }
catch (e)
{
liberator.beep();
}
if (!to)
return;
@@ -134,7 +137,7 @@ liberator.Addressbook = function () //{{{
liberator.commands.add(["contacts", "addr[essbook]"],
"List or open multiple addresses",
function (args, special) liberator.addressbook.list(args, special),
function (args, special) { liberator.addressbook.list(args, special); },
{ bangAllowed: true });
/////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -165,7 +165,8 @@ liberator.Bookmarks = function () //{{{
liberator.storage.fireEvent(name, "change", itemId);
}
},
QueryInterface: function (iid) {
QueryInterface: function (iid)
{
if (iid.equals(Components.interfaces.nsINavBookmarkObserver) || iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
@@ -221,7 +222,7 @@ liberator.Bookmarks = function () //{{{
liberator.mappings.add(modes, ["A"],
"Toggle bookmarked state of current URL",
function () liberator.bookmarks.toggle(liberator.buffer.URL));
function () { liberator.bookmarks.toggle(liberator.buffer.URL); });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// COMMANDS ////////////////////////////////////////////////
@@ -264,7 +265,7 @@ liberator.Bookmarks = function () //{{{
argCount: "?",
options: [[["-title", "-t"], liberator.commands.OPTION_STRING],
[["-tags", "-T"], liberator.commands.OPTION_LIST],
[["-keyword", "-k"], liberator.commands.OPTION_STRING, function (arg) { return /\w/.test(arg); }]]
[["-keyword", "-k"], liberator.commands.OPTION_STRING, function (arg) /\w/.test(arg)]]
});
liberator.commands.add(["bmarks"],
@@ -513,7 +514,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()
{
@@ -667,7 +668,7 @@ liberator.History = function () //{{{
liberator.commands.add(["hist[ory]", "hs"],
"Show recently visited URLs",
function (args, special) liberator.history.list(args, special),
function (args, special) { liberator.history.list(args, special); },
{
bangAllowed: true,
completer: function (filter) [0, liberator.history.get(filter)]

View File

@@ -130,11 +130,14 @@ liberator.Buffer = function () //{{{
while (true)
{
try {
try
{
// Throws NS_ERROR_DOM_INVALID_ACCESS_ERR if not finished loading
doc.styleSheets[0].cssRules.length;
break;
} catch (e) {
}
catch (e)
{
if (e.name != "NS_ERROR_DOM_INVALID_ACCESS_ERR")
return [e.toString()];
liberator.sleep(10);
@@ -608,7 +611,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["pa[geinfo]"],
"Show various page information",
function () liberator.buffer.showPageInfo(true),
function () { liberator.buffer.showPageInfo(true); },
{ argCount: "0" });
liberator.commands.add(["pagest[yle]"],
@@ -632,7 +635,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["re[load]"],
"Reload current page",
function (args, special) liberator.tabs.reload(getBrowser().mCurrentTab, special),
function (args, special) { liberator.tabs.reload(getBrowser().mCurrentTab, special); },
{
bangAllowed: true,
argCount: "0"
@@ -657,7 +660,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["st[op]"],
"Stop loading",
function () BrowserStop(),
function () { BrowserStop(); },
{ argCount: "0" });
liberator.commands.add(["sty[le]"],
@@ -692,7 +695,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["dels[tyle]"],
"Remove a user stylesheet",
function (args) styles.removeSheet(parseInt(args.arguments[0])),
function (args) { styles.removeSheet(parseInt(args.arguments[0])); },
{
completer: function (filter) [0, [[i, s[0] + ": " + s[1].replace("\n", "\\n")] for ([i, s] in styles)]],
argCount: 1
@@ -700,7 +703,7 @@ liberator.Buffer = function () //{{{
liberator.commands.add(["vie[wsource]"],
"View source code of current document",
function (args, special) liberator.buffer.viewSource(args, special),
function (args, special) { liberator.buffer.viewSource(args, special); },
{ bangAllowed: true });
liberator.commands.add(["zo[om]"],
@@ -801,7 +804,8 @@ liberator.Buffer = function () //{{{
// put feeds rss into pageFeeds[]
let nFeed = 0;
var linkNodes = doc.getElementsByTagName("link");
for (link in arrayIter(linkNodes)) {
for (link in arrayIter(linkNodes))
{
if (!link.href)
return;
@@ -1384,7 +1388,7 @@ liberator.Buffer = function () //{{{
doc.body.appendChild(liberator.util.xmlToDom(indicator));
// remove the frame indicator
setTimeout(function () doc.body.removeChild(indicator), 500);
setTimeout(function () { doc.body.removeChild(indicator); }, 500);
},
// similar to pageInfo
@@ -1876,7 +1880,7 @@ liberator.template = {
return xml;
try
{
return new XMLList(xml)
return new XMLList(xml);
}
catch (e) {}
return <>{xml}</>;
@@ -1884,7 +1888,7 @@ liberator.template = {
generic: function (xml)
{
return <>:{liberator.commandline.getCommand()}<br/></> + xml
return <>:{liberator.commandline.getCommand()}<br/></> + xml;
},
bookmarks: function (header, items)

View File

@@ -740,7 +740,7 @@ liberator.Commands = function () //{{{
"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" });

View File

@@ -174,11 +174,11 @@ liberator.Editor = function () //{{{
liberator.commands.add([ch ? ch + "una[bbrev]" : "una[bbreviate]"],
"Remove an abbreviation" + modeDescription,
function (args) liberator.editor.removeAbbreviation(mode, args));
function (args) { liberator.editor.removeAbbreviation(mode, args); });
liberator.commands.add([ch + "abc[lear]"],
"Remove all abbreviations" + modeDescription,
function () liberator.editor.removeAllAbbreviations(mode),
function () { liberator.editor.removeAllAbbreviations(mode); },
{ argCount: "0" });
}
@@ -290,7 +290,7 @@ liberator.Editor = function () //{{{
liberator.mappings.add([liberator.modes.INSERT],
["<Space>", "<Return>"], "Expand insert mode abbreviation",
function () { return liberator.editor.expandAbbreviation("i"); },
function () { liberator.editor.expandAbbreviation("i"); },
{ flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING });
liberator.mappings.add([liberator.modes.INSERT],

View File

@@ -296,7 +296,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);
}
@@ -873,7 +873,8 @@ liberator.Events = function () //{{{
evt.isMacro = true;
elem.dispatchEvent(evt);
// stop feeding keys if page loading failed
if (wasReplaying) {
if (wasReplaying)
{
if (!liberator.modes.isReplaying)
break;
if (!waitForPageLoaded())
@@ -1455,7 +1456,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);
}
}
@@ -1494,7 +1495,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 ()

View File

@@ -155,7 +155,8 @@ liberator.Search = function () //{{{
if (!doc || !(doc instanceof HTMLDocument))
return;
if (!aWord) {
if (!aWord)
{
let elems = doc.getElementsByClassName("__liberator-search");
for (let i = elems.length; --i >= 0;)
{
@@ -195,7 +196,8 @@ liberator.Search = function () //{{{
this.endPt.setStart(body, count);
this.endPt.setEnd(body, count);
for (let retRange in this.search(aWord, caseSensitive)) {
for (let retRange in this.search(aWord, caseSensitive))
{
// Highlight
var nodeSurround = baseNode.cloneNode(true);
var node = this.highlight(retRange, nodeSurround);
@@ -305,7 +307,7 @@ liberator.Search = function () //{{{
liberator.commands.add(["noh[lsearch]"],
"Remove the search highlighting",
function () liberator.search.clear(),
function () { liberator.search.clear(); },
{ argCount: "0" });
/////////////////////////////////////////////////////////////////////////////}}}
@@ -344,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 +419,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);

View File

@@ -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);
}
@@ -804,7 +804,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;
}

View File

@@ -193,7 +193,7 @@ liberator.IO = function () //{{{
liberator.commands.add(["pw[d]"],
"Print the current directory name",
function () liberator.echo(liberator.io.getCurrentDirectory()),
function () { liberator.echo(liberator.io.getCurrentDirectory()); },
{ argCount: "0" });
// mkv[imperatorrc] or mkm[uttatorrc]

View File

@@ -156,7 +156,7 @@ const liberator = (function () //{{{
liberator.commands.add(["beep"],
"Play a system beep",
function () liberator.beep(),
function () { liberator.beep(); },
{ argCount: "0" });
liberator.commands.add(["dia[log]"],
@@ -343,7 +343,7 @@ const liberator = (function () //{{{
liberator.commands.add(["norm[al]"],
"Execute Normal mode commands",
function (args, special) liberator.events.feedkeys(args.string, special),
function (args, special) { liberator.events.feedkeys(args.string, special); },
{
argCount: "+",
bangAllowed: true
@@ -365,7 +365,7 @@ const liberator = (function () //{{{
liberator.commands.add(["res[tart]"],
"Force " + liberator.config.name + " to restart",
function () liberator.restart(),
function () { liberator.restart(); },
{ argCount: "0" });
liberator.commands.add(["time"],
@@ -621,7 +621,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

View File

@@ -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;
}
@@ -263,7 +263,7 @@ liberator.Mail = function () //{{{
liberator.mappings.add(modes, ["<Space>"],
"Scroll message or select next unread one",
function () { return true; },
function () true,
{ flags: liberator.Mappings.flags.ALLOW_EVENT_ROUTING });
liberator.mappings.add(modes, ["t"],
@@ -591,7 +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
@@ -711,17 +711,17 @@ liberator.Mail = function () //{{{
liberator.commands.add(["copy[to]"],
"Copy selected messages",
function (args) moveOrCopy(true, args),
function (args) { moveOrCopy(true, args); },
{ completer: function (filter) getFolderCompletions(filter) });
liberator.commands.add(["move[to]"],
"Move selected messages",
function (args) moveOrCopy(false, args),
function (args) { moveOrCopy(false, args); },
{ completer: function (filter) getFolderCompletions(filter) });
liberator.commands.add(["empty[trash]"],
"Empty trash of the current account",
function () goDoCommand("cmd_emptyTrash"),
function () { goDoCommand("cmd_emptyTrash"); },
{ argCount: "0" });
liberator.commands.add(["get[messages]"],
@@ -740,7 +740,8 @@ liberator.Mail = function () //{{{
get currentAccount() this.currentFolder.rootFolder,
get currentFolder() {
get currentFolder()
{
var tree = GetFolderTree();
return GetFolderResource(tree, tree.currentIndex).
QueryInterface(Components.interfaces.nsIMsgFolder);

View File

@@ -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)
@@ -202,12 +202,12 @@ liberator.Mappings = function () //{{{
liberator.commands.add([ch ? ch + "m[ap]" : "map"],
"Map a key sequence" + modeDescription,
function (args) map(args, modes, false),
function (args) { map(args, modes, false); },
{ completer: function (filter) liberator.completion.userMapping(filter, modes) });
liberator.commands.add([ch + "no[remap]"],
"Map a key sequence without remapping keys" + modeDescription,
function (args) map(args, modes, true));
function (args) { map(args, modes, true); });
liberator.commands.add([ch + "mapc[lear]"],
"Remove all mappings" + modeDescription,

View File

@@ -69,7 +69,7 @@ liberator.Option = function (names, description, type, defaultValue, extraInfo)
}
this.__defineGetter__("globalvalue", function () liberator.options.store.get(cannonName));
this.__defineSetter__("globalvalue", function (val) liberator.options.store.set(cannonName, val));
this.__defineSetter__("globalvalue", function (val) { liberator.options.store.set(cannonName, val); });
if (this.globalvalue == undefined)
this.globalvalue = this.defaultValue;
@@ -887,7 +887,7 @@ liberator.Options = function () //{{{
}
// quickly access options with liberator.options["wildmode"]:
this.__defineGetter__(option.name, function () { return option.value; });
this.__defineGetter__(option.name, function () option.value);
this.__defineSetter__(option.name, function (value) { option.value = value; });
// TODO: sort option

View File

@@ -43,10 +43,10 @@ liberator.Tabs = function () //{{{
if (!tabmail)
{
tabmail = document.getElementById('tabmail');
tabmail.__defineGetter__('mTabContainer', function () { return this.tabContainer; });
tabmail.__defineGetter__('mTabs', function () { return this.tabContainer.childNodes; });
tabmail.__defineGetter__('mCurrentTab', function () { return this.tabContainer.selectedItem; });
tabmail.__defineGetter__('mStrip', function () { return this.tabStrip; });
tabmail.__defineGetter__('mTabContainer', function () this.tabContainer);
tabmail.__defineGetter__('mTabs', function () this.tabContainer.childNodes);
tabmail.__defineGetter__('mCurrentTab', function () this.tabContainer.selectedItem);
tabmail.__defineGetter__('mStrip', function () this.tabStrip);
}
return tabmail;
};
@@ -427,7 +427,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["tabr[ewind]", "tabfir[st]", "br[ewind]", "bf[irst]"],
"Switch to the first tab",
function () liberator.tabs.select(0, false),
function () { liberator.tabs.select(0, false); },
{ argCount: "0" });
if (liberator.config.name == "Vimperator")
@@ -462,7 +462,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["buffers", "files", "ls", "tabs"],
"Show a list of all buffers",
function (args, special) liberator.tabs.list(special),
function (args, special) { liberator.tabs.list(special); },
{
argCount: "0",
bangAllowed: true
@@ -470,7 +470,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["quita[ll]", "qa[ll]"],
"Quit " + liberator.config.name,
function (args, special) liberator.quit(false, special),
function (args, special) { liberator.quit(false, special); },
{
argCount: "0",
bangAllowed: true
@@ -478,7 +478,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["reloada[ll]"],
"Reload all tab pages",
function (args, special) liberator.tabs.reloadAll(special),
function (args, special) { liberator.tabs.reloadAll(special); },
{
argCount: "0",
bangAllowed: true
@@ -505,7 +505,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["tabo[nly]"],
"Close all other tabs",
function () liberator.tabs.keepOnly(getBrowser().mCurrentTab),
function () { liberator.tabs.keepOnly(getBrowser().mCurrentTab); },
{ argCount: "0" });
liberator.commands.add(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
@@ -528,7 +528,7 @@ liberator.Tabs = function () //{{{
liberator.commands.add(["tabde[tach]"],
"Detach current tab to its own window",
function (args, special, count) liberator.tabs.detachTab(null),
function (args, special, count) { liberator.tabs.detachTab(null); },
{
argCount: "0",
bangAllowed: true

View File

@@ -661,7 +661,7 @@ liberator.CommandLine = function () //{{{
multilineInputWidget.value = "";
autosizeMultilineInputWidget();
setTimeout(function () multilineInputWidget.focus(), 10);
setTimeout(function () { multilineInputWidget.focus(); }, 10);
},
onEvent: function (event)
@@ -911,7 +911,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")
{
@@ -931,8 +931,8 @@ liberator.CommandLine = function () //{{{
var closeWindow = false;
var passEvent = false;
function isScrollable() { return !win.scrollMaxY == 0; }
function atEnd() { return win.scrollY / win.scrollMaxY >= 1; }
function isScrollable() !win.scrollMaxY == 0;
function atEnd() win.scrollY / win.scrollMaxY >= 1;
var key = liberator.events.toString(event);
@@ -1248,7 +1248,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;
}
@@ -1322,7 +1322,7 @@ liberator.ItemList = function (id) //{{{
clear: function () { this.setItems([]); doc.body.innerHTML = ""; },
hide: function () { container.collapsed = true; },
show: function () { container.collapsed = false; },
visible: function () { return !container.collapsed; },
visible: function () !container.collapsed,
// if @param selectedItem is given, show the list and select that item
setItems: function (items, selectedItem)

View File

@@ -310,7 +310,8 @@ liberator.util = { //{{{
value = "<no value>";
}
if (color) {
if (color)
{
value = this.colorize(value, true).toXMLString();
i = <span style="font-weight: bold;">{i}</span>.toXMLString();
}