diff options
author | Abyss777 <abyss@fox5.ru> | 2017-03-15 14:06:51 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-03-15 14:06:51 +0500 |
commit | ccc2f0bd4387d7117a1c9b629be2d22edccb18d9 (patch) | |
tree | 282ffddac6e51e35414c5e48351631c18af6a271 /web/app/controller/Root.js | |
parent | f9cbb295fcb677b7fc44f17afa22e50c3ef48a16 (diff) | |
download | trackermap-web-ccc2f0bd4387d7117a1c9b629be2d22edccb18d9.tar.gz trackermap-web-ccc2f0bd4387d7117a1c9b629be2d22edccb18d9.tar.bz2 trackermap-web-ccc2f0bd4387d7117a1c9b629be2d22edccb18d9.zip |
Use local variable
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r-- | web/app/controller/Root.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 94f0705f..8a9b0d9b 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -124,7 +124,7 @@ Ext.define('Traccar.controller.Root', { }, asyncUpdate: function (first) { - var self = this, protocol, pathname, socket; + var self = this, protocol, pathname, socket, firstPositions = first; protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; pathname = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1); socket = new WebSocket(protocol + '//' + window.location.host + pathname + 'api/socket'); @@ -161,15 +161,13 @@ Ext.define('Traccar.controller.Root', { self.updateDevices(data.devices); } if (data.positions) { - self.updatePositions(data.positions); + self.updatePositions(data.positions, firstPositions); + firstPositions = false; } if (data.events) { self.updateEvents(data.events); } }; - if (first) { - this.first = true; - } }, updateDevices: function (array) { @@ -188,7 +186,7 @@ Ext.define('Traccar.controller.Root', { } }, - updatePositions: function (array) { + updatePositions: function (array, first) { var i, store, entity; store = Ext.getStore('LatestPositions'); for (i = 0; i < array.length; i++) { @@ -199,9 +197,8 @@ Ext.define('Traccar.controller.Root', { store.add(Ext.create('Traccar.model.Position', array[i])); } } - if (this.first) { + if (first) { this.zoomToAllDevices(); - this.first = false; } }, |