rem: var j=0; 
add: var j; 
context: function onAccept(){  var len = gDeletedDirectories.length;  if (len) {    try {      var directoryServer = gPrefInt.getCharPref("ldap_2.autoComplete.directoryServer");    }    catch(ex)  {      directoryServer = null;    }    var am = Components.classes["@mozilla.org/messenger/account-manager;1"]                 .getService(Components.interfaces.nsIMsgAccountManager);    if (am) {      var RDF, addressbook, addressbookDS;       try {        // the rdf service        RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].                         getService(Components.interfaces.nsIRDFService);        // get the datasource for the addressdirectory        addressbookDS = RDF.GetDataSource("rdf:addressdirectory");        addressbook = Components.classes["@mozilla.org/addressbook;1"].                         createInstance(Components.interfaces.nsIAddressBook);      }      catch(ex){        dump("Failed to get RDF Service or addressbook " + ex + "\n");      }       var allIdentities = am.allIdentities;      var identitiesCount = allIdentities.Count();      var identityServer = new Array();      var currentIdentity = null;      var j=0;      for (j=0; j< identitiesCount; j++) {        currentIdentity = allIdentities.QueryElementAt(j, Components.interfaces.nsIMsgIdentity);        identityServer[j] = {server:currentIdentity.directoryServer, deleted:false};      }      var deletedGlobal = false;      for (var i=0; i< len; i++){        if (!deletedGlobal && directoryServer && (gDeletedDirectories[i] == directoryServer)) {          gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer", "");          deletedGlobal = true;        }        for (j=0; j<identitiesCount; j++){          if (identityServer[j].server && !identityServer[j].deleted && (gDeletedDirectories[i] == identityServer[j].server)) {            identityServer[j].server = "";            identityServer[j].deleted = true;          }        }        try {          // delete the directory               var parentArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);          // moz-abdirectory:// is the RDF root to get all types of addressbooks.          var parentDir = RDF.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);          parentArray.AppendElement(parentDir);          var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);          // the RDF resource URI for LDAPDirectory will be moz-abldapdirectory://<prefName>          var selectedABURI = "moz-abldapdirectory://" + gDeletedDirectories[i];          var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);          var selectedABResource = selectedABDirectory.QueryInterface(Components.interfaces.nsIRDFResource);          resourceArray.AppendElement(selectedABResource);          addressbook.deleteAddressBooks(addressbookDS, parentArray, resourceArray);        }        catch(ex){          dump("Failed to delete the addressbook " + ex + "\n");        }      }      var svc = Components.classes["@mozilla.org/preferences-service;1"]                        .getService(Components.interfaces.nsIPrefService);      svc.savePrefFile(null);    }  }  window.opener.gRefresh = true;  return true;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/d482b5cf10f63e1521f05d71be4f602770acf7f5/pref-directory.js/buggy/mailnews/addrbook/prefs/resources/content/pref-directory.js