home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / toolkit.jar / content / mozapps / preferences / removemp.js < prev    next >
Encoding:
JavaScript  |  2007-11-06  |  1.8 KB  |  53 lines

  1. //@line 38 "/build/buildd/xulrunner-1.9-1.9.0.14+build2+nobinonly/mozilla/toolkit/mozapps/preferences/removemp.js"
  2.  
  3. var gRemovePasswordDialog = {
  4.   _token    : null,
  5.   _bundle   : null,
  6.   _prompt   : null,
  7.   _okButton : null,
  8.   _password : null,
  9.   init: function ()
  10.   {
  11.     this._prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
  12.                              .getService(Components.interfaces.nsIPromptService);
  13.     this._bundle = document.getElementById("bundlePreferences");
  14.  
  15.     this._okButton = document.documentElement.getButton("accept");
  16.     this._okButton.label = this._bundle.getString("pw_remove_button");
  17.     
  18.     this._password = document.getElementById("password");
  19.  
  20.     var pk11db = Components.classes["@mozilla.org/security/pk11tokendb;1"]
  21.                            .getService(Components.interfaces.nsIPK11TokenDB);
  22.     this._token = pk11db.getInternalKeyToken();
  23.  
  24.     // Initialize the enabled state of the Remove button by checking the 
  25.     // initial value of the password ("" should be incorrect).
  26.     this.validateInput();
  27.   },
  28.   
  29.   validateInput: function ()
  30.   {
  31.     this._okButton.disabled = !this._token.checkPassword(this._password.value);    
  32.   },
  33.   
  34.   removePassword: function ()
  35.   {
  36.     if (this._token.checkPassword(this._password.value)) {
  37.       this._token.changePassword(this._password.value, "");
  38.       this._prompt.alert(window,
  39.                          this._bundle.getString("pw_change_success_title"),
  40.                          this._bundle.getString("pw_erased_ok") 
  41.                          + " " + this._bundle.getString("pw_empty_warning"));
  42.     }
  43.     else {
  44.       this._password.value = "";
  45.       this._password.focus();
  46.       this._prompt.alert(window, 
  47.                          this._bundle.getString("pw_change_failed_title"),
  48.                          this._bundle.getString("incorrect_pw"));
  49.     }
  50.   },
  51. };
  52.  
  53.