diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 12:56:51 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-08-18 12:56:51 +1200 |
commit | a90ce59795690267a0924c2b911f14fe0340a6b4 (patch) | |
tree | 5de6442a5a6cc4ed44d7b62cc75f1300a988eb84 /web/app/store/DistanceUnits.js | |
parent | afaede42a0cc8170128219bd1dfa6277e4e1809a (diff) | |
parent | 21ed9dbbd8c7be191894b11e895c1c0094b4aac6 (diff) | |
download | trackermap-server-a90ce59795690267a0924c2b911f14fe0340a6b4.tar.gz trackermap-server-a90ce59795690267a0924c2b911f14fe0340a6b4.tar.bz2 trackermap-server-a90ce59795690267a0924c2b911f14fe0340a6b4.zip |
Merge from mungingLabs into odometer
Diffstat (limited to 'web/app/store/DistanceUnits.js')
-rw-r--r-- | web/app/store/DistanceUnits.js | 22 |
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 ''; + } + }, }); |