home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / mail.xpi / bin / chrome / messenger.jar / content / messenger / aw-login.js < prev    next >
Text File  |  2001-02-22  |  3KB  |  89 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 gPrefsBundle;
  27.  
  28. function validate() {
  29.   var username = document.getElementById("username").value;
  30.  
  31.   if (protocolinfo && protocolinfo.requiresUsername && (!username || username == "")) { 
  32.       var alertText = gPrefsBundle.getString("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 = gPrefsBundle.getString("accountExists");
  43.     window.alert(alertText);
  44.     return false;
  45.   }
  46.   return true;
  47. }
  48.  
  49. function onInit() {
  50.     gPrefsBundle = document.getElementById("bundle_prefs");
  51.     var loginNameInput = document.getElementById("username");
  52.     
  53.     if (loginNameInput.value == "") {
  54.       // retrieve data from previously entered pages
  55.       var pageData = parent.wizardManager.WSM.PageData;
  56.       var type = parent.getCurrentServerType(pageData);
  57.  
  58.       dump("type = " + type + "\n");
  59.       protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
  60.  
  61.       if (protocolinfo.requiresUsername) {
  62.         // since we require a username, use the uid from the email address
  63.         var email = pageData.identity.email.value;
  64.         var emailParts = email.split("@");
  65.         loginNameInput.value = emailParts[0];
  66.       }
  67.     }
  68. }
  69.  
  70.  
  71. var savedPassword="";
  72.  
  73. function onSavePassword(target) {
  74.     dump("savePassword changed! (" + target.checked + ")\n");
  75.     var passwordField = document.getElementById("server.password");
  76.     if (!passwordField) return;
  77.     
  78.     if (target.checked) {
  79.         passwordField.removeAttribute("disabled");
  80.         passwordField.value = savedPassword;
  81.     }
  82.     else {
  83.         passwordField.setAttribute("disabled", "true");
  84.         savedPassword = passwordField.value;
  85.         passwordField.value = "";
  86.     }
  87.     
  88. }
  89.