svghmi/widget_switch.ysl2
branchsvghmi
changeset 2883 8e3d130399b0
parent 2882 ac08a5d15c15
child 2907 1695122a5e16
equal deleted inserted replaced
2882:ac08a5d15c15 2883:8e3d130399b0
       
     1 // widget_switch.ysl2
       
     2 
       
     3 template "widget[@type='Switch']", mode="widget_defs" {
       
     4     param "hmi_element";
       
     5     |     frequency: 5,
       
     6     |     dispatch: function(value) {
       
     7     |         for(let choice of this.choices){
       
     8     |             if(value != choice.value){
       
     9     |                 choice.elt.setAttribute("style", "display:none");
       
    10     |             } else {
       
    11     |                 choice.elt.setAttribute("style", choice.style);
       
    12     |             }
       
    13     |         }
       
    14     |     },
       
    15     |     init: function() {
       
    16     |         // Hello Switch
       
    17     |     },
       
    18     |     choices: [
       
    19     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+)(#.*)?$'"!;
       
    20     foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" {
       
    21         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
       
    22     |         {
       
    23     |             elt:id("«@id»"),
       
    24     |             style:"«@style»",
       
    25     |             value:«$literal»
       
    26     |         }`if "position()!=last()" > ,`
       
    27     }
       
    28     |     ],
       
    29 }