home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / messenger.jar / content / messenger / aw-login.js < prev    next >
Text File  |  2001-02-14  |  3KB  |  88 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  *
  13.  * The Original Code is mozilla.org code.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation.  Portions created by Netscape are
  17.  * Copyright (C) 1998 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  * Alec Flett <alecf@netscape.com>
  22.  * Seth Spitzer <sspitzer@netscape.com>
  23.  */
  24.  
  25. var protocolinfo = null;
  26. var Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
  27.  
  28. function validate() {
  29.   var username = document.getElementById("username").value;
  30.  
  31.   if (protocolinfo && protocolinfo.requiresUsername && (!username || username == "")) { 
  32.       var alertText = Bundle.GetStringFromName("enterUserName");
  33.       window.alert(alertText);
  34.       return false;
  35.   }
  36.  
  37.   var pageData = parent.GetPageData();
  38.   var serverType = parent.getCurrentServerType(pageData);
  39.   var hostName = parent.getCurrentHostname(pageData);
  40.  
  41.   if (parent.AccountExists(username,hostName,serverType)) {
  42.     alertText = Bundle.GetStringFromName("accountExists");
  43.     window.alert(alertText);
  44.     return false;
  45.   }
  46.   return true;
  47. }
  48.  
  49. function onInit() {
  50.     var loginNameInput = document.getElementById("username");
  51.     
  52.     if (loginNameInput.value == "") {
  53.       // retrieve data from previously entered pages
  54.       var pageData = parent.wizardManager.WSM.PageData;
  55.       var type = parent.getCurrentServerType(pageData);
  56.  
  57.       dump("type = " + type + "\n");
  58.       protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
  59.  
  60.       if (protocolinfo.requiresUsername) {
  61.         // since we require a username, use the uid from the email address
  62.         var email = pageData.identity.email.value;
  63.         var emailParts = email.split("@");
  64.         loginNameInput.value = emailParts[0];
  65.       }
  66.     }
  67. }
  68.  
  69.  
  70. var savedPassword="";
  71.  
  72. function onSavePassword(target) {
  73.     dump("savePassword changed! (" + target.checked + ")\n");
  74.     var passwordField = document.getElementById("server.password");
  75.     if (!passwordField) return;
  76.     
  77.     if (target.checked) {
  78.         passwordField.removeAttribute("disabled");
  79.         passwordField.value = savedPassword;
  80.     }
  81.     else {
  82.         passwordField.setAttribute("disabled", "true");
  83.         savedPassword = passwordField.value;
  84.         passwordField.value = "";
  85.     }
  86.     
  87. }
  88.