svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2788 2ed9ff826d03
parent 2783 5ee6967f721d
child 2789 ba0dd2ec6dc4
equal deleted inserted replaced
2787:86a572fb05f8 2788:2ed9ff826d03
    44           <xsl:apply-templates mode="code_from_descs" select="//*[contains(child::svg:desc, $midmark) or                                starts-with(child::svg:desc, $mark)]"/>
    44           <xsl:apply-templates mode="code_from_descs" select="//*[contains(child::svg:desc, $midmark) or                                starts-with(child::svg:desc, $mark)]"/>
    45           <xsl:text>    return res;
    45           <xsl:text>    return res;
    46 </xsl:text>
    46 </xsl:text>
    47           <xsl:text>}
    47           <xsl:text>}
    48 </xsl:text>
    48 </xsl:text>
       
    49           <xsl:text>// svghmi.js
       
    50 </xsl:text>
       
    51           <xsl:text>
       
    52 </xsl:text>
    49           <xsl:text>(function(){
    53           <xsl:text>(function(){
    50 </xsl:text>
    54 </xsl:text>
    51           <xsl:text>    var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
    55           <xsl:text>    // Open WebSocket to relative "/ws" address
    52 </xsl:text>
    56 </xsl:text>
    53           <xsl:text>    var ws = new WebSocket(relative_URI);
    57           <xsl:text>    var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws'));
       
    58 </xsl:text>
       
    59           <xsl:text>
       
    60 </xsl:text>
       
    61           <xsl:text>    // Register message reception handler 
    54 </xsl:text>
    62 </xsl:text>
    55           <xsl:text>    ws.onmessage = function (evt) {
    63           <xsl:text>    ws.onmessage = function (evt) {
    56 </xsl:text>
    64 </xsl:text>
       
    65           <xsl:text>        // TODO : dispatch and cache hmi tree updates
       
    66 </xsl:text>
       
    67           <xsl:text>
       
    68 </xsl:text>
    57           <xsl:text>        var received_msg = evt.data;
    69           <xsl:text>        var received_msg = evt.data;
       
    70 </xsl:text>
       
    71           <xsl:text>        // TODO : check for hmitree hash header
       
    72 </xsl:text>
       
    73           <xsl:text>        //        if not matching, reload page
    58 </xsl:text>
    74 </xsl:text>
    59           <xsl:text>        alert("Message is received..."+received_msg); 
    75           <xsl:text>        alert("Message is received..."+received_msg); 
    60 </xsl:text>
    76 </xsl:text>
    61           <xsl:text>    };
    77           <xsl:text>    };
    62 </xsl:text>
    78 </xsl:text>
       
    79           <xsl:text>
       
    80 </xsl:text>
       
    81           <xsl:text>    // Once connection established
       
    82 </xsl:text>
    63           <xsl:text>    ws.onopen = function (evt) {
    83           <xsl:text>    ws.onopen = function (evt) {
       
    84 </xsl:text>
       
    85           <xsl:text>        // TODO : enable the HMI (was previously offline, or just starts)
       
    86 </xsl:text>
       
    87           <xsl:text>        //        show main page
       
    88 </xsl:text>
       
    89           <xsl:text>
       
    90 </xsl:text>
       
    91           <xsl:text>
       
    92 </xsl:text>
       
    93           <xsl:text>        // TODO : prefix with hmitree hash header
    64 </xsl:text>
    94 </xsl:text>
    65           <xsl:text>        ws.send("test");
    95           <xsl:text>        ws.send("test");
    66 </xsl:text>
    96 </xsl:text>
    67           <xsl:text>    };
    97           <xsl:text>    };
    68 </xsl:text>
    98 </xsl:text>