Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 0165cdc

Browse files
Added onClick methods to all validation checks, top improve user experience
1 parent 4ff0e1e commit 0165cdc

File tree

6 files changed

+76
-16
lines changed

6 files changed

+76
-16
lines changed

webadmin/var/www/webadmin/AFP.php

+32-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,35 @@
5555
<?php echo "<div class=\"alert alert-success\">" . $accountsuccess . "</div>" ?></span>
5656
<?php } ?>
5757

58+
<script type="text/javascript">
59+
function showErr(id, valid)
60+
{
61+
if (valid || document.getElementById(id).value == "")
62+
{
63+
document.getElementById(id).style.borderColor = "";
64+
document.getElementById(id).style.backgroundColor = "";
65+
}
66+
else
67+
{
68+
document.getElementById(id).style.borderColor = "#a94442";
69+
document.getElementById(id).style.backgroundColor = "#f2dede";
70+
}
71+
}
72+
73+
function enableButton(id, enable)
74+
{
75+
document.getElementById(id).disabled = !enable;
76+
}
77+
78+
function validateafpPW()
79+
{
80+
var validPassword = (document.getElementById("afppass1").value != "");
81+
var validConfirm = (document.getElementById("afppass1").value == document.getElementById("afppass2").value);
82+
showErr("afppass2", validConfirm);
83+
enableButton("afppass", validPassword && validConfirm);
84+
}
85+
</script>
86+
5887
<div class="row">
5988
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
6089

@@ -90,13 +119,13 @@
90119
-->
91120

92121
<label class="control-label">New Password</label>
93-
<input type="password" placeholder="Required" name="afppass1" id="afppass1" class="form-control input-sm" value="" onKeyUp="validateafpPW();" onChange="validateafpPW();" />
122+
<input type="password" placeholder="Required" name="afppass1" id="afppass1" class="form-control input-sm" value="" onClick="validateafpPW();" onKeyUp="validateafpPW();" onChange="validateafpPW();" />
94123

95124
<label class="control-label">Confirm New Password</label>
96-
<input type="password" placeholder="Required" name="afppass2" id="afppass2" class="form-control input-sm" value="" onKeyUp="validateafpPW();" onChange="validateafpPW();" />
125+
<input type="password" placeholder="Required" name="afppass2" id="afppass2" class="form-control input-sm" value="" onClick="validateafpPW();" onKeyUp="validateafpPW();" onChange="validateafpPW();" />
97126
<br>
98127

99-
<input type="submit" name="afppass" id="afppass" value="Save" class="btn btn-primary" />
128+
<input type="submit" name="afppass" id="afppass" value="Save" class="btn btn-primary" disabled="disabled" />
100129
<br>
101130
<br>
102131

webadmin/var/www/webadmin/SMB.php

+31-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,35 @@
5050
<?php echo "<div class=\"alert alert-success\">" . $accountsuccess . "</div>" ?></span>
5151
<?php } ?>
5252

53+
<script type="text/javascript">
54+
function showErr(id, valid)
55+
{
56+
if (valid || document.getElementById(id).value == "")
57+
{
58+
document.getElementById(id).style.borderColor = "";
59+
document.getElementById(id).style.backgroundColor = "";
60+
}
61+
else
62+
{
63+
document.getElementById(id).style.borderColor = "#a94442";
64+
document.getElementById(id).style.backgroundColor = "#f2dede";
65+
}
66+
}
67+
68+
function enableButton(id, enable)
69+
{
70+
document.getElementById(id).disabled = !enable;
71+
}
72+
73+
function validatePW()
74+
{
75+
var validPassword = (document.getElementById("smbpass1").value != "");
76+
var validConfirm = (document.getElementById("smbpass1").value == document.getElementById("smbpass2").value);
77+
showErr("smbpass2", validConfirm);
78+
enableButton("smbpass", validPassword && validConfirm);
79+
}
80+
</script>
81+
5382
<div class="row">
5483
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
5584

@@ -85,10 +114,10 @@
85114
-->
86115

87116
<label class="control-label">New Password</label>
88-
<input type="password" name="smbpass1" id="smbpass1" class="form-control input-sm" value="" placeholder="Required" onKeyUp="validatePW();" onChange="validatePW();" />
117+
<input type="password" placeholder="Required" name="smbpass1" id="smbpass1" class="form-control input-sm" value="" onClick="validatePW();" onKeyUp="validatePW();" onChange="validatePW();" />
89118

90119
<label class="control-label">Confirm New Password</label>
91-
<input type="password" name="smbpass2" id="smbpass2" class="form-control input-sm" value="" placeholder="Required" onKeyUp="validatePW();" onChange="validatePW();" />
120+
<input type="password" placeholder="Required" name="smbpass2" id="smbpass2" class="form-control input-sm" value="" onClick="validatePW();" onKeyUp="validatePW();" onChange="validatePW();" />
92121
<br>
93122

94123
<input type="submit" name="smbpass" id="smbpass" class="btn btn-primary" value="Save" />

webadmin/var/www/webadmin/SUS.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function validateProxy()
207207
<span class="label label-default">New Branch</span>
208208

