svghmi/widget_switch.ysl2
branchsvghmi
changeset 2962 02ea529fd08c
parent 2907 1695122a5e16
child 2969 88988edb2e93
equal deleted inserted replaced
2961:00825316ed00 2962:02ea529fd08c
     1 // widget_switch.ysl2
     1 // widget_switch.ysl2
       
     2 
       
     3 template "widget[@type='Switch']", mode="widget_class"
       
     4     ||
       
     5     class SwitchWidget extends Widget{
       
     6         frequency = 5;
       
     7         dispatch(value) {
       
     8             for(let choice of this.choices){
       
     9                 if(value != choice.value){
       
    10                     choice.elt.setAttribute("style", "display:none");
       
    11                 } else {
       
    12                     choice.elt.setAttribute("style", choice.style);
       
    13                 }
       
    14             }
       
    15         }
       
    16     }
       
    17     ||
     2 
    18 
     3 template "widget[@type='Switch']", mode="widget_defs" {
    19 template "widget[@type='Switch']", mode="widget_defs" {
     4     param "hmi_element";
    20     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: [
    21     |     choices: [
    19     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    22     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    20     foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" {
    23     foreach "$hmi_element/*[regexp:test(@inkscape:label,$regex)]" {
    21         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    24         const "literal", "regexp:match(@inkscape:label,$regex)[2]";
    22     |         {
    25     |         {