diff options
Diffstat (limited to 'comm/mailnews/base/prefs/content/aw-incoming.js')
-rw-r--r-- | comm/mailnews/base/prefs/content/aw-incoming.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/comm/mailnews/base/prefs/content/aw-incoming.js b/comm/mailnews/base/prefs/content/aw-incoming.js new file mode 100644 index 0000000000..a4f746d71d --- /dev/null +++ b/comm/mailnews/base/prefs/content/aw-incoming.js @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* import-globals-from AccountWizard.js */ + +var { cleanUpHostName, isLegalHostNameOrIP } = ChromeUtils.import( + "resource:///modules/hostnameUtils.jsm" +); +var { NntpUtils } = ChromeUtils.import("resource:///modules/NntpUtils.jsm"); + +function incomingPageValidate() { + let hostName = cleanUpHostName(document.getElementById("newsServer").value); + + let hasAccount = false; + let server = NntpUtils.findServer(hostName); + if (server) { + // It's OK if a server exists, as long as it's not used by any account. + hasAccount = MailServices.accounts.FindAccountForServer(server); + } + // Can advance if it's a legal host name and we do not already have a server + // in use with the same host name. + document.querySelector("wizard").canAdvance = + !!isLegalHostNameOrIP(hostName) && !hasAccount; +} + +function incomingPageUnload() { + parent.GetPageData().hostname = cleanUpHostName( + document.getElementById("newsServer").value + ); + + return true; +} + +function incomingPageInit() { + var pageData = parent.GetPageData(); + if (pageData.hostname) { + document.getElementById("newsServer").value = pageData.hostname; + } + incomingPageValidate(); +} |