feature: distance value calculation in km or miles

This commit is contained in:
Darryl Quinn 2016-01-04 22:41:27 -06:00
parent 2dfc911df7
commit a1bc4fa35b
6 changed files with 94 additions and 11 deletions

View File

@ -15,8 +15,17 @@ hr {
body table {
font-size: 12px;
border-collapse: collapse;
}
.dist-alert {
border: medium solid red;
}
.dist-norm {
border: none;
}
.navbar_select { background:black; color:white; border-radius: 10px; }
.navbar_select a:link { background:black; color:white }
.navbar_select a:visited { background:black; color:white }

View File

@ -14,8 +14,15 @@ hr {
}
body table {
font-size: 16px;
font-size: 12px;
border-collapse: collapse;
}
.dist-alert {
border: medium solid red;
}
.dist-norm {
border: none;
}
.navbar_select { background:white; color:black }
.navbar_select a:link { background:white; color:black }

View File

@ -362,6 +362,43 @@ reboot_page("/cgi-bin/status") if $parms{button_reboot};
http_header() unless $debug == 2;
html_header(nvram_get("node") . " setup", 1);
print "<body><center>\n";
print "
<script>
function updDist(x) {
var u = document.getElementById('distance_unit_text').innerHTML;
var xc= calcDistance(x,u);
var distBox = document.getElementById('dist');
var dist_hidden=document.getElementsByName('wifi_distance')[0];
document.getElementsByName('wifi_distance_disp')[0].value = x;
dist_hidden.value = xc;
// if default, then ALERT!
if(dist_hidden.value==100000) {
distBox.className = 'dist-alert';
} else {
distBox.className = 'dist-norm';
}
}
function updDistUnit(u) {
document.getElementById('distance_unit_text').innerHTML = u;
var x=document.getElementsByName('wifi_distance_disp')[0].value;
updDist(x,u);
}
function calcDistance(x, u) {
var dv=0;
if(u=='kilometers') {
dv=x*1000;
} else {
dv=x/0.00062137;
}
dv=Math.round(dv);
return dv;
}
</script>
";
alert_banner();
print "<form method=post action=/cgi-bin/setup enctype='multipart/form-data'>\n" unless $debug == 2;
print "<form method=post action=test>\n" if $debug == 2;
@ -603,8 +640,17 @@ if($wifi_proto ne "disabled")
for($i = wifi_maxpower($wifi_channel); $i >= 1; --$i) { selopt($i+$txpoweroffset ." dBm", $i, $wifi_txpower) }
print "</select>&nbsp;&nbsp;<a href=\"/help.html\#power\" target=\"_blank\"><img src=\"/qmark.png\"></a></td></tr>\n";
print "<tr><td>Distance</td>\n";
print "<td><input type=text size=8 name=wifi_distance value='$wifi_distance' title='Distance in meters to the farthest neighbor'>&nbsp;meters</td></tr>\n";
print "<tr id='dist' class='dist-norm'><td>Distance to<br />FARTHEST Node</td>\n";
$wifi_distance_disp=int($wifi_distance/1000);
print "<td><input readonly type=text size=8 name='wifi_distance_disp' value='$wifi_distance_disp' title='Distance to the farthest neighbor'>&nbsp;<span id='distance_unit_text'>kilometers</span><br />";
print "<input id='distance_slider' type='range' min='0' max='150' step='1' value='$wifi_distance_disp' oninput='updDist(this.value)' onchange='updDist(this.value)' /><br />";
print "<input type='radio' name='distance_unit' value='miles' onchange='updDistUnit(this.value)'>Miles&nbsp;";
print "<input type='radio' name='distance_unit' value='kilometers' checked onchange='updDistUnit(this.value)'>Kilometers<br />";
print "<input type='hidden' size='6' readonly name='wifi_distance' value='$wifi_distance' />";
print "</td></tr>\n";
print "<tr><td></td><td><input type=submit name=button_apply value=Apply title='Immediately use these active settings'></td></tr>\n";
}

View File

@ -14,8 +14,15 @@ hr {
}
body table {
font-size: 16px;
font-size: 12px;
border-collapse: collapse;
}
.dist-alert {
border: medium solid red;
}
.dist-norm {
border: none;
}
.navbar_select { background:black; color:red }
.navbar_select a:link { background:black; color:red }

View File

@ -14,8 +14,15 @@ hr {
}
body table {
font-size: 16px;
font-size: 12px;
border-collapse: collapse;
}
.dist-alert {
border: medium solid red;
}
.dist-norm {
border: none;
}
.navbar_select { background:black; color:white }
.navbar_select a:link { background:black; color:white }

View File

@ -14,8 +14,15 @@ hr {
}
body table {
font-size: 16px;
font-size: 12px;
border-collapse: collapse;
}
.dist-alert {
border: medium solid red;
}
.dist-norm {
border: none;
}
.navbar_select { background:black; color:yellow }
.navbar_select a:link { background:black; color:yellow }