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

whitespace fixes

This commit is contained in:
Doug Kearns
2008-06-06 13:47:51 +00:00
parent d79224b4cd
commit 5beaa4ca6c
6 changed files with 42 additions and 38 deletions

View File

@@ -31,7 +31,7 @@ liberator.Addressbook = function () //{{{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
const abManager = Components.classes["@mozilla.org/abmanager;1"] const abManager = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager); .getService(Components.interfaces.nsIAbManager);
const rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"] const rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"]
@@ -45,15 +45,15 @@ liberator.Addressbook = function () //{{{
// TODO: add option for a format specifier, like: // TODO: add option for a format specifier, like:
// :set displayname=%l, %f // :set displayname=%l, %f
function generateDisplayName(firstName, lastName) function generateDisplayName(firstName, lastName)
{ {
if (firstName && lastName) if (firstName && lastName)
return lastName + ", " + firstName; return lastName + ", " + firstName;
else if (firstName) else if (firstName)
return firstName; return firstName;
else if (lastName) else if (lastName)
return lastName; return lastName;
else else
return ""; return "";
} }
@@ -72,7 +72,7 @@ liberator.Addressbook = function () //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var modes = liberator.config.mailModes || [liberator.modes.NORMAL]; var modes = liberator.config.mailModes || [liberator.modes.NORMAL];
liberator.mappings.add(modes, ["a"], liberator.mappings.add(modes, ["a"],
"Open a prompt to save a new addressbook entry for the sender of the selected message", "Open a prompt to save a new addressbook entry for the sender of the selected message",
function () function ()
@@ -82,7 +82,7 @@ liberator.Addressbook = function () //{{{
{ {
to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor; to = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor;
} }
catch (e) { liberator.beep();} catch (e) { liberator.beep(); }
if (!to) if (!to)
return; return;
@@ -90,12 +90,12 @@ liberator.Addressbook = function () //{{{
var address = to.substring(to.indexOf("<") + 1, to.indexOf(">")); var address = to.substring(to.indexOf("<") + 1, to.indexOf(">"));
var displayName = to.substr(0, to.indexOf("<") - 1); var displayName = to.substr(0, to.indexOf("<") - 1);
if (/^\S+\s+\S+\s*$/.test(displayName)) if (/^\S+\s+\S+\s*$/.test(displayName))
{ {
var names = displayName.split(/\s+/); var names = displayName.split(/\s+/);
displayName = "-firstname=" + names[0].replace(/"/g, "") displayName = "-firstname=" + names[0].replace(/"/g, "")
+ " -lastname=" + names[1].replace(/"/g, ""); + " -lastname=" + names[1].replace(/"/g, "");
} }
else else
{ {
displayName = "-name=\"" + displayName.replace(/"/g, "") + "\""; displayName = "-name=\"" + displayName.replace(/"/g, "") + "\"";
@@ -126,7 +126,7 @@ liberator.Addressbook = function () //{{{
var firstName = liberator.commands.getOption(res.opts, "-firstname", null); var firstName = liberator.commands.getOption(res.opts, "-firstname", null);
var lastName = liberator.commands.getOption(res.opts, "-lastname", null); var lastName = liberator.commands.getOption(res.opts, "-lastname", null);
var displayName = liberator.commands.getOption(res.opts, "-name", null); var displayName = liberator.commands.getOption(res.opts, "-name", null);
if (!displayName) if (!displayName)
displayName = generateDisplayName(firstName, lastName); displayName = generateDisplayName(firstName, lastName);
if (liberator.addressbook.add(mailAddr, firstName, lastName, displayName)) if (liberator.addressbook.add(mailAddr, firstName, lastName, displayName))
@@ -148,10 +148,10 @@ liberator.Addressbook = function () //{{{
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
return { return {
add: function(address, firstname, lastname, displayName) add: function (address, firstname, lastname, displayName)
{ {
var directory = getDirectoryFromURI(kPersonalAddressbookURI); var directory = getDirectoryFromURI(kPersonalAddressbookURI);
var card = Components.classes["@mozilla.org/addressbook/cardproperty;1"] var card = Components.classes["@mozilla.org/addressbook/cardproperty;1"]
@@ -169,7 +169,7 @@ liberator.Addressbook = function () //{{{
}, },
// TODO: add telephone number support // TODO: add telephone number support
list: function(filter, newMail) list: function (filter, newMail)
{ {
var addresses = []; var addresses = [];
var dirs = abManager.directories; var dirs = abManager.directories;
@@ -179,15 +179,15 @@ liberator.Addressbook = function () //{{{
{ {
var addrbook = dirs.getNext().QueryInterface(Components.interfaces.nsIAbDirectory); var addrbook = dirs.getNext().QueryInterface(Components.interfaces.nsIAbDirectory);
var cards = addrbook.childCards; var cards = addrbook.childCards;
while(cards.hasMoreElements()) while (cards.hasMoreElements())
{ {
var card = cards.getNext().QueryInterface(Components.interfaces.nsIAbCard); var card = cards.getNext().QueryInterface(Components.interfaces.nsIAbCard);
var mail = card.primaryEmail || ""; var mail = card.primaryEmail || "";
var displayName = card.displayName; var displayName = card.displayName;
if (!displayName) if (!displayName)
displayName = generateDisplayName(card.firstName, card.lastName); displayName = generateDisplayName(card.firstName, card.lastName);
if (displayName.toLowerCase().indexOf(lowerFilter) > -1 if (displayName.toLowerCase().indexOf(lowerFilter) > -1
|| card.primaryEmail.toLowerCase().indexOf(lowerFilter) > -1) || card.primaryEmail.toLowerCase().indexOf(lowerFilter) > -1)
addresses.push([displayName, card.primaryEmail]); addresses.push([displayName, card.primaryEmail]);
} }
@@ -195,21 +195,21 @@ liberator.Addressbook = function () //{{{
if (addresses.length < 1) if (addresses.length < 1)
{ {
liberator.echoerr("E94: No matching contact for " + filter, liberator.commandline.FORCE_SINGLELINE); liberator.echoerr("E94: No matching contact for " + filter, liberator.commandline.FORCE_SINGLELINE);
return false; return false;
} }
if (newMail) if (newMail)
{ {
// Now we have to create a new message // Now we have to create a new message
var args = new Object(); var args = new Object();
args.to = addresses.map(function(address) args.to = addresses.map(function (address)
{ {
return "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""; return "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\"";
}).join(", "); }).join(", ");
liberator.mail.composeNewMail(args); liberator.mail.composeNewMail(args);
} }
else else
{ {
var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" + var list = ":" + liberator.util.escapeHTML(liberator.commandline.getCommand()) + "<br/>" +
"<table><tr align=\"left\" class=\"hl-Title\"><th>Name</th><th>Address</th></tr>"; "<table><tr align=\"left\" class=\"hl-Title\"><th>Name</th><th>Address</th></tr>";

View File

@@ -181,7 +181,7 @@ liberator.Completion = function () //{{{
searchEngineSuggest: function (filter, engineAliases) searchEngineSuggest: function (filter, engineAliases)
{ {
if (!filter) if (!filter)
return [0,null]; return [0, null];
var engineList = (engineAliases || liberator.options["suggestengines"]).split(","); var engineList = (engineAliases || liberator.options["suggestengines"]).split(",");
var responseType = "application/x-suggestions+json"; var responseType = "application/x-suggestions+json";
@@ -218,7 +218,7 @@ liberator.Completion = function () //{{{
// make sure we receive strings, otherwise a man-in-the-middle attack // make sure we receive strings, otherwise a man-in-the-middle attack
// could return objects which toString() method could be called to // could return objects which toString() method could be called to
// execute untrusted code // execute untrusted code
if(typeof(item) != "string") if (typeof item != "string")
return; return;
completions.push([(matches ? matches[1] : "") + item, engine.name + " suggestion"]); completions.push([(matches ? matches[1] : "") + item, engine.name + " suggestion"]);

View File

@@ -433,7 +433,8 @@ liberator.Hints = function () //{{{
} }
// the current word matches same characters as the previous word // the current word matches same characters as the previous word
if (wcIdx > 0) { if (wcIdx > 0)
{
var prevCharIdx = charIdx; var prevCharIdx = charIdx;
// now check if it matches additional characters // now check if it matches additional characters
for (; wcIdx < word.length && charIdx < chars.length; wcIdx++, charIdx++) for (; wcIdx < word.length && charIdx < chars.length; wcIdx++, charIdx++)
@@ -458,7 +459,8 @@ liberator.Hints = function () //{{{
} }
// the current word doesn't match same characters as the previous word, just // the current word doesn't match same characters as the previous word, just
// try to match the next characters // try to match the next characters
else { else
{
var prevCharIdx = charIdx; var prevCharIdx = charIdx;
for (var i = 0; i < word.length && charIdx < chars.length; i++, charIdx++) for (var i = 0; i < word.length && charIdx < chars.length; i++, charIdx++)
{ {
@@ -466,7 +468,8 @@ liberator.Hints = function () //{{{
break; break;
} }
if (prevCharIdx == charIdx) { if (prevCharIdx == charIdx)
{
if (! allowWordOverleaping) if (! allowWordOverleaping)
return false; return false;
} }
@@ -502,7 +505,8 @@ liberator.Hints = function () //{{{
return true; return true;
} }
for (; strIdx < strings.length; strIdx++) { for (; strIdx < strings.length; strIdx++)
{
if (strings[strIdx].length != 0) if (strings[strIdx].length != 0)
return false; return false;
} }

View File

@@ -70,7 +70,7 @@ liberator.IO = function () //{{{
}); });
// mkv[imperatorrc] or mkm[uttatorrc] // mkv[imperatorrc] or mkm[uttatorrc]
liberator.commands.add(["mk" + extname.substr(0,1) + "[" + extname.substr(1) + "rc]"], liberator.commands.add(["mk" + extname.substr(0, 1) + "[" + extname.substr(1) + "rc]"],
"Write current key mappings and changed options to the config file", "Write current key mappings and changed options to the config file",
function (args, special) function (args, special)
{ {

View File

@@ -626,7 +626,7 @@ liberator.Mail = function () //{{{
addresses = addresses.concat(mailargs.cc); addresses = addresses.concat(mailargs.cc);
// TODO: is there a better way to check for validity? // 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) { return !(/\S@\S+\.\S/.test(recipient)); }))
{ {
liberator.echoerr("Exxx: Invalid e-mail address"); liberator.echoerr("Exxx: Invalid e-mail address");
return; return;

View File

@@ -34,18 +34,18 @@ liberator.Tabs = function () //{{{
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var tabmail; var tabmail;
var getBrowser = (function(){ var getBrowser = (function () {
if (liberator.config.hostApplication == "Thunderbird") if (liberator.config.hostApplication == "Thunderbird")
{ {
return function() return function ()
{ {
if (!tabmail) if (!tabmail)
{ {
tabmail = document.getElementById('tabmail'); tabmail = document.getElementById('tabmail');
tabmail.__defineGetter__('mTabContainer',function(){ return this.tabContainer; }); tabmail.__defineGetter__('mTabContainer', function () { return this.tabContainer; });
tabmail.__defineGetter__('mTabs',function(){ return this.tabContainer.childNodes; }); tabmail.__defineGetter__('mTabs', function () { return this.tabContainer.childNodes; });
tabmail.__defineGetter__('mCurrentTab',function(){ return this.tabContainer.selectedItem; }); tabmail.__defineGetter__('mCurrentTab', function () { return this.tabContainer.selectedItem; });
tabmail.__defineGetter__('mStrip',function(){ return this.tabStrip; }); tabmail.__defineGetter__('mStrip', function () { return this.tabStrip; });
} }
return tabmail; return tabmail;
}; };
@@ -605,7 +605,7 @@ liberator.Tabs = function () //{{{
liberator.beep(); liberator.beep();
}; };
} }
return function() { return null; }; return function () { return null; };
})(); })();
if (typeof count != "number" || count < 1) if (typeof count != "number" || count < 1)