aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-02 17:11:18 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-02 17:11:18 +0500
commit0271fa29703f24df24756c117209b9b04e127fc3 (patch)
tree7d2afe2b865dc5f9f10faa5ce7d213a219afa82a
parentd9e57775e5bb10e722d0043186308df05eea3296 (diff)
downloadtrackermap-server-0271fa29703f24df24756c117209b9b04e127fc3.tar.gz
trackermap-server-0271fa29703f24df24756c117209b9b04e127fc3.tar.bz2
trackermap-server-0271fa29703f24df24756c117209b9b04e127fc3.zip
Style fixes and optimization.
-rw-r--r--src/org/traccar/api/AsyncSocket.java8
-rw-r--r--web/app/controller/Root.js10
-rw-r--r--web/app/store/Events.js2
3 files changed, 9 insertions, 11 deletions
diff --git a/src/org/traccar/api/AsyncSocket.java b/src/org/traccar/api/AsyncSocket.java
index 76ec99406..d1e5594f4 100644
--- a/src/org/traccar/api/AsyncSocket.java
+++ b/src/org/traccar/api/AsyncSocket.java
@@ -47,7 +47,7 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U
public void onWebSocketConnect(Session session) {
super.onWebSocketConnect(session);
- Map<String, Collection<?>> data = new HashMap<String, Collection<?>>();
+ Map<String, Collection<?>> data = new HashMap<>();
data.put(KEY_POSITIONS, Context.getConnectionManager().getInitialState(userId));
sendData(data);
@@ -63,21 +63,21 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U
@Override
public void onUpdateDevice(Device device) {
- Map<String, Collection<?>> data = new HashMap<String, Collection<?>>();
+ Map<String, Collection<?>> data = new HashMap<>();
data.put(KEY_DEVICES, Collections.singletonList(device));
sendData(data);
}
@Override
public void onUpdatePosition(Position position) {
- Map<String, Collection<?>> data = new HashMap<String, Collection<?>>();
+ Map<String, Collection<?>> data = new HashMap<>();
data.put(KEY_POSITIONS, Collections.singletonList(position));
sendData(data);
}
@Override
public void onUpdateEvent(Event event, Position position) {
- Map<String, Collection<?>> data = new HashMap<String, Collection<?>>();
+ Map<String, Collection<?>> data = new HashMap<>();
data.put(KEY_EVENTS, Collections.singletonList(event));
if (position != null) {
data.put(KEY_POSITIONS, Collections.singletonList(position));
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 3e2358c8d..991a2572c 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -94,7 +94,7 @@ Ext.define('Traccar.controller.Root', {
};
socket.onmessage = function (event) {
- var i, store, data, array, entity;
+ var i, j, store, data, array, entity, device, typeKey, text;
data = Ext.decode(event.data);
@@ -132,9 +132,7 @@ Ext.define('Traccar.controller.Root', {
store = Ext.getStore('Events');
for (i = 0; i < array.length; i++) {
store.add(array[i]);
- var text;
if (array[i].type === 'commandResult' && data.positions) {
- var j;
for (j = 0; j < data.positions.length; j++) {
if (data.positions[j].id == array[i].positionId) {
text = data.positions[j].attributes.result;
@@ -143,13 +141,13 @@ Ext.define('Traccar.controller.Root', {
}
text = Strings.eventCommandResult + text;
} else {
- var typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
- var text = Strings[typeKey];
+ typeKey = 'event' + array[i].type.charAt(0).toUpperCase() + array[i].type.slice(1);
+ text = Strings[typeKey];
if (typeof text == "undefined") {
text = typeKey;
}
}
- var device = Ext.getStore('Devices').getById(array[i].deviceId);
+ device = Ext.getStore('Devices').getById(array[i].deviceId);
if (typeof device != "undefined") {
Ext.toast(text, device.getData().name);
}
diff --git a/web/app/store/Events.js b/web/app/store/Events.js
index f98764456..54b341d30 100644
--- a/web/app/store/Events.js
+++ b/web/app/store/Events.js
@@ -22,4 +22,4 @@ Ext.define('Traccar.store.Events', {
type: 'rest',
url: '/api/events'
}
-}); \ No newline at end of file
+});