From 78fc6eab38c75ea5b0f5ac9c68d8e1c1b9561b79 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 8 Feb 2022 19:01:31 -0800 Subject: [PATCH] Ensure that the mph values are also formatted Without this fix, the mph values had lots of decimal points. Note that we might not actually need to `parseFloat`, multiplying with numeric strings seems to work fine at least in chrome. ``` ic.getKmph(metersPerSecond) "10.80" KM_TO_MILES * ic.getKmph(metersPerSecond) 6.7108068 KM_TO_MILES * 10.80 6.710806 KM_TO_MILES * "3.1" 1.9262501 ``` But I presumably made the change for a reason, so let's be consistent throughout and change later if needed https://github.com/e-mission/e-mission-phone/commit/98af95d9b1965d35a3f0434670057fe2fe1eca4b --- www/js/config/imperial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/config/imperial.js b/www/js/config/imperial.js index 1503bfa62..7ca224ac5 100644 --- a/www/js/config/imperial.js +++ b/www/js/config/imperial.js @@ -30,7 +30,7 @@ angular.module('emission.config.imperial', ['emission.plugin.logger']) }; ic.getMph = function(metersPerSecond) { - return (KM_TO_MILES * ic.getKmph(metersPerSecond)); + return (KM_TO_MILES * Number.parseFloat(ic.getKmph(metersPerSecond))).toFixed(2); }; ic.getFormattedDistance = USE_IMPERIAL? ic.getFormattedDistanceInMiles : ic.getFormattedDistanceInKm;