[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] Disable Username/Password when SOCKS4 is chosen.



commit dbab2d6402690f2083f113a6f39c42b4b4c40575
Author: Kathy Brade <brade@xxxxxxxxxxxxxx>
Date:   Tue Apr 30 09:39:56 2013 -0400

    Disable Username/Password when SOCKS4 is chosen.
---
 src/chrome/content/network-settings-overlay.xul |    8 +++--
 src/chrome/content/network-settings.js          |   43 ++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/src/chrome/content/network-settings-overlay.xul b/src/chrome/content/network-settings-overlay.xul
index 0061d5f..64dc366 100644
--- a/src/chrome/content/network-settings-overlay.xul
+++ b/src/chrome/content/network-settings-overlay.xul
@@ -29,13 +29,15 @@
           </hbox>
         </row>
         <row align="center">
-          <label value="&torsettings.useProxy.username;"
+          <label id="proxyUsernameLabel"
+                 value="&torsettings.useProxy.username;"
                  control="proxyUsername" style="text-align:right" />
           <hbox align="center">
             <textbox id="proxyUsername" size="14" flex="1"
                      placeholder="&torsettings.optional;" />
             <separator orient="vertical" />
-            <label value="&torsettings.useProxy.password;"
+            <label id="proxyPasswordLabel"
+                   value="&torsettings.useProxy.password;"
                    control="proxyPassword"/>
             <textbox id="proxyPassword" size="14" type="password"
                      placeholder="&torsettings.optional;" />
@@ -45,7 +47,7 @@
           <label value="&torsettings.useProxy.type;" control="proxyType"
                  style="text-align:right" />
           <hbox align="center">
-            <menulist id="proxyType">
+            <menulist id="proxyType" oncommand="onProxyTypeChange()">
               <menupopup id="proxyType_menuPopup">
                 <menuitem label="&torsettings.useProxy.type.socks4;"
                           value="SOCKS4"/>
diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index 0af6d90..ce35a12 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -311,6 +311,38 @@ function setButtonAttr(aID, aAttr, aValue)
 }
 
 
+function enableTextBox(aID, aEnable)
+{
+  if (!aID)
+    return;
+
+  var textbox = document.getElementById(aID);
+  if (textbox)
+  {
+    var label = document.getElementById(aID + "Label");
+    if (aEnable)
+    {
+      if (label)
+        label.removeAttribute("disabled");
+
+      textbox.removeAttribute("disabled");
+      var s = textbox.getAttribute("origPlaceholder");
+      if (s)
+        textbox.setAttribute("placeholder", s);
+    }
+    else
+    {
+      if (label)
+        label.setAttribute("disabled", true);
+
+      textbox.setAttribute("disabled", true);
+      textbox.setAttribute("origPlaceholder", textbox.placeholder);
+      textbox.removeAttribute("placeholder");
+    }
+  }
+}
+
+
 function overrideButtonLabel(aID, aLabelKey)
 {
   var btn = document.documentElement.getButton(aID);
@@ -337,6 +369,15 @@ function restoreButtonLabel(aID)
 }
 
 
+function onProxyTypeChange()
+{
+  var proxyType = getElemValue(kProxyTypeMenulist, null);
+  var mayHaveCredentials = (proxyType != "SOCKS4");
+  enableTextBox(kProxyUsername, mayHaveCredentials); 
+  enableTextBox(kProxyPassword, mayHaveCredentials); 
+}
+
+
 function onCancel()
 {
   if (gRestoreAfterHelpPanelID) // Is help open?
@@ -423,7 +464,6 @@ function initProxySettings()
   {
     proxyType = "SOCKS4";
     proxyAddrPort = reply.retVal;
-    // TODO: disable user and password fields.
   }
   else
   {
@@ -474,6 +514,7 @@ function initProxySettings()
   setYesNoRadioValue(kWizardProxyRadioGroup, haveProxy);
   setElemValue(kUseProxyCheckbox, haveProxy);
   setElemValue(kProxyTypeMenulist, proxyType);
+  onProxyTypeChange();
 
   var proxyAddr, proxyPort;
   if (proxyAddrPort)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits