'No Connection' label is now clickable to reinitialize

This commit is contained in:
Dave Kliczbor 2018-10-28 12:33:43 +01:00
parent 5fb64d4e73
commit 6219d4302b
3 changed files with 100 additions and 9 deletions

View File

@ -84,6 +84,23 @@ function colorClass(colorId) {
var websock;
function restart() {
$(document).add('*').off();
$("#row").html("");
websock.close();
start();
}
function conStatusError() {
$("#conStatus").removeClass("color-green");
$("#conStatus").addClass("color-red");
$("#conStatus").text("Error / No Connection");
$("#conStatus").off();
$("#conStatus").on({
'click': restart
});
}
function start() {
websock = new WebSocket('ws://' + window.location.hostname + '/ws');
websock.onopen = function(evt) {
@ -93,15 +110,11 @@ function start() {
};
websock.onclose = function(evt) {
console.log('websock close');
$("#conStatus").removeClass("color-green");
$("#conStatus").addClass("color-red");
$("#conStatus").text("Error / No Connection");
conStatusError();
};
websock.onerror = function(evt) {
console.log(evt);
$("#conStatus").removeClass("color-green");
$("#conStatus").addClass("color-red");
$("#conStatus").text("Error / No Connection");
conStatusError();
};
websock.onmessage = function(evt) {
console.log(evt);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long