home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / mail.xpi / bin / chrome / messenger.jar / content / messenger / aw-done.js < prev    next >
Text File  |  2001-04-11  |  6KB  |  156 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  */
  20.  
  21. var gPrefsBundle;
  22.  
  23. function onInit() {
  24.     gPrefsBundle = document.getElementById("bundle_prefs");
  25.     var pageData = parent.wizardManager.WSM.PageData;
  26.     var showMailServerDetails = true; 
  27.  
  28.     var currentAccountData = parent.gCurrentAccountData;
  29.     if (currentAccountData) {
  30.         // find out if we need to hide server details
  31.         showMailServerDetails = currentAccountData.showServerDetailsOnWizardSummary; 
  32.   
  33.         // Change the username field description to email field label in aw-identity
  34.         setUserNameDescField(currentAccountData.emailIDFieldTitle);
  35.     }
  36.  
  37.     var email = "";
  38.     if (pageData.identity && pageData.identity.email) {
  39.         // fixup the email
  40.         email = pageData.identity.email.value;
  41.         if (email.split('@').length < 2 && 
  42.                      currentAccountData && 
  43.                      currentAccountData.domain)
  44.             email += "@" + currentAccountData.domain;
  45.     }
  46.     setDivTextFromForm("identity.email", email);
  47.  
  48.     var userName="";
  49.     if (pageData.login && pageData.login.username) {
  50.         userName = pageData.login.username.value;
  51.     }
  52.     if (!userName && email) {
  53.         var emailData = email.split('@');
  54.         userName = emailData[0];
  55.     }
  56.     setDivTextFromForm("server.username", userName);
  57.  
  58.     var accountName="";
  59.     if (pageData.accname && pageData.accname.prettyName) {
  60.         accountName = pageData.accname.prettyName.value;
  61.  
  62.         // If the AccountData exists, tha means we have values read from rdf file.
  63.         // Get the pretty name and polish the account name
  64.         if ( currentAccountData && 
  65.              currentAccountData.incomingServer.prettyName)
  66.         {
  67.             var prettyName = currentAccountData.incomingServer.prettyName; 
  68.             // Get the polished account name 
  69.             accountName = gPrefsBundle.getFormattedString("accountName",
  70.                                                           [prettyName,
  71.                                                            userName]);
  72.             // Set that to be the name in the pagedata 
  73.             pageData.accname.prettyName.value = accountName;
  74.         }
  75.     }
  76.     setDivTextFromForm("account.name", accountName);
  77.  
  78.     // Show mail servers (incoming&outgoing) detials
  79.     // based on current account data. ISP can set 
  80.     // rdf value of literal showServerDetailsOnWizardSummary
  81.     // to false to hide server details
  82.     if (showMailServerDetails) {
  83.         var incomingServerName="";
  84.         if (pageData.server && pageData.server.hostname) {
  85.             incomingServerName = pageData.server.hostname.value;
  86.             if (!incomingServerName && 
  87.                  currentAccountData && 
  88.                  currentAccountData.incomingServer.hostname)
  89.                 incomingServerName = currentAccountData.incomingServer.hostName;
  90.         }
  91.         setDivTextFromForm("server.name", incomingServerName);
  92.  
  93.         var incomingServerType="";
  94.         if (pageData.server && pageData.server.servertype) {
  95.             incomingServerType = pageData.server.servertype.value;
  96.             if (!incomingServerType && 
  97.                  currentAccountData && 
  98.                  currentAccountData.incomingServer.type)
  99.                 incomingServerType = currentAccountData.incomingServer.type;
  100.         }
  101.         setDivTextFromForm("server.type", incomingServerType.toUpperCase());
  102.  
  103.         var smtpServerName="";
  104.         if (pageData.server && pageData.server.smtphostname) {
  105.             var smtpServer = parent.smtpService.defaultServer;
  106.             smtpServerName = pageData.server.smtphostname.value;
  107.             if (!smtpServerName && smtpServer.hostname)
  108.                 smtpServerName = smtpServer.hostname;
  109.         }
  110.         setDivTextFromForm("smtpServer.name", smtpServerName);
  111.     }
  112.     else {
  113.         setDivTextFromForm("server.name", null);
  114.         setDivTextFromForm("server.type", null);
  115.         setDivTextFromForm("smtpServer.name", null);
  116.     }
  117.  
  118.     var newsServerName="";
  119.     if (pageData.newsserver && pageData.newsserver.hostname)
  120.         newsServerName = pageData.newsserver.hostname.value;
  121.     if (newsServerName) {
  122.         // No need to show username for news account
  123.         setDivTextFromForm("server.username", null);
  124.     }
  125.     setDivTextFromForm("newsServer.name", newsServerName);
  126. }
  127.  
  128. function setDivTextFromForm(divid, value) {
  129.  
  130.     // collapse the row if the div has no value
  131.     if (!value) {
  132.         var div = document.getElementById(divid);
  133.         div.setAttribute("collapsed","true");
  134.         return;
  135.     }
  136.  
  137.     // otherwise fill in the .text element
  138.     div = document.getElementById(divid+".text");
  139.     if (!div) return;
  140.  
  141.     div.setAttribute("value", value);
  142. }
  143.  
  144. function setUserNameDescField(name)
  145. {
  146.    if (name) {
  147.        var userNameField = document.getElementById("server.username.label");
  148.        userNameField.setAttribute("value", name);
  149.    }
  150. }
  151.  
  152. function setupAnother(event)
  153. {
  154.     window.alert("Unimplemented, see bug #19982");
  155. }
  156.