From 540e5f8e95843cab7a35c1ab9e3a31682b03b37e Mon Sep 17 00:00:00 2001 From: James Wilson Date: Fri, 3 Aug 2018 18:39:13 -0500 Subject: [PATCH] Just use ft/m for the Rc display --- public_html/formatter.js | 22 +++++++++++++++++++++- public_html/script.js | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/public_html/formatter.js b/public_html/formatter.js index 014c4c5..2aca7df 100644 --- a/public_html/formatter.js +++ b/public_html/formatter.js @@ -12,7 +12,8 @@ var UnitLabels = { 'altitude': { metric: "m", imperial: "ft", nautical: "ft"}, 'speed': { metric: "km/h", imperial: "mph", nautical: "kt" }, 'distance': { metric: "km", imperial: "mi", nautical: "NM" }, - 'verticalRate': { metric: "m/s", imperial: "ft/min", nautical: "ft/min" } + 'verticalRate': { metric: "m/s", imperial: "ft/min", nautical: "ft/min" }, + 'distanceShort': {metric: "m", imperial: "ft", nautical: "m"} }; // formatting helpers @@ -156,6 +157,16 @@ function format_distance_long(dist, displayUnits, fixed) { return dist_text; } +function format_distace_short (dist, displayUnits) { + if (dist === null) { + return "n/a"; + } + + var dist_text = Math.round(convert_distance_short(dist, displayUnits)) + NBSP + get_unit_label("distanceShort", displayUnits); + + return dist_text; +} + // dist in meters function convert_distance(dist, displayUnits) { if (displayUnits === "metric") { @@ -167,6 +178,15 @@ function convert_distance(dist, displayUnits) { return (dist / 1852); // meters to nautical miles } +// dist in meters +// converts meters to feet or just returns meters +function convert_distance_short(dist, displayUnits) { + if (displayUnits === "imperial") { + return (dist * 3.28084); // meters to feet + } + return dist; // just meters +} + // rate in ft/min function format_vert_rate_brief(rate, displayUnits) { if (rate === null || rate === undefined) { diff --git a/public_html/script.js b/public_html/script.js index 18610c0..a2b6d91 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -1044,7 +1044,7 @@ function refreshSelected() { } else if (selected.rc == 0) { $('#selected_rc').text("unknown"); } else { - $('#selected_rc').text(format_distance_long(selected.rc, DisplayUnits)); + $('#selected_rc').text(format_distace_short(selected.rc, DisplayUnits)); } if (selected.sil == null || selected.sil_type == null) {