# HG changeset patch # User Edouard Tisserant # Date 1651827857 -7200 # Node ID 97622e9560b51d8588e9d82fc0729d70dd777c1d # Parent 3725487d5468cad428847325189e89a8fdb7e8d9 SVGHMI: fix widget's update frequency forcing : syntax checking was enforcing unit and js code was using undefined variables diff -r 3725487d5468 -r 97622e9560b5 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 3725487d5468 -r 97622e9560b5 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;