diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:48:54 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 13:48:54 +1200 |
commit | c06de84d316e7c67f6d22e12f855e2df34bbc3fb (patch) | |
tree | f7ab337c360bf50a79855787e9fa80e45ebd808c /web/app/store/DistanceUnits.js | |
parent | afaede42a0cc8170128219bd1dfa6277e4e1809a (diff) | |
parent | 3ad3edfadba59e94d95e967e9d5cd28ae671cae4 (diff) | |
download | trackermap-server-c06de84d316e7c67f6d22e12f855e2df34bbc3fb.tar.gz trackermap-server-c06de84d316e7c67f6d22e12f855e2df34bbc3fb.tar.bz2 trackermap-server-c06de84d316e7c67f6d22e12f855e2df34bbc3fb.zip |
Merge branch odometer
Diffstat (limited to 'web/app/store/DistanceUnits.js')
-rw-r--r-- | web/app/store/DistanceUnits.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js index 506f1077c..653bf6efb 100644 --- a/web/app/store/DistanceUnits.js +++ b/web/app/store/DistanceUnits.js @@ -20,5 +20,23 @@ Ext.define('Traccar.store.DistanceUnits', { data: [ {'key': 'km', 'name': strings.sharedKm}, {'key': 'mi', 'name': strings.sharedMi} - ] + ], + + convert: function(value, unit) { + switch (unit) { + case 'km': + return Math.round(value * 0.1) / 100; + case 'mi': + return Math.round(value * 0.0621371) / 100; + } + return value; + }, + + getUnitName: function(unit) { + if (unit) { + return this.findRecord('key', unit).get('name'); + } else { + return ''; + } + } }); |