svghmi/scripts.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sat, 18 Apr 2020 13:14:45 +0200
branchsvghmi
changeset 2938 1379cd5c69dd
parent 2937 svghmi/gen_index_xhtml.ysl2@9226a830fbc3
permissions -rw-r--r--
SVGHMI: Added scripts.ysl2
function "scripts"
{
    |
    | id = idstr => document.getElementById(idstr);
    |
    | var hmi_hash = [«$hmitree/@hash»];

    | var hmi_widgets = {
    apply "$hmi_elements", mode="hmi_elements";
    | }
    |
    | var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»;
    |
    | var hmitree_types = [

    foreach "$indexed_hmitree/*" {
    |     /* «@index»  «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
    }

    | ]
    |

    | var detachable_elements = {
    foreach "$detachable_elements"{
    |     "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
    }
    | }

    |
    | var page_desc = {
    apply "$hmi_pages", mode="page_desc";
    | }

    | var keypads = {
    foreach "$keypads_descs"{
        const "keypad_id","@id";
        foreach "arg"{
            const "g", "$geometry[@Id = $keypad_id]";
    |     "«@value»":["«$keypad_id»", «$g/@x», «$g/@y»],
        }
    }
    | }


    |
    | var default_page = "«$default_page»";
    | var svg_root = id("«/svg:svg/@id»");
    include text svghmi.js
}