From 87237d4cb5bfa953ae31e7b086f5bf774a09f1e3 Mon Sep 17 00:00:00 2001 From: "bugzilla%standard8.demon.co.uk" Date: Mon, 20 Feb 2006 18:11:05 +0000 Subject: [PATCH] Bug 237210 In , "Warning: function GetSelectedCardTypes does not always return a value"; plus various cleanups including a few additionnal fixes. (Cv1-TB) additional cleanup. patch by Serge GAUTHERIE r/sr=bryner --- mail/components/addrbook/content/abCommon.js | 54 +++++++------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/mail/components/addrbook/content/abCommon.js b/mail/components/addrbook/content/abCommon.js index e1a640e89bc4..4d10fbd7a652 100644 --- a/mail/components/addrbook/content/abCommon.js +++ b/mail/components/addrbook/content/abCommon.js @@ -193,14 +193,14 @@ var DirPaneController = var ldapUrlPrefix = "moz-abldapdirectory://"; if ((selectedDir.indexOf(ldapUrlPrefix, 0)) == 0) { - var prefName = selectedDir.substr(ldapUrlPrefix.length, selectedDir.length); var disable = false; try { - disable = gPrefs.getBoolPref(prefName + ".disable_delete"); - } - catch(ex){ - // if this preference is not set its ok. - } + var prefName = selectedDir.substr(ldapUrlPrefix.length); + disable = gPrefs.getBoolPref(prefName + ".disable_delete"); + } + catch(ex) { + // if this preference is not set its ok. + } if (disable) return false; } @@ -269,7 +269,7 @@ function AbEditSelectedDirectory() var ldapUrlPrefix = "moz-abldapdirectory://"; var args = { selectedDirectory: directory.dirName, selectedDirectoryString: null}; - args.selectedDirectoryString = selecteduri.substr(ldapUrlPrefix.length, selecteduri.length); + args.selectedDirectoryString = selecteduri.substr(ldapUrlPrefix.length); window.openDialog("chrome://messenger/content/addressbook/pref-directory-add.xul", "editDirectory", "chrome,modal=yes,resizable=no,centerscreen", args); } @@ -319,7 +319,7 @@ function GetSelectedCardTypes() return kNothingSelected; // no view var count = cards.length; - if (!count) + if (count == 0) return kNothingSelected; // nothing selected var mailingListCnt = 0; @@ -393,10 +393,7 @@ function GetSelectedCardIndex() function GetSelectedCard() { var index = GetSelectedCardIndex(); - if (index == -1) - return null; - else - return gAbView.getCardFromRow(index); + return (index == -1) ? null : gAbView.getCardFromRow(index); } function AbEditSelectedCard() @@ -406,11 +403,9 @@ function AbEditSelectedCard() function AbEditCard(card) { - if (!card) - return; - - // Not allowing AOL special groups to be edited. - if (card.isASpecialGroup) + // Need a card, + // but not allowing AOL special groups to be edited. + if (!card || card.isASpecialGroup) return; if (card.isMailList) { @@ -463,7 +458,6 @@ function goToggleSplitter( id, elementID ) if ( splitter ) { var attribValue = splitter.getAttribute("state") ; - if ( attribValue == "collapsed" ) { splitter.setAttribute("state", "open" ); @@ -496,11 +490,9 @@ function GetSelectedAddressesFromDirTree() if (directory.isMailList) { var listCardsCount = directory.addressLists.Count(); var cards = new Array(listCardsCount); - for ( var i = 0; i < listCardsCount; i++ ) { - var card = directory.addressLists.GetElementAt(i); - card = card.QueryInterface(Components.interfaces.nsIAbCard); - cards[i] = card; - } + for (var i = 0; i < listCardsCount; ++i) + cards[i] = directory.addressLists.QueryElementAt( + i, Components.interfaces.nsIAbCard); addresses = GetAddressesForCards(cards); } } @@ -605,10 +597,8 @@ function GetSelectedAbCards() var start = new Object; var end = new Object; abView.selection.getRangeAt(i,start,end); - for (j=start.value;j<=end.value;j++) { - cards[current] = abView.getCardFromRow(j); - current++; - } + for (j = start.value; j <= end.value; ++j) + cards[current++] = abView.getCardFromRow(j); } return cards; } @@ -729,10 +719,7 @@ function GetAbView() // done. to get the uri of the directory only, use GetSelectedDirectory(). function GetAbViewURI() { - if (gAbView) - return gAbView.URI; - else - return null; + return gAbView && gAbView.URI; } function ChangeDirectoryByURI(uri) @@ -902,10 +889,7 @@ function GenerateAddressFromCard(card) if (card.isMailList) { var directory = GetDirectoryFromURI(card.mailListURI); - if(directory.description) - email = directory.description; - else - email = card.displayName; + email = directory.description || card.displayName; } else email = card.primaryEmail;