From 23d7b616b9c12648f1b6bb5aac4f43761c2f0fcf Mon Sep 17 00:00:00 2001 From: "Stefan.Borggraefe%gmx.de" Date: Wed, 17 May 2006 02:39:49 +0000 Subject: [PATCH] Bug 257758 Add UI for WPAD and option for using the configured SOCKS proxy for DNS lookups to proxy preferences r=neil, sr=shaver --- suite/common/pref/pref-proxies-advanced.js | 148 +++++++++++++ suite/common/pref/pref-proxies-advanced.xul | 202 ++++++++++++++++++ suite/common/pref/pref-proxies.js | 190 ++++++++++------ suite/common/pref/pref-proxies.xul | 152 ++++++------- .../common/pref/pref-proxies-advanced.dtd | 30 +++ .../en-US/chrome/common/pref/pref-proxies.dtd | 46 ++-- 6 files changed, 584 insertions(+), 184 deletions(-) create mode 100644 suite/common/pref/pref-proxies-advanced.js create mode 100644 suite/common/pref/pref-proxies-advanced.xul create mode 100644 suite/locales/en-US/chrome/common/pref/pref-proxies-advanced.dtd diff --git a/suite/common/pref/pref-proxies-advanced.js b/suite/common/pref/pref-proxies-advanced.js new file mode 100644 index 000000000000..a8e2607f1332 --- /dev/null +++ b/suite/common/pref/pref-proxies-advanced.js @@ -0,0 +1,148 @@ +var httpParent; +var httpPortParent; +var sslParent; +var sslPortParent; +var ftpParent; +var ftpPortParent; +var gopherParent; +var gopherPortParent; +var socksParent; +var socksPortParent; +var socksVersionParent; +var socksRemoteDNSParent; +var shareSettingsParent; + +var http; +var httpPort; +var ssl; +var sslPort; +var ftp; +var ftpPort; +var gopher; +var gopherPort; +var socks; +var socksPort; +var socksVersion; +var socksRemoteDNS; +var shareSettings; + +var settings; +var parentSettings; + +function onLoad() +{ + initElementVars(); + receiveSettingsFromProxyPanel(); + DoEnabling(); +} + +function initElementVars() +{ + httpParent = opener.document.getElementById("networkProxyHTTP"); + httpPortParent = opener.document.getElementById("networkProxyHTTP_Port"); + sslParent = opener.document.getElementById("networkProxySSL"); + sslPortParent = opener.document.getElementById("networkProxySSL_Port"); + ftpParent = opener.document.getElementById("networkProxyFTP"); + ftpPortParent = opener.document.getElementById("networkProxyFTP_Port"); + gopherParent = opener.document.getElementById("networkProxyGopher"); + gopherPortParent = opener.document.getElementById("networkProxyGopher_Port"); + socksParent = opener.document.getElementById("networkProxySOCKS"); + socksPortParent = opener.document.getElementById("networkProxySOCKS_Port"); + socksVersionParent = opener.document.getElementById("networkProxySOCKSVersion"); + socksRemoteDNSParent = opener.document.getElementById("networkProxySOCKSRemoteDNS"); + shareSettingsParent = opener.document.getElementById("networkProxyShareSettings"); + + http = document.getElementById("networkProxyHTTP"); + httpPort = document.getElementById("networkProxyHTTP_Port"); + ssl = document.getElementById("networkProxySSL"); + sslPort = document.getElementById("networkProxySSL_Port"); + ftp = document.getElementById("networkProxyFTP"); + ftpPort = document.getElementById("networkProxyFTP_Port"); + gopher = document.getElementById("networkProxyGopher"); + gopherPort = document.getElementById("networkProxyGopher_Port"); + socks = document.getElementById("networkProxySOCKS"); + socksPort = document.getElementById("networkProxySOCKS_Port"); + socksVersion = document.getElementById("networkProxySOCKSVersion"); + socksRemoteDNS = document.getElementById("networkProxySOCKSRemoteDNS"); + shareSettings = document.getElementById("networkProxyShareSettings"); + + // Convenience Arrays + settings = [http, httpPort, ssl, sslPort, ftp, ftpPort, gopher, gopherPort, + socks, socksPort, socksVersion, socksRemoteDNS, shareSettings]; + parentSettings = [httpParent, httpPortParent, sslParent, sslPortParent, + ftpParent, ftpPortParent, gopherParent, gopherPortParent, + socksParent, socksPortParent, socksVersionParent, + socksRemoteDNSParent, shareSettingsParent]; +} + +// Use "" instead of "0" as the default for the port number. +// "0" doesn't make sense as a port number. +function replaceZero(value) +{ + return (value == "0") ? "" : value; +} + +function receiveSettingsFromProxyPanel() +{ + // es do have a "value" property ... + http.value = httpParent.value; + httpPort.value = httpPortParent.value; + + // ... elements only a "value" attribute. + ssl.value = sslParent.getAttribute("value"); + sslPort.value = replaceZero(sslPortParent.getAttribute("value")); + ftp.value = ftpParent.getAttribute("value"); + ftpPort.value = replaceZero(ftpPortParent.getAttribute("value")); + gopher.value = gopherParent.getAttribute("value"); + gopherPort.value = replaceZero(gopherPortParent.getAttribute("value")); + socks.value = socksParent.getAttribute("value"); + socksPort.value = replaceZero(socksPortParent.getAttribute("value")); + socksVersion.value = socksVersionParent.getAttribute("value"); + socksRemoteDNS.checked = (socksRemoteDNSParent.getAttribute("value") == "true"); + shareSettings.checked = (shareSettingsParent.getAttribute("value") == "true"); +} + +function sendSettingsToProxyPanel() +{ + // es do have a "value" property ... + httpParent.value = http.value; + httpPortParent.value = httpPort.value; + + // ... elements only a "value" attribute. + sslParent.setAttribute("value", ssl.value); + sslPortParent.setAttribute("value", sslPort.value); + ftpParent.setAttribute("value", ftp.value); + ftpPortParent.setAttribute("value", ftpPort.value); + gopherParent.setAttribute("value", gopher.value); + gopherPortParent.setAttribute("value", gopherPort.value); + socksParent.setAttribute("value", socks.value); + socksPortParent.setAttribute("value", socksPort.value); + socksVersionParent.setAttribute("value", socksVersion.value); + socksRemoteDNSParent.setAttribute("value", socksRemoteDNS.checked); + shareSettingsParent.setAttribute("value", shareSettings.checked); +} + +function DoProxyCopy() +{ + if (shareSettings.checked) + { + ftp.value = gopher.value = ssl.value = http.value; + ftpPort.value = gopherPort.value = sslPort.value = httpPort.value; + } +} + +function DoEnabling() +{ + ftp.disabled = gopher.disabled = ssl.disabled = + ftpPort.disabled = gopherPort.disabled = sslPort.disabled = + shareSettings.checked; + + disableLockedElements(); +} + +function disableLockedElements() +{ + for (var i = 0; i < parentSettings.length; i++) + if (parentSettings[i].getAttribute("disabled") == "true") + settings[i].disabled = true; +} diff --git a/suite/common/pref/pref-proxies-advanced.xul b/suite/common/pref/pref-proxies-advanced.xul new file mode 100644 index 000000000000..97fafdc579ea --- /dev/null +++ b/suite/common/pref/pref-proxies-advanced.xul @@ -0,0 +1,202 @@ + + + + + + + + +