!import
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 * Seth Spitzer <sspitzer@netscape.com>
24 * Ben Goodger <ben@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 newmessages = "";
41 var newsgroupname = "";
42 var gNewsBundle;
43 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService();
44 prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch);
45
46 var serverid = null;
47 var markreadElement = null;
48 var numberElement = null;
49
50 var server = null;
51 var nntpServer = null;
52 var args = null;
53
OnLoad
54 function OnLoad()
55 {
56 gNewsBundle = document.getElementById("bundle_news");
57
58 if ("arguments" in window && window.arguments[0]) {
59 args = window.arguments[0].QueryInterface( Components.interfaces.nsINewsDownloadDialogArgs);
60 args.hitOK = false; /* by default, act like the user hit cancel */
61 args.downloadAll = false; /* by default, act like the user did not select download all */
62
63 var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
64 server = accountManager.getIncomingServer(args.serverKey);
65 nntpServer = server.QueryInterface(Components.interfaces.nsINntpIncomingServer);
66
67 var downloadHeadersTitlePrefix = gNewsBundle.getString("downloadHeadersTitlePrefix");
68 var okButtonText = gNewsBundle.getString("okButtonText");
69
70 document.title = downloadHeadersTitlePrefix;
71
72 var infotext = gNewsBundle.getFormattedString("downloadHeadersInfoText", [args.articleCount]);
73 setText('info', infotext);
74 var okbutton = document.documentElement.getButton("accept");
75 okbutton.setAttribute("label", okButtonText);
76 okbutton.focus();
77 setText("newsgroupLabel", args.groupName);
78 }
79
80 numberElement = document.getElementById("number");
81 numberElement.value = nntpServer.maxArticles;
82
83 markreadElement = document.getElementById("markread");
84 markreadElement.checked = nntpServer.markOldRead;
85
86 return true;
87 }
88
setText
89 function setText(id, value) {
90 var element = document.getElementById(id);
91 if (!element) return;
92 if (element.hasChildNodes())
93 element.removeChild(element.firstChild);
94 var textNode = document.createTextNode(value);
95 element.appendChild(textNode);
96 }
97
OkButtonCallback
98 function OkButtonCallback() {
99 nntpServer.maxArticles = numberElement.value;
100 nntpServer.markOldRead = markreadElement.checked;
101
102 var radio = document.getElementById("all");
103 if (radio)
104 args.downloadAll = radio.selected;
105
106 args.hitOK = true;
107 return true;
108 }
109
CancelButtonCallback
110 function CancelButtonCallback() {
111 args.hitOK = false;
112 return true;
113 }
114
setupDownloadUI
115 function setupDownloadUI(enable) {
116 var checkbox = document.getElementById("markread");
117 var numberFld = document.getElementById("number");
118
119 checkbox.disabled = !enable;
120 numberFld.disabled = !enable;
121 }