# HG changeset patch
# User Edouard Tisserant
# Date 1636376789 -3600
# Node ID 18621ce81f5fec92f1d51c38066915c4ed1a2d69
# Parent  bd337d21f686b82d11fc0691b73bea5c439115df
SVGHMI: Changes /CURRENT_PAGE_* behaviour to prevent problem whith multiclient : all clients were switching page when one was jumping.
    - now PLC have to prefix page name with "!" to order page switch.
    - HMI do not prefix with "!" when jumping, this avoiding looping incidently
    - In case of multiple client:
        CURRENT_PAGE reflects current page of last client hwo did jump
        Setting CURRENT_PAGE with "!" affects all clients simultaneously

diff -r bd337d21f686 -r 18621ce81f5f svghmi/svghmi.js
--- a/svghmi/svghmi.js	Mon Nov 08 14:03:21 2021 +0100
+++ b/svghmi/svghmi.js	Mon Nov 08 14:06:29 2021 +0100
@@ -210,11 +210,13 @@
 }
 
 // subscribe to per instance current page hmi variable
+// PLC must prefix page name with "!" for page switch to happen
 subscribers(current_page_var_index).add({
     frequency: 1,
     indexes: [current_page_var_index],
     new_hmi_value: function(index, value, oldval) {
-        switch_page(value);
+        if(value.startsWith("!"))
+            switch_page(value.slice(1));
     }
 });
 
@@ -467,10 +469,9 @@
     if(jump_history.length > 42)
         jump_history.shift();
 
-    apply_hmi_value(current_page_var_index,
-                    page_index == undefined
-                        ? page_name
-                        : page_name + "@" + hmitree_paths[page_index]);
+    apply_hmi_value(current_page_var_index, page_index == undefined
+        ? page_name
+        : page_name + "@" + hmitree_paths[page_index]);
 
     return true;
 };