diff --git a/examples/gui/data/js/controls.js b/examples/gui/data/js/controls.js
index 5b72533..099587a 100644
--- a/examples/gui/data/js/controls.js
+++ b/examples/gui/data/js/controls.js
@@ -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);
diff --git a/examples/gui/data/js/controls.min.js b/examples/gui/data/js/controls.min.js
index 571d6f3..9025d1a 100644
--- a/examples/gui/data/js/controls.min.js
+++ b/examples/gui/data/js/controls.min.js
@@ -1 +1,40 @@
-function colorClass(e){switch(e=Number(e)){case C_TURQUOISE:return"turquoise";case C_EMERALD:return"emerald";case C_PETERRIVER:return"peterriver";case C_WETASPHALT:return"wetasphalt";case C_SUNFLOWER:return"sunflower";case C_CARROT:return"carrot";case C_ALIZARIN:return"alizarin";case C_NONE:default:return""}}function start(){websock=new WebSocket("ws://"+window.location.hostname+"/ws"),websock.onopen=function(e){console.log("websock open"),$("#conStatus").addClass("color-green"),$("#conStatus").text("Connected")},websock.onclose=function(e){console.log("websock close"),$("#conStatus").removeClass("color-green"),$("#conStatus").addClass("color-red"),$("#conStatus").text("Error / No Connection")},websock.onerror=function(e){console.log(e),$("#conStatus").removeClass("color-green"),$("#conStatus").addClass("color-red"),$("#conStatus").text("Error / No Connection")},websock.onmessage=function(e){console.log(e);var c=JSON.parse(e.data),o=(document.body,"");switch(c.type){case UI_TITEL:document.title=c.label,$("#mainHeader").html(c.label);break;case UI_LABEL:$("#row").append("
"+c.label+"
"+c.value+"");break;case UI_BUTTON:$("#row").append(""+c.label+"
"),$("#"+c.id).on({touchstart:function(e){e.preventDefault(),buttonclick(c.id,!0)}}),$("#"+c.id).on({touchend:function(e){e.preventDefault(),buttonclick(c.id,!1)}});break;case UI_SWITCHER:var s="