edouard@2883: // widget_switch.ysl2 Edouard@2779: edouard@2883: template "widget[@type='Switch']", mode="widget_defs" { edouard@2883: param "hmi_element"; edouard@2883: | frequency: 5, edouard@2883: | dispatch: function(value) { edouard@2883: | for(let choice of this.choices){ edouard@2883: | if(value != choice.value){ edouard@2883: | choice.elt.setAttribute("style", "display:none"); edouard@2883: | } else { edouard@2883: | choice.elt.setAttribute("style", choice.style); edouard@2883: | } edouard@2883: | } edouard@2883: | }, edouard@2883: | init: function() { edouard@2883: | // Hello Switch edouard@2883: | }, edouard@2883: | choices: [ edouard@2883: const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+)(#.*)?$'"!; edouard@2883: foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" { edouard@2883: const "literal", "regexp:match(@inkscape:label,$regex)[2]"; edouard@2883: | { edouard@2883: | elt:id("«@id»"), edouard@2883: | style:"«@style»", edouard@2883: | value:«$literal» edouard@2883: | }`if "position()!=last()" > ,` Edouard@2792: } edouard@2883: | ], Edouard@2753: }