edouard@2891: edouard@2891: template "widget[@type='ForEach']", mode="widget_defs" { edouard@2891: param "hmi_element"; edouard@2892: const "widgets", "func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"; edouard@2891: | frequency: 2, edouard@2891: | dispatch: function(value) { edouard@2891: | // do something edouard@2891: | }, edouard@2891: | init: function() { edouard@2891: foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" { edouard@2891: | id("«@id»").addEventListener( edouard@2891: | "click", edouard@2891: | evt => {let new_val = "«func:escape_quotes(@inkscape:label)»"); edouard@2891: | // do something with new_val edouard@2891: | }); edouard@2891: } edouard@2891: | }, edouard@2892: edouard@2892: | widgets: [ edouard@2892: const "labels_regex","concat('^',arg[1]/@value,':[0-9]+')"; edouard@2892: foreach "$hmi_element/*[regexp:test(@inkscape:label, $labels_regex)]" { edouard@2892: | [ /* «@inkscape:label» */ edouard@2892: const "elt","."; edouard@2892: //foreach "$hmi_elements[ancestor::svg:*/@id = $_id]" { edouard@2892: foreach "func:refered_elements(.)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" { edouard@2892: | hmi_widgets["«@id»"]`if "position()!=last()" > ,` edouard@2892: } edouard@2892: | ]`if "position()!=last()" > ,` edouard@2892: } edouard@2892: | ], edouard@2891: } edouard@2891: edouard@2891: template "widget[@type='ForEach']", mode="widget_subscribe"{ edouard@2891: // param "hmi_element"; edouard@2891: | sub: function(off){ edouard@2892: | subscribe.call(this,off); edouard@2892: /* TODO */ edouard@2891: | }, edouard@2891: edouard@2891: | unsub: function(){ edouard@2892: | unsubscribe.call(this); edouard@2892: /* TODO */ edouard@2891: | }, edouard@2891: }