svghmi/svghmi.js
changeset 3512 fce3d407bb46
parent 3455 2716cd8e498d
child 3514 f86ffe291fea
equal deleted inserted replaced
3511:7c27d57b6ec0 3512:fce3d407bb46
   200             apply_hmi_value(heartbeat_index, value+1);
   200             apply_hmi_value(heartbeat_index, value+1);
   201         }
   201         }
   202     });
   202     });
   203 }
   203 }
   204 
   204 
       
   205 
       
   206 function fading_page_switch(...args){
       
   207     svg_root.classList.add("fade-out-page");
       
   208 
       
   209     setTimeout(function(){
       
   210         switch_page(...args);
       
   211         svg_root.classList.remove("fade-out-page");
       
   212     },10);
       
   213 }
       
   214 document.body.style.backgroundColor = "black";
       
   215 
   205 // subscribe to per instance current page hmi variable
   216 // subscribe to per instance current page hmi variable
   206 // PLC must prefix page name with "!" for page switch to happen
   217 // PLC must prefix page name with "!" for page switch to happen
   207 subscribers(current_page_var_index).add({
   218 subscribers(current_page_var_index).add({
   208     frequency: 1,
   219     frequency: 1,
   209     indexes: [current_page_var_index],
   220     indexes: [current_page_var_index],
   210     new_hmi_value: function(index, value, oldval) {
   221     new_hmi_value: function(index, value, oldval) {
   211         if(value.startsWith("!"))
   222         if(value.startsWith("!"))
   212             switch_page(value.slice(1));
   223             fading_page_switch(value.slice(1));
   213     }
   224     }
   214 });
   225 });
   215 
   226 
   216 function svg_text_to_multiline(elt) {
   227 function svg_text_to_multiline(elt) {
   217     return(Array.prototype.map.call(elt.children, x=>x.textContent).join("\\\\n")); 
   228     return(Array.prototype.map.call(elt.children, x=>x.textContent).join("\\\\n"));