Added extended unit settings
Added some code to enable the user to configure unit selection in a more detailed fashion. you can now select either metric or imperial, or both, and even set which one of those should be displayed first.
This commit is contained in:
parent
ab8c4db85b
commit
a531327533
4 changed files with 178 additions and 116 deletions
public_html
|
@ -486,118 +486,6 @@ function reaper() {
|
|||
PlanesOrdered = newPlanes;
|
||||
refreshTableInfo();
|
||||
refreshSelected();
|
||||
}
|
||||
|
||||
//
|
||||
// formatting helpers
|
||||
//
|
||||
|
||||
var TrackDirections = ["North","Northeast","East","Southeast","South","Southwest","West","Northwest"];
|
||||
|
||||
// track in degrees (0..359)
|
||||
function format_track_brief(track) {
|
||||
if (track === null) return "";
|
||||
return Math.round(track);
|
||||
}
|
||||
|
||||
// track in degrees (0..359)
|
||||
function format_track_long(track) {
|
||||
if (track === null) return "n/a";
|
||||
var trackDir = Math.floor((360 + track % 360 + 22.5) / 45) % 8;
|
||||
return Math.round(track) + DEGREES + NBSP + "(" + TrackDirections[trackDir] + ")";
|
||||
}
|
||||
|
||||
// alt in ft
|
||||
function format_altitude_brief(alt, vr) {
|
||||
var alt_text;
|
||||
|
||||
if (alt === null)
|
||||
return "";
|
||||
if (alt === "ground")
|
||||
return "ground";
|
||||
|
||||
if (Metric)
|
||||
alt_text = Math.round(alt / 3.2828) + NBSP;
|
||||
else
|
||||
alt_text = Math.round(alt) + NBSP;
|
||||
|
||||
if (vr > 128)
|
||||
return alt_text + UP_TRIANGLE;
|
||||
else if (vr < -128)
|
||||
return alt_text + DOWN_TRIANGLE;
|
||||
else
|
||||
return alt_text + NBSP;
|
||||
}
|
||||
|
||||
// alt in ft
|
||||
function format_altitude_long(alt, vr) {
|
||||
var alt_text;
|
||||
|
||||
if (alt === null)
|
||||
return "n/a";
|
||||
if (alt === "ground")
|
||||
return "on ground";
|
||||
|
||||
if (Metric)
|
||||
alt_text = Math.round(alt / 3.2828) + NBSP + "m / " + Math.round(alt) + NBSP + "ft";
|
||||
else
|
||||
alt_text = Math.round(alt) + NBSP + "ft / " + Math.round(alt / 3.2828) + NBSP + "m";
|
||||
|
||||
if (vr > 128)
|
||||
return UP_TRIANGLE + NBSP + alt_text;
|
||||
else if (vr < -128)
|
||||
return DOWN_TRIANGLE + NBSP + alt_text;
|
||||
else
|
||||
return alt_text;
|
||||
}
|
||||
|
||||
// speed in kts
|
||||
function format_speed_brief(speed) {
|
||||
if (speed === null)
|
||||
return "";
|
||||
|
||||
if (Metric)
|
||||
return Math.round(speed * 1.852);
|
||||
else
|
||||
return Math.round(speed);
|
||||
}
|
||||
|
||||
// speed in kts
|
||||
function format_speed_long(speed) {
|
||||
if (speed === null)
|
||||
return "n/a";
|
||||
|
||||
if (Metric)
|
||||
return Math.round(speed * 1.852) + NBSP + "km/h / " + Math.round(speed) + NBSP + "kt";
|
||||
else
|
||||
return Math.round(speed) + NBSP + "kt / " + Math.round(speed * 1.852) + NBSP + "km/h";
|
||||
}
|
||||
|
||||
// dist in metres
|
||||
function format_distance_brief(dist) {
|
||||
if (dist === null)
|
||||
return "";
|
||||
|
||||
if (Metric)
|
||||
return (dist/1000).toFixed(1);
|
||||
else
|
||||
return (dist/1852).toFixed(1);
|
||||
}
|
||||
|
||||
// dist in metres
|
||||
function format_distance_long(dist) {
|
||||
if (dist === null)
|
||||
return "n/a";
|
||||
|
||||
if (Metric)
|
||||
return (dist/1000).toFixed(1) + " km / " + (dist/1852).toFixed(1) + " NM";
|
||||
else
|
||||
return (dist/1852).toFixed(1) + " NM / " + (dist/1000).toFixed(1) + " km";
|
||||
}
|
||||
|
||||
// p as a LatLng
|
||||
function format_latlng(p) {
|
||||
return p.lat().toFixed(3) + DEGREES + "," + NBSP + p.lng().toFixed(3) + DEGREES;
|
||||
}
|
||||
|
||||
// Refresh the detail window about the plane
|
||||
|
@ -898,7 +786,7 @@ function drawCircle(marker, distance) {
|
|||
}
|
||||
|
||||
distance *= 1000.0;
|
||||
if (!Metric) {
|
||||
if (!EnableMetric) {
|
||||
distance *= 1.852;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue