# HG changeset patch
# User Edouard Tisserant
# Date 1651827857 -7200
# Node ID 1202b47e7e63b28852deccdd5e18295a3e84b737
# Parent  2fb9849c67214a5a418f7991c04af276a087f467
SVGHMI: fix widget's update frequency forcing : syntax checking was enforcing unit and js code was using undefined variables

diff -r 2fb9849c6721 -r 1202b47e7e63 svghmi/parse_labels.ysl2
--- a/svghmi/parse_labels.ysl2	Fri May 06 11:02:03 2022 +0200
+++ b/svghmi/parse_labels.ysl2	Fri May 06 11:04:17 2022 +0200
@@ -15,7 +15,7 @@
 //
 const "pathregex",!"'^([^\[,]+)(\[[^\]]+\])?([\d,]*)$'"!;
 
-template "*", mode="parselabel" 
+template "*", mode="parselabel"
 {
     const "label","@inkscape:label";
     const "id","@id";
@@ -45,7 +45,7 @@
         attrib "id" > «$id»
         attrib "type" > «$type»
         if "$freq" {
-            if "not(regexp:test($freq,'^[0-9]*(\.[0-9]+)?[smh]'))" {
+            if "not(regexp:test($freq,'^[0-9]*(\.[0-9]+)?[smh]?'))" {
                 error > Widget id:«$id» label:«$label» has wrong syntax of frequency forcing «$freq»
             }
             attrib "freq" > «$freq»
diff -r 2fb9849c6721 -r 1202b47e7e63 svghmi/widgets_common.ysl2
--- a/svghmi/widgets_common.ysl2	Fri May 06 11:02:03 2022 +0200
+++ b/svghmi/widgets_common.ysl2	Fri May 06 11:04:17 2022 +0200
@@ -187,23 +187,23 @@
         }
 
         do_init(){
-            if(widget.forced_frequency !== undefined){
-                let s = widget.forced_frequency;
+            let forced = this.forced_frequency;
+            if(forced !== undefined){
                 /*
                 once every 10 seconds : 10s
                 once per minute : 1m
                 once per hour : 1h
                 once per day : 1d
                 */
-                let unit = s.slice(-1);
+                let unit = forced.slice(-1);
                 let factor = {
                     "s":1,
                     "m":60,
                     "h":3600,
                     "d":86400}[unit];
 
-                widget.frequency = factor ? 1/(factor * Number(s.slice(0,-1)))
-                                          : Number(s);
+                this.frequency = factor ? 1/(factor * Number(forced.slice(0,-1)))
+                                          : Number(forced);
             }
 
             let init = this.init;