Fixed small issue of not terminating init() function correctly

This commit is contained in:
James 2018-12-09 17:15:27 +11:00
parent 2bc415b2af
commit ba5bd51b14

View file

@ -9,22 +9,23 @@ const char* MAIN_PAGE PROGMEM = R"=====(
function init() { function init() {
Socket = new WebSocket('ws://' + window.location.hostname + ':81/'); Socket = new WebSocket('ws://' + window.location.hostname + ':81/');
Socket.onmessage = function(event){ Socket.onmessage = function(event){
console.log("msg rec", evt.data); console.log("msg rec", evt.data);
var msgArray = evt.data.split(","); // split message by delimiter into a string array var msgArray = evt.data.split(","); // split message by delimiter into a string array
console.log("msgArray", msgArray[0]); console.log("msgArray", msgArray[0]);
console.log("msgArray", msgArray[1]); console.log("msgArray", msgArray[1]);
console.log("msgArray", msgArray[2]); console.log("msgArray", msgArray[2]);
console.log("msgArray", msgArray[3]); console.log("msgArray", msgArray[3]);
var indicator = msgArray[1]; // the first element in the message array is the ID of the object to update var indicator = msgArray[1]; // the first element in the message array is the ID of the object to update
console.log("indiactor", indicator); console.log("indiactor", indicator);
if (SensorRead) // if an object by the name of the message exists, update its value or its attributes if (SensorRead) // if an object by the name of the message exists, update its value or its attributes
{ {
switch (msgArray[1]) switch (msgArray[1])
{ {
case "CurrentTemp": case "CurrentTemp":
document.getElementById("TempCurrent").innerHTML = event.data; document.getElementById("TempCurrent").innerHTML = event.data;
}
}
} }
}