diff options
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r-- | web/app/AttributeFormatter.js | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index 87689a28..957992da 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -139,86 +139,90 @@ Ext.define('Traccar.AttributeFormatter', { getFormatter: function (key) { var self = this; - if (key === 'latitude' || key === 'longitude') { - return function (value) { - return self.coordinateFormatter(key, value); - }; - } else if (key === 'speed') { - return this.speedFormatter; - } else if (key === 'course') { - return this.courseFormatter; - } else if (key === 'distance' || key === 'accuracy') { - return this.distanceFormatter; - } else if (key === 'duration') { - return this.durationFormatter; - } else if (key === 'deviceId') { - return this.deviceIdFormatter; - } else if (key === 'groupId') { - return this.groupIdFormatter; - } else if (key === 'geofenceId') { - return this.geofenceIdFormatter; - } else if (key === 'lastUpdate') { - return this.lastUpdateFormatter; - } else if (key === 'spentFuel') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation); - } else if (key === 'driverUniqueId') { - return this.driverUniqueIdFormatter; - } else { - return this.defaultFormatter; + + switch (key) { + case 'latitude': + case 'longitude': + return function (value) { + return self.coordinateFormatter(key, value); + }; + case 'speed': + return this.speedFormatter; + case 'course': + return this.courseFormatter; + case 'distance': + case 'accuracy': + return this.distanceFormatter; + case 'duration': + return this.durationFormatter; + case 'deviceId': + return this.deviceIdFormatter; + case 'groupId': + return this.groupIdFormatter; + case 'geofenceId': + return this.geofenceIdFormatter; + case 'lastUpdate': + return this.lastUpdateFormatter; + case 'spentFuel': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation); + case 'driverUniqueId': + return this.driverUniqueIdFormatter; + default: + return this.defaultFormatter; } }, getConverter: function (key) { - if (key === 'speed') { - return this.speedConverter; - } else if (key === 'distance' || key === 'accuracy') { - return this.distanceConverter; - } else { - return function (value) { - return value; - }; + switch (key) { + case 'speed': + return this.speedConverter; + case 'distance': + case 'accuracy': + return this.distanceConverter; + default: + return function (value) { + return value; + }; } }, getAttributeFormatter: function (key) { var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key); - if (!dataType) { - return this.defaultFormatter; - } else if (dataType === 'distance') { - return this.distanceFormatter; - } else if (dataType === 'speed') { - return this.speedFormatter; - } else if (dataType === 'driverUniqueId') { - return this.driverUniqueIdFormatter; - } else if (dataType === 'voltage') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation); - } else if (dataType === 'percentage') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, '%'); - } else if (dataType === 'temperature') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°C'); - } else if (dataType === 'volume') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation); - } else if (dataType === 'consumption') { - return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation); - } else { - return this.defaultFormatter; + + switch (dataType) { + case 'distance': + return this.distanceFormatter; + case 'speed': + return this.speedFormatter; + case 'driverUniqueId': + return this.driverUniqueIdFormatter; + case 'voltage': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation); + case 'percentage': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, '%'); + case 'temperature': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°C'); + case 'volume': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation); + case 'consumption': + return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation); + default: + return this.defaultFormatter; } }, getAttributeConverter: function (key) { var dataType = Ext.getStore('PositionAttributes').getAttributeDataType(key); - if (!dataType) { - return function (value) { - return value; - }; - } else if (dataType === 'distance') { - return this.distanceConverter; - } else if (dataType === 'speed') { - return this.speedConverter; - } else { - return function (value) { - return value; - }; + + switch (dataType) { + case 'distance': + return this.distanceConverter; + case 'speed': + return this.speedConverter; + default: + return function (value) { + return value; + }; } } }); |