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
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/
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
15 # The Original Code is the Firefox Preferences System.
17 # The Initial Developer of the Original Code is
19 # Portions created by the Initial Developer are Copyright (C) 2005
20 # the Initial Developer. All Rights Reserved.
23 # Ben Goodger <ben@mozilla.org>
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
40 beforeAccept:
function ()
42 var proxyTypePref = document.getElementById(
"network.proxy.type");
43 if (proxyTypePref.value == 2) {
44 this.doAutoconfigURLFixup();
48 if (proxyTypePref.value != 1)
51 var httpProxyURLPref = document.getElementById(
"network.proxy.http");
52 var httpProxyPortPref = document.getElementById(
"network.proxy.http_port");
53 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
54 if (shareProxiesPref.value) {
55 var proxyPrefs = [
"ssl",
"ftp",
"socks",
"gopher"];
56 for (var
i = 0;
i < proxyPrefs.length; ++
i) {
57 var proxyServerURLPref = document.getElementById(
"network.proxy." + proxyPrefs[
i]);
58 var proxyPortPref = document.getElementById(
"network.proxy." + proxyPrefs[i] +
"_port");
59 var backupServerURLPref = document.getElementById(
"network.proxy.backup." + proxyPrefs[i]);
60 var backupPortPref = document.getElementById(
"network.proxy.backup." + proxyPrefs[i] +
"_port");
61 backupServerURLPref.value = proxyServerURLPref.value;
62 backupPortPref.value = proxyPortPref.value;
63 proxyServerURLPref.value = httpProxyURLPref.value;
64 proxyPortPref.value = httpProxyPortPref.value;
68 var noProxiesPref = document.getElementById(
"network.proxy.no_proxies_on");
69 noProxiesPref.value = noProxiesPref.value.replace(/[;]/g,
',');
74 checkForSystemProxy:
function ()
76 if (
"@mozilla.org/system-proxy-settings;1" in Components.classes)
77 document.getElementById(
"systemPref").removeAttribute(
"hidden");
80 proxyTypeChanged:
function ()
82 var proxyTypePref = document.getElementById(
"network.proxy.type");
85 var httpProxyURLPref = document.getElementById(
"network.proxy.http");
86 httpProxyURLPref.disabled = proxyTypePref.value != 1;
87 var httpProxyPortPref = document.getElementById(
"network.proxy.http_port");
88 httpProxyPortPref.disabled = proxyTypePref.value != 1;
91 this.updateProtocolPrefs();
93 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
94 shareProxiesPref.disabled = proxyTypePref.value != 1;
96 var noProxiesPref = document.getElementById(
"network.proxy.no_proxies_on");
97 noProxiesPref.disabled = proxyTypePref.value != 1;
99 var autoconfigURLPref = document.getElementById(
"network.proxy.autoconfig_url");
100 autoconfigURLPref.disabled = proxyTypePref.value != 2;
102 this.updateReloadButton();
105 updateReloadButton:
function ()
112 var typedURL = document.getElementById(
"networkProxyAutoconfigURL").value;
113 var proxyTypeCur = document.getElementById(
"network.proxy.type").value;
116 Components.classes[
"@mozilla.org/preferences-service;1"].
117 getService(Components.interfaces.nsIPrefBranch);
118 var pacURL = prefs.getCharPref(
"network.proxy.autoconfig_url");
119 var proxyType = prefs.getIntPref(
"network.proxy.type");
121 var disableReloadPref =
122 document.getElementById(
"pref.advanced.proxies.disable_button.reload");
123 disableReloadPref.disabled =
124 (proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL);
127 readProxyType:
function ()
129 this.proxyTypeChanged();
133 updateProtocolPrefs:
function ()
135 var proxyTypePref = document.getElementById(
"network.proxy.type");
136 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
137 var proxyPrefs = [
"ssl",
"ftp",
"socks",
"gopher"];
138 for (var
i = 0;
i < proxyPrefs.length; ++
i) {
139 var proxyServerURLPref = document.getElementById(
"network.proxy." + proxyPrefs[
i]);
140 var proxyPortPref = document.getElementById(
"network.proxy." + proxyPrefs[i] +
"_port");
143 if (!shareProxiesPref.value) {
144 var backupServerURLPref = document.getElementById(
"network.proxy.backup." + proxyPrefs[i]);
145 var backupPortPref = document.getElementById(
"network.proxy.backup." + proxyPrefs[i] +
"_port");
146 if (backupServerURLPref.hasUserValue) {
147 proxyServerURLPref.value = backupServerURLPref.value;
148 backupServerURLPref.reset();
150 if (backupPortPref.hasUserValue) {
151 proxyPortPref.value = backupPortPref.value;
152 backupPortPref.reset();
156 proxyServerURLPref.updateElements();
157 proxyPortPref.updateElements();
158 proxyServerURLPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
159 proxyPortPref.disabled = proxyServerURLPref.disabled;
161 var socksVersionPref = document.getElementById(
"network.proxy.socks_version");
162 socksVersionPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
167 readProxyProtocolPref:
function (aProtocol, aIsPort)
169 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
170 if (shareProxiesPref.value) {
171 var
pref = document.getElementById(
"network.proxy.http" + (aIsPort ?
"_port" :
""));
175 var backupPref = document.getElementById(
"network.proxy.backup." + aProtocol + (aIsPort ?
"_port" :
""));
176 return backupPref.hasUserValue ? backupPref.value : undefined;
179 reloadPAC:
function ()
181 Components.classes[
"@mozilla.org/network/protocol-proxy-service;1"].
185 doAutoconfigURLFixup:
function ()
187 var autoURL = document.getElementById(
"networkProxyAutoconfigURL");
188 var autoURLPref = document.getElementById(
"network.proxy.autoconfig_url");
189 var URIFixup = Components.classes[
"@mozilla.org/docshell/urifixup;1"]
190 .getService(Components.interfaces.nsIURIFixup);
192 autoURLPref.value = autoURL.value = URIFixup.createFixupURI(autoURL.value, 0).spec;
196 readHTTPProxyServer:
function ()
198 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
199 if (shareProxiesPref.value)
200 this.updateProtocolPrefs();
204 readHTTPProxyPort:
function ()
206 var shareProxiesPref = document.getElementById(
"network.proxy.share_proxy_settings");
207 if (shareProxiesPref.value)
208 this.updateProtocolPrefs();
getService(Ci.sbIFaceplateManager)
_getSelectedPageStyle s i