template "widget[@type='ForEach']", mode="widget_defs" { param "hmi_element"; const "widgets", "func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]"; | frequency: 2, | dispatch: function(value) { | // do something | }, | index_pool: [ | ], | buttons: [ const "class","arg[1]/@value"; const "prefix","concat($class,':')"; const "buttons_regex","concat('^',$prefix,'[+\-][0-9]+')"; foreach "$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]" { | ["«substring-after(@inkscape:label, concat(arg[1]/@value, ':'))»", id("«@id»")]`if "position()!=last()" > ,` } | ], | init: function() { | /* TODO elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");*/ | }, | items: [ const "base_path","path/@value"; const "items_regex","concat('^',$prefix,'[0-9]+')"; const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"; foreach "$unordered_items" { const "elt_label","concat($prefix, string(position()))"; const "elt","$unordered_items[@inkscape:label = $elt_label]"; | /* `apply "func:get_hmi_tree_elt($base_path)", mode="testtree";` */ | [ /* «$elt_label» */ if "count($elt)=0" error > Missing item labeled «$elt_label» in ForEach widget «$hmi_element/@id» foreach "func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" { | hmi_widgets["«@id»"]`if "position()!=last()" > ,` } | ]`if "position()!=last()" > ,` } | ], } template "widget[@type='ForEach']", mode="widget_subscribe"{ // param "hmi_element"; | sub: function(off){ | subscribe.call(this,off); /* TODO */ | }, | unsub: function(){ | unsubscribe.call(this); /* TODO */ | }, }