Commit dbab2d64 authored by Kathleen Brade's avatar Kathleen Brade
Browse files

Disable Username/Password when SOCKS4 is chosen.

parent 566c8a93
......@@ -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"/>
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment