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-accname.js < prev    next >
Text File  |  2001-02-14  |  2KB  |  53 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  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 Bundle = srGetStrBundle("chrome://messenger/locale/prefs.properties");
  26.  
  27. function validate() {
  28.   var accountname = document.getElementById("prettyName").value;
  29.  
  30.   if (!accountname || accountname =="") {
  31.       var alertText = Bundle.GetStringFromName("enterAccountName");
  32.       window.alert(alertText);
  33.       return false;
  34.   }
  35.   return true;
  36. }
  37.  
  38. function onInit() {
  39.     var accountNameInput = document.getElementById("prettyName");
  40.     if (accountNameInput.value=="") {
  41.         var pageData = parent.GetPageData();
  42.         var type = parent.getCurrentServerType(pageData);
  43.         var protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
  44.         var accountName;
  45.         if (type == "nntp") {
  46.             accountName = pageData.newsserver.hostname.value;
  47.         } else {
  48.             accountName = pageData.identity.email.value;
  49.         }
  50.         accountNameInput.value = accountName;
  51.     }
  52. }
  53.