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@2893: | index_pool: [ Edouard@2893: | ], Edouard@2893: | buttons: [ Edouard@2893: const "class","arg[1]/@value"; Edouard@2893: const "prefix","concat($class,':')"; Edouard@2893: const "buttons_regex","concat('^',$prefix,'[+\-][0-9]+')"; Edouard@2893: foreach "$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]" { Edouard@2893: | ["«substring-after(@inkscape:label, concat(arg[1]/@value, ':'))»", id("«@id»")]`if "position()!=last()" > ,` Edouard@2893: } Edouard@2893: | ], edouard@2891: | init: function() { Edouard@2893: | /* TODO elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");*/ edouard@2891: | }, edouard@2892: Edouard@2893: | items: [ Edouard@2893: const "base_path","path/@value"; Edouard@2893: const "items_regex","concat('^',$prefix,'[0-9]+')"; Edouard@2893: const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"; Edouard@2893: foreach "$unordered_items" { Edouard@2893: const "elt_label","concat($prefix, string(position()))"; Edouard@2893: const "elt","$unordered_items[@inkscape:label = $elt_label]"; Edouard@2893: Edouard@2893: | /* `apply "func:get_hmi_tree_elt($base_path)", mode="testtree";` */ Edouard@2893: | [ /* «$elt_label» */ Edouard@2893: if "count($elt)=0" error > Missing item labeled «$elt_label» in ForEach widget «$hmi_element/@id» Edouard@2893: foreach "func:refered_elements($elt)[@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: }