diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-03 21:01:45 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-03 21:01:45 +1300 |
commit | 48f981a2a9755fb0af6497020e499bb0883e0e1f (patch) | |
tree | ac960f950e4f37aec2614a97a706aed34a1fb2db /web/app/AttributeFormatter.js | |
parent | d16121684ecae7646aa87616a64d60978d087bc0 (diff) | |
download | trackermap-server-48f981a2a9755fb0af6497020e499bb0883e0e1f.tar.gz trackermap-server-48f981a2a9755fb0af6497020e499bb0883e0e1f.tar.bz2 trackermap-server-48f981a2a9755fb0af6497020e499bb0883e0e1f.zip |
Enable JavaScript strict mode
Diffstat (limited to 'web/app/AttributeFormatter.js')
-rw-r--r-- | web/app/AttributeFormatter.js | 92 |
1 files changed, 48 insertions, 44 deletions
diff --git a/web/app/AttributeFormatter.js b/web/app/AttributeFormatter.js index b4720be61..fe50e0d99 100644 --- a/web/app/AttributeFormatter.js +++ b/web/app/AttributeFormatter.js @@ -13,49 +13,53 @@ * 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, styles.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, styles.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; + } } - } -}); + }); + +})(); |