aboutsummaryrefslogtreecommitdiff
path: root/web/app/store/SpeedUnits.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-09-15 12:24:13 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-09-15 12:24:13 +1200
commitd2139af877194952e3d49ca882188bcebbbd927e (patch)
treef5f6c81df6f04269a0f57d83e5fce17b8c98c346 /web/app/store/SpeedUnits.js
parent5cf1061cfcc5baf214bce145961512fd4f672621 (diff)
downloadtrackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.gz
trackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.tar.bz2
trackermap-server-d2139af877194952e3d49ca882188bcebbbd927e.zip
Update and format store classes
Diffstat (limited to 'web/app/store/SpeedUnits.js')
-rw-r--r--web/app/store/SpeedUnits.js32
1 files changed, 15 insertions, 17 deletions
diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js
index 15c52625f..037670c8d 100644
--- a/web/app/store/SpeedUnits.js
+++ b/web/app/store/SpeedUnits.js
@@ -16,27 +16,25 @@
Ext.define('Traccar.store.SpeedUnits', {
extend: 'Ext.data.Store',
- fields: ['key', 'name'],
- data: [
- {'key': 'kmh', 'name': strings.sharedKmh},
- {'key': 'mph', 'name': strings.sharedMph}
- ],
+ fields: ['key', 'name', 'factor'],
- convert: function(value, unit) {
- switch (unit) {
- case 'kmh':
- return Math.round(value * 1.852 * 10) / 10;
- case 'mph':
- return Math.round(value * 1.15078 * 10) / 10;
- }
- return value;
- },
+ data: [{
+ key: 'kmh',
+ name: strings.sharedKmh,
+ factor: 1.852
+ }, {
+ key: 'mph',
+ name: strings.sharedMph,
+ factor: 1.15078
+ }],
- getUnitName: function(unit) {
+ formatValue: function(value, unit) {
+ var model;
if (unit) {
- return this.findRecord('key', unit).get('name');
+ model = this.findRecord('key', unit);
+ return Math.round(value * model.get('factor') * 10) / 10 + ' ' + model.get('name');
} else {
- return '';
+ return value;
}
}
});