svghmi/widget_switch.ysl2
branchsvghmi
changeset 3232 7bdb766c2a4d
parent 3220 ec365ef396b1
child 3241 fe945f1f48b7
equal deleted inserted replaced
3231:5243c2a2f7f8 3232:7bdb766c2a4d
     1 // widget_switch.ysl2
     1 // widget_switch.ysl2
     2 
     2 
     3 template "widget[@type='Switch']", mode="widget_class"
     3 widget_class("Switch")
     4     ||
     4     ||
     5     class SwitchWidget extends Widget{
       
     6         frequency = 5;
     5         frequency = 5;
     7         dispatch(value) {
     6         dispatch(value) {
     8             for(let choice of this.choices){
     7             for(let choice of this.choices){
     9                 if(value != choice.value){
     8                 if(value != choice.value){
    10                     choice.elt.setAttribute("style", "display:none");
     9                     choice.elt.setAttribute("style", "display:none");
    11                 } else {
    10                 } else {
    12                     choice.elt.setAttribute("style", choice.style);
    11                     choice.elt.setAttribute("style", choice.style);
    13                 }
    12                 }
    14             }
    13             }
    15         }
    14         }
    16     }
       
    17     ||
    15     ||
    18 
    16 
    19 template "widget[@type='Switch']", mode="widget_defs" {
    17 widget_defs("Switch") {
    20     param "hmi_element";
    18     param "hmi_element";
    21     |     choices: [
    19     |     choices: [
    22     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    20     const "regex",!"'^(\"[^\"].*\"|\-?[0-9]+|false|true)(#.*)?$'"!;
    23 
    21 
    24     const "subelts", "$result_widgets[@id = $hmi_element/@id]//*";
    22     const "subelts", "$result_widgets[@id = $hmi_element/@id]//*";