# HG changeset patch
# User Edouard Tisserant
# Date 1668764696 -3600
# Node ID 2239f8e3de48dc71e319ddaed87a398f8bdb01cf
# Parent bbcbb1bba9f10c2d1e379b0ea09556b06a815309
SVGHMI: update generated XSLT
diff -r bbcbb1bba9f1 -r 2239f8e3de48 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Fri Nov 18 10:40:57 2022 +0100
+++ b/svghmi/gen_index_xhtml.xslt Fri Nov 18 10:44:56 2022 +0100
@@ -12128,29 +12128,37 @@
- var screensaver_timer = null;
-
- function reset_screensaver_timer() {
-
- if(screensaver_timer){
-
- window.clearTimeout(screensaver_timer);
+ if(screensaver_delay){
+
+ var screensaver_timer = null;
+
+ function reset_screensaver_timer() {
+
+ if(screensaver_timer){
+
+ window.clearTimeout(screensaver_timer);
+
+ }
+
+ screensaver_timer = window.setTimeout(() => {
+
+ switch_page("ScreenSaver");
+
+ screensaver_timer = null;
+
+ }, screensaver_delay*1000);
}
- screensaver_timer = window.setTimeout(() => {
-
- switch_page("ScreenSaver");
-
- screensaver_timer = null;
-
- }, screensaver_delay*1000);
+ document.body.addEventListener('pointerdown', reset_screensaver_timer);
+
+ // initialize screensaver
+
+ reset_screensaver_timer();
}
- if(screensaver_delay)
-
- document.body.addEventListener('pointerdown', reset_screensaver_timer);
+
@@ -12474,16 +12482,12 @@
- // initialize screensaver
-
- reset_screensaver_timer();
-
-
-
var reconnect_delay = 0;
var periodic_reconnect_timer;
+ var force_reconnect = false;
+
// Once connection established
@@ -12504,6 +12508,8 @@
periodic_reconnect_timer = window.setTimeout(() => {
+ force_reconnect = true;
+
ws.close();
periodic_reconnect_timer = null;
@@ -12540,14 +12546,26 @@
ws = null;
- // reconect
-
- // TODO : add visible notification while waiting for reload
+ // Do not attempt to reconnect immediately in case:
+
+ // - connection was closed by server (PLC stop)
+
+ // - connection was closed locally with an intention to reconnect
+
+ if(evt.code=1000 && !force_reconnect){
+
+ window.alert("Connection closed by server");
+
+ location.reload();
+
+ }
window.setTimeout(create_ws, reconnect_delay);
reconnect_delay += 500;
+ force_reconnect = false;
+
};