209209
<div class="input-group">
210-
<input type="text" name="branchname" id="branchname" class="form-control input-sm" value="" onKeyUp="validateBranch();" onChange="validateBranch();"/>
210+
<input type="text" name="branchname" id="branchname" class="form-control input-sm" value="" onClick="validateBranch();" onKeyUp="validateBranch();" onChange="validateBranch();"/>
211211
<span class="input-group-btn">
212212
<input type="submit" name="addbranch" id="addbranch" class="btn btn-primary btn-sm" value="Add Branch" disabled="disabled"/>
213213
</span>

webadmin/var/www/webadmin/dateTime.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ function validateTimeserver()
6868

6969
<span class="label label-default">Current Time Zone</span>
7070
<span class="description">Current time zone on the NetBoot/SUS/LDAP Proxy server</span>
71-
<span><?php echo getSystemTimeZoneMenu();?></span>
71+
<span>
72+
<select class="form-control input-sm" id="timezone" name="timezone" onClick="validateTimeserver();" onChange="validateTimeserver();">
73+
<?php echo getSystemTimeZoneMenu();?>
74+
</select>
75+
</span>
7276

7377
<span class="label label-default">Network Time Server</span>
7478
<span class="description">Server to use to synchronize the date/time (e.g. "pool.ntp.org")</span>
75-
<input type="text" name="timeserver" id="timeserver" class="form-control input-sm" value="<?php echo getCurrentTimeServer();?>" onKeyUp="validateTimeserver();" onChange="validateTimeserver();" />
79+
<input type="text" name="timeserver" id="timeserver" class="form-control input-sm" value="<?php echo getCurrentTimeServer();?>" onClick="validateTimeserver();" onKeyUp="validateTimeserver();" onChange="validateTimeserver();" />
7680

7781
<br>
7882

webadmin/var/www/webadmin/inc/functions.php

-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ function getSystemTimeZones($path="/usr/share/zoneinfo/right")
3636
function getSystemTimeZoneMenu()
3737
{
3838
$currentTZ = getCurrentTimeZone();
39-
echo "<select class=\"form-control input-sm\" id=\"timezone\" name=\"timezone\">\n";
4039
$timezone_identifiers = DateTimeZone::listIdentifiers();
4140
foreach($timezone_identifiers as $value){
4241
if (preg_match('/^(America|Australia|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//', $value))
@@ -56,7 +55,6 @@ function getSystemTimeZoneMenu()
5655
}
5756
}
5857
echo "</optgroup>\n";
59-
echo "</select>\n";
6058
}
6159

6260
function suExec($cmd)

webadmin/var/www/webadmin/networkSettings.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function validateNetwork()
141141
<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3">
142142

143143
<label class="control-label">Hostname</label>
144-
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo getCurrentHostname(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
144+
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo getCurrentHostname(); ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
145145

146146
<label class="control-label">Type</label>
147147
<!-- <select onchange="disableStaticOptions(this.value);" name="selectedNetType">
@@ -160,25 +160,25 @@ function validateNetwork()
160160
</div>
161161

162162
<label class="control-label">IP Address</label>
163-
<input type="text" name="ip" id="ip" class="form-control input-sm" value="<?php echo getCurrentIP(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
163+
<input type="text" name="ip" id="ip" class="form-control input-sm" value="<?php echo getCurrentIP(); ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
164164

165165
<label class="control-label">Netmask</label>
166-
<input type="text" name="netmask" id="netmask" class="form-control input-sm" value="<?php echo getCurrentNetmask(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
166+
<input type="text" name="netmask" id="netmask" class="form-control input-sm" value="<?php echo getCurrentNetmask(); ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
167167

168168
</div>
169169

170170
<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3">
171171

172172
<label class="control-label">Gateway</label>
173-
<input type="text" name="gateway" id="gateway" class="form-control input-sm" value="<?php echo getCurrentGateway(); ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
173+
<input type="text" name="gateway" id="gateway" class="form-control input-sm" value="<?php echo getCurrentGateway(); ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
174174

175175

176176
<label class="control-label">DNS Server 1</label>
177-
<input type="text" name="dns1" id="dns1" class="form-control input-sm" value="<?php if (isset($dns[0])) { echo $dns[0]; } ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
177+
<input type="text" name="dns1" id="dns1" class="form-control input-sm" value="<?php if (isset($dns[0])) { echo $dns[0]; } ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
178178

179179

180180
<label class="control-label">DNS Server 2</label>
181-
<input type="text" name="dns2" id="dns2" class="form-control input-sm" value="<?php if (isset($dns[1])) { echo $dns[1]; } ?>" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
181+
<input type="text" name="dns2" id="dns2" class="form-control input-sm" value="<?php if (isset($dns[1])) { echo $dns[1]; } ?>" onClick="validateNetwork();" onKeyUp="validateNetwork();" onChange="validateNetwork();" />
182182
<br>
183183

184184
<input type="submit" class="btn btn-sm <?php if (getSSHstatus()) { echo 'btn-success" value="Disable'; } else { echo'btn-danger" value="Enable'; } ?> SSH" name="SSH"/>

0 commit comments

Comments
 (0)