From 0350d762a7c08199e79dc401b6c6821d7e2a21bd Mon Sep 17 00:00:00 2001 From: amilasilva88 Date: Thu, 13 Aug 2015 20:28:58 +0800 Subject: Added ODOMeter and Modification to Mobile UI --- web/app/store/DistanceUnits.js | 22 +++++++++++++++++++++- web/app/store/SpeedUnits.js | 6 ++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'web/app/store') diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 506f1077c..7f0f93b70 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -20,5 +20,25 @@ Ext.define('Traccar.store.DistanceUnits', { data: [ {'key': 'km', 'name': strings.sharedKm}, {'key': 'mi', 'name': strings.sharedMi} - ] + ], + + convert: function(value, unit) { + switch (unit) { + case 'km': + value = value * 0.001; + return Math.round(value * 100) / 100; + case 'mi': + value = value * 0.000621371; + return Math.round(value * 100) / 100; + } + return value; + }, + + getUnitName: function(unit) { + if (unit) { + return this.findRecord('key', unit).get('name'); + } else { + return ''; + } + }, }); diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js index 78686fbb9..934d03717 100644 --- a/web/app/store/SpeedUnits.js +++ b/web/app/store/SpeedUnits.js @@ -25,9 +25,11 @@ Ext.define('Traccar.store.SpeedUnits', { convert: function(value, unit) { switch (unit) { case 'kmh': - return value * 1.852; + value = value * 1.852; + return Math.round(value * 10) / 10; case 'mph': - return value * 1.15078; + value = value * 1.15078; + return Math.round(value * 10) / 10; } return value; }, -- cgit v1.2.3