svghmi/widget_custom.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 29 Mar 2022 08:50:01 +0200
branchwxPython4
changeset 3446 de8cc85b688a
parent 2909 0519fdce9a59
permissions -rw-r--r--
Tests: refactored sikuli based test
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     1
// widget_custom.ysl2
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     2
//
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     3
// widget entierely defined from JS code in Inkscape description field
2779
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     4
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     5
// TODO
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
     6
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     7
// a preliminary implementation was initially attempted but disabled
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     8
// code collected around before code refactoring
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
     9
2790
8fab1886ebec SVGHI: compute hmitree variables ordered index in xslt
Edouard Tisserant
parents: 2789
diff changeset
    10
2909
0519fdce9a59 SVGHMI: moved dead code to where it belongs
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2883
diff changeset
    11
/*const "mark" > =HMI=\n*/
0519fdce9a59 SVGHMI: moved dead code to where it belongs
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2883
diff changeset
    12
2792
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    13
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    14
        /* TODO re-enable
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    15
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    16
        function evaluate_js_from_descriptions() {
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    17
            var Page;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    18
            var Input;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    19
            var Display;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    20
            var res = [];
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    21
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    22
        const "midmark" > \n«$mark»
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    23
        apply """//*[contains(child::svg:desc, $midmark) or \
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    24
                     starts-with(child::svg:desc, $mark)]""",2 
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    25
              mode="code_from_descs";
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    26
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    27
            return res;
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    28
        }
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    29
        ||
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    30
        */
0c0d3895b036 SVGHMI: moved/fixed some templates, avoided namespace problems, added parsing of HMI:* inkscape labels
Edouard Tisserant
parents: 2791
diff changeset
    31
2810
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    32
    // template "*", mode="code_from_descs" {
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    33
    //     ||
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    34
    //     {
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    35
    //         var path, role, name, priv;
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    36
    //         var id = "«@id»";
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    37
    //     ||
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    38
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    39
    //     /* if label is used, use it as default name */
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    40
    //     if "@inkscape:label"
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    41
    //         |> name = "«@inkscape:label»";
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    42
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    43
    //     | /* -------------- */
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    44
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    45
    //     // this breaks indent, but fixing indent could break string literals
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    46
    //     value "substring-after(svg:desc, $mark)";
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    47
    //     // nobody reads generated code anyhow...
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    48
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    49
    //     ||
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    50
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    51
    //         /* -------------- */
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    52
    //         res.push({
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    53
    //             path:path,
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    54
    //             role:role,
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    55
    //             name:name,
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    56
    //             priv:priv
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    57
    //         })
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    58
    //     }
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    59
    //     ||
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    60
    // }
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    61
63b9a37b73c7 SVGHMI: various insignificant code moves, commenting and typos fixes.
Edouard Tisserant
parents: 2808
diff changeset
    62