| 1 |
|
|---|
| 2 |
var gProxyDialog = { |
|---|
| 3 |
beforeAccept: function () |
|---|
| 4 |
{ |
|---|
| 5 |
var proxyTypePref = document.getElementById("network.proxy.type"); |
|---|
| 6 |
if (proxyTypePref.value == 2) { |
|---|
| 7 |
this.doAutoconfigURLFixup(); |
|---|
| 8 |
return true; |
|---|
| 9 |
} |
|---|
| 10 |
|
|---|
| 11 |
if (proxyTypePref.value != 1) |
|---|
| 12 |
return true; |
|---|
| 13 |
|
|---|
| 14 |
var httpProxyURLPref = document.getElementById("network.proxy.http"); |
|---|
| 15 |
var httpProxyPortPref = document.getElementById("network.proxy.http_port"); |
|---|
| 16 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 17 |
if (shareProxiesPref.value) { |
|---|
| 18 |
var proxyPrefs = ["ssl", "socks"]; |
|---|
| 19 |
for (var i = 0; i < proxyPrefs.length; ++i) { |
|---|
| 20 |
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]); |
|---|
| 21 |
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port"); |
|---|
| 22 |
var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]); |
|---|
| 23 |
var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port"); |
|---|
| 24 |
backupServerURLPref.value = proxyServerURLPref.value; |
|---|
| 25 |
backupPortPref.value = proxyPortPref.value; |
|---|
| 26 |
proxyServerURLPref.value = httpProxyURLPref.value; |
|---|
| 27 |
proxyPortPref.value = httpProxyPortPref.value; |
|---|
| 28 |
} |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
return true; |
|---|
| 32 |
}, |
|---|
| 33 |
|
|---|
| 34 |
proxyTypeChanged: function () |
|---|
| 35 |
{ |
|---|
| 36 |
var proxyTypePref = document.getElementById("network.proxy.type"); |
|---|
| 37 |
|
|---|
| 38 |
// Update http |
|---|
| 39 |
var httpProxyURLPref = document.getElementById("network.proxy.http"); |
|---|
| 40 |
httpProxyURLPref.disabled = proxyTypePref.value != 1; |
|---|
| 41 |
var httpProxyPortPref = document.getElementById("network.proxy.http_port"); |
|---|
| 42 |
httpProxyPortPref.disabled = proxyTypePref.value != 1; |
|---|
| 43 |
|
|---|
| 44 |
// Now update the other protocols |
|---|
| 45 |
this.updateProtocolPrefs(); |
|---|
| 46 |
|
|---|
| 47 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 48 |
shareProxiesPref.disabled = proxyTypePref.value != 1; |
|---|
| 49 |
|
|---|
| 50 |
var autoconfigURLPref = document.getElementById("network.proxy.autoconfig_url"); |
|---|
| 51 |
autoconfigURLPref.disabled = proxyTypePref.value != 2; |
|---|
| 52 |
|
|---|
| 53 |
var disableReloadPref = document.getElementById("pref.advanced.proxies.disable_button.reload"); |
|---|
| 54 |
disableReloadPref.disabled = proxyTypePref.value != 2; |
|---|
| 55 |
}, |
|---|
| 56 |
|
|---|
| 57 |
readProxyType: function () |
|---|
| 58 |
{ |
|---|
| 59 |
this.proxyTypeChanged(); |
|---|
| 60 |
return undefined; |
|---|
| 61 |
}, |
|---|
| 62 |
|
|---|
| 63 |
updateProtocolPrefs: function () |
|---|
| 64 |
{ |
|---|
| 65 |
var proxyTypePref = document.getElementById("network.proxy.type"); |
|---|
| 66 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 67 |
var proxyPrefs = ["ssl", "socks"]; |
|---|
| 68 |
for (var i = 0; i < proxyPrefs.length; ++i) { |
|---|
| 69 |
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]); |
|---|
| 70 |
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port"); |
|---|
| 71 |
|
|---|
| 72 |
// Restore previous per-proxy custom settings, if present. |
|---|
| 73 |
if (!shareProxiesPref.value) { |
|---|
| 74 |
var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]); |
|---|
| 75 |
var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port"); |
|---|
| 76 |
if (backupServerURLPref.hasUserValue) { |
|---|
| 77 |
proxyServerURLPref.value = backupServerURLPref.value; |
|---|
| 78 |
backupServerURLPref.reset(); |
|---|
| 79 |
} |
|---|
| 80 |
if (backupPortPref.hasUserValue) { |
|---|
| 81 |
proxyPortPref.value = backupPortPref.value; |
|---|
| 82 |
backupPortPref.reset(); |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
proxyServerURLPref.updateElements(); |
|---|
| 87 |
proxyPortPref.updateElements(); |
|---|
| 88 |
proxyServerURLPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value; |
|---|
| 89 |
proxyPortPref.disabled = proxyServerURLPref.disabled; |
|---|
| 90 |
} |
|---|
| 91 |
var socksVersionPref = document.getElementById("network.proxy.socks_version"); |
|---|
| 92 |
socksVersionPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value; |
|---|
| 93 |
|
|---|
| 94 |
return undefined; |
|---|
| 95 |
}, |
|---|
| 96 |
|
|---|
| 97 |
readProxyProtocolPref: function (aProtocol, aIsPort) |
|---|
| 98 |
{ |
|---|
| 99 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 100 |
if (shareProxiesPref.value) { |
|---|
| 101 |
var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : "")); |
|---|
| 102 |
return pref.value; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
var backupPref = document.getElementById("network.proxy.backup." + aProtocol + (aIsPort ? "_port" : "")); |
|---|
| 106 |
return backupPref.hasUserValue ? backupPref.value : undefined; |
|---|
| 107 |
}, |
|---|
| 108 |
|
|---|
| 109 |
reloadPAC: function () |
|---|
| 110 |
{ |
|---|
| 111 |
var autoURL = document.getElementById("networkProxyAutoconfigURL"); |
|---|
| 112 |
var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"] |
|---|
| 113 |
.getService(Components.interfaces.nsPIProtocolProxyService); |
|---|
| 114 |
pps.configureFromPAC(autoURL.value); |
|---|
| 115 |
}, |
|---|
| 116 |
|
|---|
| 117 |
doAutoconfigURLFixup: function () |
|---|
| 118 |
{ |
|---|
| 119 |
var autoURL = document.getElementById("networkProxyAutoconfigURL"); |
|---|
| 120 |
var autoURLPref = document.getElementById("network.proxy.autoconfig_url"); |
|---|
| 121 |
var URIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"] |
|---|
| 122 |
.getService(Components.interfaces.nsIURIFixup); |
|---|
| 123 |
try { |
|---|
| 124 |
autoURLPref.value = autoURL.value = URIFixup.createFixupURI(autoURL.value, 0).spec; |
|---|
| 125 |
} catch(ex) {} |
|---|
| 126 |
}, |
|---|
| 127 |
|
|---|
| 128 |
readHTTPProxyServer: function () |
|---|
| 129 |
{ |
|---|
| 130 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 131 |
if (shareProxiesPref.value) |
|---|
| 132 |
this.updateProtocolPrefs(); |
|---|
| 133 |
return undefined; |
|---|
| 134 |
}, |
|---|
| 135 |
|
|---|
| 136 |
readHTTPProxyPort: function () |
|---|
| 137 |
{ |
|---|
| 138 |
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); |
|---|
| 139 |
if (shareProxiesPref.value) |
|---|
| 140 |
this.updateProtocolPrefs(); |
|---|
| 141 |
return undefined; |
|---|
| 142 |
} |
|---|
| 143 |
}; |
|---|