Merge pull request #20 from andreasIBM/Array

Add capability to pass in an Array of Data to the Node
This commit is contained in:
Dave Conway-Jones 2017-06-25 11:01:40 +01:00 committed by GitHub
commit 607e5bffaf

View File

@ -151,9 +151,19 @@ ws.on('error', function() {
});
ws.on('worldmapdata', function(data) {
if (data.command) { doCommand(data.command); delete data.command; }
if (data.hasOwnProperty("name")) { setMarker(data); }
else { console.log("SKIP",data); }
if (Array.isArray(data)) {
console.log("Data passed in is Array");
for (var prop in data) {
if (data[prop].command) { doCommand(data[prop].command); delete data[prop].command; }
if (data[prop].hasOwnProperty("name")) { setMarker(data[prop]); }
else { console.log("SKIP",data[prop]); }
}
}
else {
if (data.command) { doCommand(data.command); delete data.command; }
if (data.hasOwnProperty("name")) { setMarker(data); }
else { console.log("SKIP",data); }
}
});
if ( window.localStorage.hasOwnProperty("lastpos") ) {