!import
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Alec Flett <alecf@netscape.com>
24 * Seth Spitzer <sspitzer@netscape.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 var gPrefsBundle;
41
acctNamePageValidate
42 function acctNamePageValidate()
43 {
44 var accountname = document.getElementById("prettyName").value;
45
46 if (!accountname || accountname =="") {
47 var alertText = gPrefsBundle.getString("enterAccountName");
48 window.alert(alertText);
49 return false;
50 }
51 var pageData = parent.GetPageData();
52
53 // fix for bug #255473
54 // allow for multiple RSS accounts.
55 // if our isp.rdf file defines "wizardAutoGenerateUniqueHostname"
56 // we generate a unique hostname until we have one that doesn't exist
57 // for RSS accounts, in rss.rdf, userName, hostName and serverType
58 // default to the same thing, so we need to do this to allow for
59 // multiple RSS accounts. Note, they can all have the same pretty name.
60 if (gCurrentAccountData &&
61 gCurrentAccountData.wizardAutoGenerateUniqueHostname)
62 {
63 var serverType = parent.getCurrentServerType(pageData);
64 var userName = parent.getCurrentUserName(pageData);
65 var hostName = parent.getCurrentHostname(pageData);
66 var hostNamePref = hostName;
67 var i = 1;
68 while (parent.AccountExists(userName, hostName, serverType))
69 {
70 // if "News & Blogs" exists, try
71 // "News & Blogs-1", then "News & Blogs-2", etc.
72 hostName = hostNamePref + "-" + i;
73 i++;
74 }
75 setPageData(pageData, "server", "hostname", hostName);
76 }
77
78 setPageData(pageData, "accname", "prettyName", accountname);
79 // Set this to true so we know the user has set the name.
80 setPageData(pageData, "accname", "userset", true);
81 return true;
82 }
83
acctNamePageInit
84 function acctNamePageInit()
85 {
86 gPrefsBundle = document.getElementById("bundle_prefs");
87 var accountNameInput = document.getElementById("prettyName");
88 if (accountNameInput.value=="") {
89 var pageData = parent.GetPageData();
90 var type = parent.getCurrentServerType(pageData);
91 var protocolinfo = Components.classes["@mozilla.org/messenger/protocol/info;1?type=" + type].getService(Components.interfaces.nsIMsgProtocolInfo);
92 var accountName;
93
94 if (gCurrentAccountData && gCurrentAccountData.wizardAccountName)
95 accountName = gCurrentAccountData.wizardAccountName;
96 else if (type == "nntp")
97 accountName = pageData.newsserver.hostname.value;
98 else
99 accountName = pageData.identity.email.value;
100 accountNameInput.value = accountName;
101 }
102 }