aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/app/AttributeFormatter.js48
1 files changed, 13 insertions, 35 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 423492dd..3f7c1276 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -18,6 +18,14 @@
Ext.define('Traccar.AttributeFormatter', {
singleton: true,
+ numberFormatterFactory: function (precision, suffix) {
+ return function (value) {
+ if (value !== undefined) {
+ return Number(value.toFixed(precision)) + ' ' + suffix;
+ }
+ };
+ },
+
coordinateFormatter: function (key, value) {
return Ext.getStore('CoordinateFormats').formatValue(key, value, Traccar.app.getPreference('coordinateFormat'));
},
@@ -43,36 +51,6 @@ Ext.define('Traccar.AttributeFormatter', {
return Ext.getStore('DistanceUnits').convertValue(value, Traccar.app.getPreference('distanceUnit'));
},
- voltageFormatter: function (value) {
- if (value !== undefined) {
- return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedVoltAbbreviation;
- }
- },
-
- percentageFormatter: function (value) {
- if (value !== undefined) {
- return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' %';
- }
- },
-
- temperatureFormatter: function (value) {
- if (value !== undefined) {
- return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' °C';
- }
- },
-
- volumeFormatter: function (value) {
- if (value !== undefined) {
- return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterAbbreviation;
- }
- },
-
- consumptionFormatter: function (value) {
- if (value !== undefined) {
- return Number(value.toFixed(Traccar.Style.numberPrecision)) + ' ' + Strings.sharedLiterPerHourAbbreviation;
- }
- },
-
hoursFormatter: function (value) {
var hours = Math.round(value / 3600000);
return (hours + ' ' + Strings.sharedHourAbbreviation);
@@ -171,15 +149,15 @@ Ext.define('Traccar.AttributeFormatter', {
} else if (dataType === 'speed') {
return this.speedFormatter;
} else if (dataType === 'voltage') {
- return this.voltageFormatter;
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedVoltAbbreviation);
} else if (dataType === 'percentage') {
- return this.percentageFormatter;
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, '%');
} else if (dataType === 'temperature') {
- return this.temperatureFormatter;
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, '°C');
} else if (dataType === 'volume') {
- return this.volumeFormatter;
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterAbbreviation);
} else if (dataType === 'consumption') {
- return this.consumptionFormatter;
+ return this.numberFormatterFactory(Traccar.Style.numberPrecision, Strings.sharedLiterPerHourAbbreviation);
} else {
return this.defaultFormatter;
}