aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-09 13:26:33 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-09 13:26:33 +1200
commitfe7b8bd58e23e289a041bc7c9a5d6c37f085419a (patch)
treed28b58d1ea3b4fcd6c715c4f2d2e2e04cb91c208
parent70d22de4205aec294660378f0d854cbc32c7a6b8 (diff)
downloadtraccar-server-fe7b8bd58e23e289a041bc7c9a5d6c37f085419a.tar.gz
traccar-server-fe7b8bd58e23e289a041bc7c9a5d6c37f085419a.tar.bz2
traccar-server-fe7b8bd58e23e289a041bc7c9a5d6c37f085419a.zip
Fix issues in JavaScript code
-rw-r--r--web/app/GeofenceConverter.js16
-rw-r--r--web/app/controller/Root.js10
-rw-r--r--web/app/store/CommandTypes.js15
-rw-r--r--web/app/view/AttributesController.js25
-rw-r--r--web/app/view/BaseMap.js2
-rw-r--r--web/app/view/BasePermissionsController.js6
-rw-r--r--web/app/view/DevicesController.js10
-rw-r--r--web/app/view/GeofenceMap.js4
-rw-r--r--web/app/view/GroupsController.js7
-rw-r--r--web/app/view/Notifications.js9
-rw-r--r--web/app/view/NotificationsController.js9
11 files changed, 60 insertions, 53 deletions
diff --git a/web/app/GeofenceConverter.js b/web/app/GeofenceConverter.js
index d104ef127..ebe121385 100644
--- a/web/app/GeofenceConverter.js
+++ b/web/app/GeofenceConverter.js
@@ -20,7 +20,7 @@ Ext.define('Traccar.GeofenceConverter', {
wktToGeometry: function (mapView, wkt) {
var geometry, projection, resolutionAtEquator, pointResolution, resolutionFactor, points = [], center, radius,
content, i, lat, lon, coordinates;
- if (wkt.startsWith("POLYGON")) {
+ if (wkt.startsWith('POLYGON')) {
content = wkt.match(/\([^\(\)]+\)/);
if (content !== null) {
coordinates = content[0].match(/-?\d+\.?\d*/g);
@@ -34,7 +34,7 @@ Ext.define('Traccar.GeofenceConverter', {
geometry = new ol.geom.Polygon([points]);
}
}
- } else if (wkt.startsWith("CIRCLE")) {
+ } else if (wkt.startsWith('CIRCLE')) {
content = wkt.match(/\([^\(\)]+\)/);
if (content !== null) {
coordinates = content[0].match(/-?\d+\.?\d*/g);
@@ -62,17 +62,17 @@ Ext.define('Traccar.GeofenceConverter', {
earthSphere = new ol.Sphere(6378137);
groundRadius = earthSphere.haversineDistance(center,
ol.proj.transform(edgeCoordinate, projection, 'EPSG:4326'));
- result = "CIRCLE (";
- result += center[1] + " " + center[0] + ", ";
- result += Number((groundRadius).toFixed(1)) + ")";
+ result = 'CIRCLE (';
+ result += center[1] + ' ' + center[0] + ', ';
+ result += Number((groundRadius).toFixed(1)) + ')';
} else if (geometry instanceof ol.geom.Polygon) {
geometry.transform(projection, 'EPSG:4326');
points = geometry.getCoordinates();
- result = "POLYGON((";
+ result = 'POLYGON((';
for (i = 0; i < points[0].length; i += 1) {
- result += points[0][i][1] + " " + points[0][i][0] + ", ";
+ result += points[0][i][1] + ' ' + points[0][i][0] + ', ';
}
- result = result.substring(0, result.length - 2) + "))";
+ result = result.substring(0, result.length - 2) + '))';
}
return result;
}
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index ba23b90bf..98ded9c47 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -139,27 +139,27 @@ Ext.define('Traccar.controller.Root', {
store.add(array[i]);
if (array[i].type === 'commandResult' && data.positions) {
for (j = 0; j < data.positions.length; j++) {
- if (data.positions[j].id == array[i].positionId) {
+ if (data.positions[j].id === array[i].positionId) {
text = data.positions[j].attributes.result;
break;
}
}
- text = Strings.eventCommandResult + ": " + text;
+ text = Strings.eventCommandResult + ': ' + text;
} else {
typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
text = Strings[typeKey];
- if (typeof text == "undefined") {
+ if (typeof text === 'undefined') {
text = typeKey;
}
}
if (array[i].geofenceId !== 0) {
geofence = Ext.getStore('Geofences').getById(array[i].geofenceId);
- if (typeof geofence != "undefined") {
+ if (typeof geofence !== 'undefined') {
text += ' \"' + geofence.getData().name + '"';
}
}
device = Ext.getStore('Devices').getById(array[i].deviceId);
- if (typeof device != "undefined") {
+ if (typeof device !== 'undefined') {
Ext.toast(text, device.getData().name);
}
}
diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js
index 2ef190edc..d3825fb95 100644
--- a/web/app/store/CommandTypes.js
+++ b/web/app/store/CommandTypes.js
@@ -19,7 +19,7 @@ Ext.define('Traccar.store.CommandTypes', {
fields: ['type', 'name'],
listeners: {
- 'beforeload' : function(store) {
+ 'beforeload' : function (store) {
var proxy;
proxy = store.getProxy();
proxy.setUrl('/api/commandtypes?deviceId' + proxy.extraParams.deviceId);
@@ -31,13 +31,14 @@ Ext.define('Traccar.store.CommandTypes', {
url: '',
reader: {
type: 'json',
- getData: function(data) {
- Ext.each(data, function(entry) {
+ getData: function (data) {
+ Ext.each(data, function (entry) {
+ var nameKey, name;
entry.name = entry.type;
- if (typeof entry.type !== "undefined") {
- var nameKey = 'command' + entry.type.charAt(0).toUpperCase() + entry.type.slice(1);
- var name = Strings[nameKey];
- if (typeof name !== "undefined") {
+ if (typeof entry.type !== 'undefined') {
+ nameKey = 'command' + entry.type.charAt(0).toUpperCase() + entry.type.slice(1);
+ name = Strings[nameKey];
+ if (typeof name !== 'undefined') {
entry.name = name;
}
}
diff --git a/web/app/view/AttributesController.js b/web/app/view/AttributesController.js
index 663b6eae3..3028e41eb 100644
--- a/web/app/view/AttributesController.js
+++ b/web/app/view/AttributesController.js
@@ -24,29 +24,32 @@ Ext.define('Traccar.view.AttributesController', {
],
init: function () {
- var store, propertyName, i = 0;
+ var store, propertyName, i = 0, attributes;
store = Ext.create('Traccar.store.Attributes');
store.setProxy(Ext.create('Ext.data.proxy.Memory'));
- for (propertyName in this.getView().record.get('attributes')) {
- store.add(Ext.create('Traccar.model.Attribute', {
- priority: i++,
- name: propertyName,
- value:this.getView().record.get('attributes')[propertyName]
- }));
+ attributes = this.getView().record.get('attributes');
+ for (propertyName in attributes) {
+ if (attributes.hasOwnProperty(propertyName)) {
+ store.add(Ext.create('Traccar.model.Attribute', {
+ priority: i++,
+ name: propertyName,
+ value: this.getView().record.get('attributes')[propertyName]
+ }));
+ }
}
- store.addListener('add', function (store , records , index , eOpts) {
- for (var i = 0; i < records.length; i++) {
+ store.addListener('add', function (store, records, index, eOpts) {
+ for (i = 0; i < records.length; i++) {
this.getView().record.get('attributes')[records[i].get('name')] = records[i].get('value');
this.getView().record.dirty = true;
}
}, this);
- store.addListener('update', function (store, record, operation , modifiedFieldNames , details , eOpts) {
+ store.addListener('update', function (store, record, operation, modifiedFieldNames, details, eOpts) {
if (operation === Ext.data.Model.EDIT) {
this.getView().record.get('attributes')[record.get('name')] = record.get('value');
this.getView().record.dirty = true;
}
}, this);
- store.addListener('remove', function (store , records , index , isMove , eOpts) {
+ store.addListener('remove', function (store, records, index, isMove, eOpts) {
delete this.getView().record.get('attributes')[records[index].get('name')];
this.getView().record.dirty = true;
}, this);
diff --git a/web/app/view/BaseMap.js b/web/app/view/BaseMap.js
index 7f508cbe8..77646cbef 100644
--- a/web/app/view/BaseMap.js
+++ b/web/app/view/BaseMap.js
@@ -28,7 +28,7 @@ Ext.define('Traccar.view.BaseMap', {
return this.mapView;
},
- initMap: function() {
+ initMap: function () {
var user, server, layer, type, bingKey, lat, lon, zoom, target;
user = Traccar.app.getUser();
diff --git a/web/app/view/BasePermissionsController.js b/web/app/view/BasePermissionsController.js
index 713d91770..3cdc2e4dc 100644
--- a/web/app/view/BasePermissionsController.js
+++ b/web/app/view/BasePermissionsController.js
@@ -19,10 +19,10 @@ Ext.define('Traccar.view.BasePermissionsController', {
alias: 'controller.basePermissionsController',
init: function () {
- var params = {};
+ var params = {}, linkStoreName, storeName;
params[this.getView().baseObjectName] = this.getView().baseObject;
- var linkStoreName = this.getView().linkStoreName;
- var storeName = this.getView().storeName;
+ linkStoreName = this.getView().linkStoreName;
+ storeName = this.getView().storeName;
linkStoreName = (typeof linkStoreName === 'undefined') ? storeName : linkStoreName;
this.getView().setStore(Ext.getStore(storeName));
this.getView().getStore().load({
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js
index cf31dd7bb..c61f8711b 100644
--- a/web/app/view/DevicesController.js
+++ b/web/app/view/DevicesController.js
@@ -86,15 +86,16 @@ Ext.define('Traccar.view.DevicesController', {
},
onGeofencesClick: function () {
- var admin = Traccar.app.getUser().get('admin');
- var device = this.getView().getSelectionModel().getSelection()[0];
+ var admin, device;
+ admin = Traccar.app.getUser().get('admin');
+ device = this.getView().getSelectionModel().getSelection()[0];
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedGeofences,
items: {
xtype: 'deviceGeofencesView',
baseObjectName: 'deviceId',
linkObjectName: 'geofenceId',
- storeName: (admin) ? 'AllGeofences' : 'Geofences',
+ storeName: admin ? 'AllGeofences' : 'Geofences',
urlApi: '/api/devices/geofences',
baseObject: device.getData().id
}
@@ -115,8 +116,9 @@ Ext.define('Traccar.view.DevicesController', {
},
onFollowClick: function (button, pressed) {
+ var device;
if (pressed) {
- var device = this.getView().getSelectionModel().getSelection()[0];
+ device = this.getView().getSelectionModel().getSelection()[0];
this.fireEvent('selectDevice', device, true);
}
},
diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js
index 165daf40d..573836bc9 100644
--- a/web/app/view/GeofenceMap.js
+++ b/web/app/view/GeofenceMap.js
@@ -57,7 +57,7 @@ Ext.define('Traccar.view.GeofenceMap', {
map = this.map;
this.features = new ol.Collection();
- if (this.area !== "") {
+ if (this.area !== '') {
geometry = Traccar.GeofenceConverter.wktToGeometry(this.mapView, this.area);
this.features.push(new ol.Feature(geometry));
if (geometry instanceof ol.geom.Circle) {
@@ -90,7 +90,7 @@ Ext.define('Traccar.view.GeofenceMap', {
map.addInteraction(new ol.interaction.Modify({
features: this.features,
- deleteCondition: function(event) {
+ deleteCondition: function (event) {
return ol.events.condition.shiftKeyOnly(event) && ol.events.condition.singleClick(event);
}
}));
diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js
index bc713bb6d..1764423d7 100644
--- a/web/app/view/GroupsController.js
+++ b/web/app/view/GroupsController.js
@@ -60,15 +60,16 @@ Ext.define('Traccar.view.GroupsController', {
},
onGeofencesClick: function () {
- var admin = Traccar.app.getUser().get('admin');
- var group = this.getView().getSelectionModel().getSelection()[0];
+ var admin, group;
+ admin = Traccar.app.getUser().get('admin');
+ group = this.getView().getSelectionModel().getSelection()[0];
Ext.create('Traccar.view.BaseWindow', {
title: Strings.sharedGeofences,
items: {
xtype: 'groupGeofencesView',
baseObjectName: 'groupId',
linkObjectName: 'geofenceId',
- storeName: (admin) ? 'AllGeofences' : 'Geofences',
+ storeName: admin ? 'AllGeofences' : 'Geofences',
urlApi: '/api/groups/geofences',
baseObject: group.getData().id
}
diff --git a/web/app/view/Notifications.js b/web/app/view/Notifications.js
index 211e5cd15..92a850671 100644
--- a/web/app/view/Notifications.js
+++ b/web/app/view/Notifications.js
@@ -26,7 +26,7 @@ Ext.define('Traccar.view.Notifications', {
store: 'AllNotifications',
selModel: {
- selType: 'cellmodel',
+ selType: 'cellmodel'
},
columns: [{
@@ -47,7 +47,7 @@ Ext.define('Traccar.view.Notifications', {
checkChange: 'onCheckChange'
},
renderer: function (value, metaData, record) {
- var fields = this.dataIndex.split('\.',2);
+ var fields = this.dataIndex.split('\.', 2);
return (new Ext.ux.CheckColumn()).renderer(record.get(fields[0])[fields[1]], metaData);
}
}, {
@@ -60,9 +60,8 @@ Ext.define('Traccar.view.Notifications', {
checkChange: 'onCheckChange'
},
renderer: function (value, metaData, record) {
- var fields = this.dataIndex.split('\.',2);
+ var fields = this.dataIndex.split('\.', 2);
return (new Ext.ux.CheckColumn()).renderer(record.get(fields[0])[fields[1]], metaData);
}
- }],
-
+ }]
});
diff --git a/web/app/view/NotificationsController.js b/web/app/view/NotificationsController.js
index a7c4290ca..90479fe07 100644
--- a/web/app/view/NotificationsController.js
+++ b/web/app/view/NotificationsController.js
@@ -47,11 +47,12 @@ Ext.define('Traccar.view.NotificationsController', {
},
onBeforeCheckChange: function (column, rowIndex, checked, eOpts) {
- var fields = column.dataIndex.split('\.',2);
- var record = this.getView().getStore().getAt(rowIndex);
- var data = record.get(fields[0]);
+ var fields, record, data;
+ fields = column.dataIndex.split('\.', 2);
+ record = this.getView().getStore().getAt(rowIndex);
+ data = record.get(fields[0]);
if (!data[fields[1]]) {
- data[fields[1]] = "true";
+ data[fields[1]] = 'true';
} else {
delete data[fields[1]];
}