aboutsummaryrefslogtreecommitdiff
path: root/web/app/store/DistanceUnits.js
diff options
context:
space:
mode:
authoramilasilva88 <amilasilva88@gmail.com>2015-08-13 20:28:58 +0800
committeramilasilva88 <amilasilva88@gmail.com>2015-08-13 20:28:58 +0800
commit0350d762a7c08199e79dc401b6c6821d7e2a21bd (patch)
tree5b0751fb43278026aee2c153ae131e17776beecd /web/app/store/DistanceUnits.js
parenta5b29b0e5df4ba84c8eaa8944258b9c9e12472db (diff)
downloadtrackermap-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.tar.gz
trackermap-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.tar.bz2
trackermap-server-0350d762a7c08199e79dc401b6c6821d7e2a21bd.zip
Added ODOMeter and Modification to Mobile UI
Diffstat (limited to 'web/app/store/DistanceUnits.js')
-rw-r--r--web/app/store/DistanceUnits.js22
1 files changed, 21 insertions, 1 deletions
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 '';
+ }
+ },
});