aboutsummaryrefslogtreecommitdiff
path: root/web/app/AttributeFormatter.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r--web/app/AttributeFormatter.js92
1 files changed, 44 insertions, 48 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js
index 3f8f346c0..b7b2d01a6 100644
--- a/web/app/AttributeFormatter.js
+++ b/web/app/AttributeFormatter.js
@@ -13,53 +13,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function () {
- 'use strict';
- Ext.define('Traccar.AttributeFormatter', {
- singleton: true,
-
- coordinateFormatter: function (value) {
- return value.toFixed(6);
- },
-
- speedFormatter: function (value) {
- return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit'));
- },
-
- courseFormatter: function (value) {
- var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
- return courseValues[Math.floor(value / 45)];
- },
-
- distanceFormatter: function (value) {
- return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
- },
-
- defaultFormatter: function (value) {
- if (typeof value === 'number') {
- return value.toFixed(2);
- } else if (typeof value === 'boolean') {
- return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no;
- } else if (value instanceof Date) {
- return Ext.Date.format(value, Traccar.Style.dateTimeFormat);
- }
- return value;
- },
-
- getFormatter: function (key) {
- if (key === 'latitude' || key === 'longitude') {
- return this.coordinateFormatter;
- } else if (key === 'speed') {
- return this.speedFormatter;
- } else if (key === 'course') {
- return this.courseFormatter;
- } else if (key === 'distance' || key === 'odometer') {
- return this.distanceFormatter;
- } else {
- return this.defaultFormatter;
- }
+Ext.define('Traccar.AttributeFormatter', {
+ singleton: true,
+
+ coordinateFormatter: function (value) {
+ return value.toFixed(6);
+ },
+
+ speedFormatter: function (value) {
+ return Ext.getStore('SpeedUnits').formatValue(value, Traccar.app.getPreference('speedUnit'));
+ },
+
+ courseFormatter: function (value) {
+ var courseValues = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'];
+ return courseValues[Math.floor(value / 45)];
+ },
+
+ distanceFormatter: function (value) {
+ return Ext.getStore('DistanceUnits').formatValue(value, Traccar.app.getPreference('distanceUnit'));
+ },
+
+ defaultFormatter: function (value) {
+ if (typeof value === 'number') {
+ return value.toFixed(2);
+ } else if (typeof value === 'boolean') {
+ return value ? Ext.Msg.buttonText.yes : Ext.Msg.buttonText.no;
+ } else if (value instanceof Date) {
+ return Ext.Date.format(value, Traccar.Style.dateTimeFormat);
}
- });
-
-})();
+ return value;
+ },
+
+ getFormatter: function (key) {
+ if (key === 'latitude' || key === 'longitude') {
+ return this.coordinateFormatter;
+ } else if (key === 'speed') {
+ return this.speedFormatter;
+ } else if (key === 'course') {
+ return this.courseFormatter;
+ } else if (key === 'distance' || key === 'odometer') {
+ return this.distanceFormatter;
+ } else {
+ return this.defaultFormatter;
+ }
+ }
+});