svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 3084 1ae4a871b6f9
parent 3080 e5fa1f49f0b9
child 3085 6b1b23971960
equal deleted inserted replaced
3083:45f044cf845b 3084:1ae4a871b6f9
  3852 </xsl:text>
  3852 </xsl:text>
  3853     <xsl:text>
  3853     <xsl:text>
  3854 </xsl:text>
  3854 </xsl:text>
  3855     <xsl:text>    do_http_request(...opt) {
  3855     <xsl:text>    do_http_request(...opt) {
  3856 </xsl:text>
  3856 </xsl:text>
       
  3857     <xsl:text>        console.log(opt);
       
  3858 </xsl:text>
  3857     <xsl:text>        const query = {
  3859     <xsl:text>        const query = {
  3858 </xsl:text>
  3860 </xsl:text>
  3859     <xsl:text>            args: this.args,
  3861     <xsl:text>            args: this.args,
  3860 </xsl:text>
  3862 </xsl:text>
  3861     <xsl:text>            range: this.cache[1],
  3863     <xsl:text>            range: this.cache[1],
  3902 </xsl:text>
  3904 </xsl:text>
  3903     <xsl:text>    }
  3905     <xsl:text>    }
  3904 </xsl:text>
  3906 </xsl:text>
  3905     <xsl:text>    make_on_click(...options){
  3907     <xsl:text>    make_on_click(...options){
  3906 </xsl:text>
  3908 </xsl:text>
       
  3909     <xsl:text>        let that = this;
       
  3910 </xsl:text>
  3907     <xsl:text>        return function(evt){
  3911     <xsl:text>        return function(evt){
  3908 </xsl:text>
  3912 </xsl:text>
  3909     <xsl:text>            this.do_http_request(...options);
  3913     <xsl:text>            that.do_http_request(...options);
  3910 </xsl:text>
  3914 </xsl:text>
  3911     <xsl:text>        }
  3915     <xsl:text>        }
  3912 </xsl:text>
  3916 </xsl:text>
  3913     <xsl:text>    }
  3917     <xsl:text>    }
  3914 </xsl:text>
  3918 </xsl:text>
  4007     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  4011     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  4008     <xsl:choose>
  4012     <xsl:choose>
  4009       <xsl:when test="count($from_list) &gt; 0">
  4013       <xsl:when test="count($from_list) &gt; 0">
  4010         <xsl:text>        id("</xsl:text>
  4014         <xsl:text>        id("</xsl:text>
  4011         <xsl:value-of select="@id"/>
  4015         <xsl:value-of select="@id"/>
  4012         <xsl:text>").setAttribute("xlink:href", 
  4016         <xsl:text>").setAttribute("xlink:href",
  4013 </xsl:text>
  4017 </xsl:text>
  4014         <xsl:text>            "#"+hmi_widgets["</xsl:text>
  4018         <xsl:text>            "#"+hmi_widgets["</xsl:text>
  4015         <xsl:value-of select="$from_list/@id"/>
  4019         <xsl:value-of select="$from_list/@id"/>
  4016         <xsl:text>"].items[</xsl:text>
  4020         <xsl:text>"].items[</xsl:text>
  4017         <xsl:value-of select="$expressions/expression[1]/@content"/>
  4021         <xsl:value-of select="$expressions/expression[1]/@content"/>
  4105     <xsl:for-each select="$new_expressions/expression[position() &gt; 1][starts-with(@name,'onClick')]">
  4109     <xsl:for-each select="$new_expressions/expression[position() &gt; 1][starts-with(@name,'onClick')]">
  4106       <xsl:text>        id("</xsl:text>
  4110       <xsl:text>        id("</xsl:text>
  4107       <xsl:value-of select="$elt/@id"/>
  4111       <xsl:value-of select="$elt/@id"/>
  4108       <xsl:text>").onclick = this.make_on_click('</xsl:text>
  4112       <xsl:text>").onclick = this.make_on_click('</xsl:text>
  4109       <xsl:value-of select="@name"/>
  4113       <xsl:value-of select="@name"/>
  4110       <xsl:text>', '"+</xsl:text>
  4114       <xsl:text>', </xsl:text>
  4111       <xsl:value-of select="@content"/>
  4115       <xsl:value-of select="@content"/>
  4112       <xsl:text>+"');
  4116       <xsl:text>);
  4113 </xsl:text>
  4117 </xsl:text>
  4114     </xsl:for-each>
  4118     </xsl:for-each>
  4115     <xsl:apply-templates mode="json_table_elt_render" select=".">
  4119     <xsl:apply-templates mode="json_table_elt_render" select=".">
  4116       <xsl:with-param name="expressions" select="$new_expressions"/>
  4120       <xsl:with-param name="expressions" select="$new_expressions"/>
  4117     </xsl:apply-templates>
  4121     </xsl:apply-templates>
  4324 </xsl:text>
  4328 </xsl:text>
  4325       </xsl:if>
  4329       </xsl:if>
  4326       <xsl:text>    },
  4330       <xsl:text>    },
  4327 </xsl:text>
  4331 </xsl:text>
  4328     </xsl:if>
  4332     </xsl:if>
  4329     <xsl:text>    on_click: function(evt) {
       
  4330 </xsl:text>
       
  4331     <xsl:text>        const index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
       
  4332 </xsl:text>
       
  4333     <xsl:text>        const name = this.args[0];
       
  4334 </xsl:text>
       
  4335     <xsl:text>        switch_page(name, index);
       
  4336 </xsl:text>
       
  4337     <xsl:text>    },
       
  4338 </xsl:text>
       
  4339     <xsl:if test="$have_activity">
  4333     <xsl:if test="$have_activity">
  4340       <xsl:text>    notify_page_change: function(page_name, index){
  4334       <xsl:text>    notify_page_change: function(page_name, index){
  4341 </xsl:text>
  4335 </xsl:text>
  4342       <xsl:text>        const ref_index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
  4336       <xsl:text>        const ref_index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
  4343 </xsl:text>
  4337 </xsl:text>
  4348       <xsl:text>        this.update();
  4342       <xsl:text>        this.update();
  4349 </xsl:text>
  4343 </xsl:text>
  4350       <xsl:text>    },
  4344       <xsl:text>    },
  4351 </xsl:text>
  4345 </xsl:text>
  4352     </xsl:if>
  4346     </xsl:if>
       
  4347     <xsl:text>    make_on_click(){
       
  4348 </xsl:text>
       
  4349     <xsl:text>        let that = this;
       
  4350 </xsl:text>
       
  4351     <xsl:text>        const name = this.args[0];
       
  4352 </xsl:text>
       
  4353     <xsl:text>        return function(evt){
       
  4354 </xsl:text>
       
  4355     <xsl:text>            const index = that.indexes.length &gt; 0 ? that.indexes[0] + that.offset : undefined;
       
  4356 </xsl:text>
       
  4357     <xsl:text>            switch_page(name, index);
       
  4358 </xsl:text>
       
  4359     <xsl:text>        }
       
  4360 </xsl:text>
       
  4361     <xsl:text>    },
       
  4362 </xsl:text>
  4353     <xsl:text>    init: function() {
  4363     <xsl:text>    init: function() {
  4354 </xsl:text>
  4364 </xsl:text>
  4355     <xsl:text>        this.element.setAttribute("onclick", "hmi_widgets['</xsl:text>
  4365     <xsl:text>        this.element.onclick = this.make_on_click();
  4356     <xsl:value-of select="$hmi_element/@id"/>
       
  4357     <xsl:text>'].on_click(evt)");
       
  4358 </xsl:text>
  4366 </xsl:text>
  4359     <xsl:if test="$have_activity">
  4367     <xsl:if test="$have_activity">
  4360       <xsl:text>        this.active_elt_style = this.active_elt.getAttribute("style");
  4368       <xsl:text>        this.active_elt_style = this.active_elt.getAttribute("style");
  4361 </xsl:text>
  4369 </xsl:text>
  4362       <xsl:text>        this.inactive_elt_style = this.inactive_elt.getAttribute("style");
  4370       <xsl:text>        this.inactive_elt_style = this.inactive_elt.getAttribute("style");
  5974     <xsl:comment>
  5982     <xsl:comment>
  5975       <xsl:apply-templates select="document('')/*/debug:*"/>
  5983       <xsl:apply-templates select="document('')/*/debug:*"/>
  5976     </xsl:comment>
  5984     </xsl:comment>
  5977     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  5985     <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
  5978       <head/>
  5986       <head/>
  5979       <body style="margin:0;overflow:hidden;user-select:none;">
  5987       <body style="margin:0;overflow:hidden;user-select:none;touch-action:none;">
  5980         <xsl:copy-of select="$result_svg"/>
  5988         <xsl:copy-of select="$result_svg"/>
  5981         <script>
  5989         <script>
  5982           <xsl:text>
  5990           <xsl:text>
  5983 //
  5991 //
  5984 //
  5992 //
  6635 </xsl:text>
  6643 </xsl:text>
  6636           <xsl:text>
  6644           <xsl:text>
  6637 </xsl:text>
  6645 </xsl:text>
  6638           <xsl:text>function prepare_svg() {
  6646           <xsl:text>function prepare_svg() {
  6639 </xsl:text>
  6647 </xsl:text>
       
  6648           <xsl:text>    document.body.addEventListener('contextmenu', e =&gt; {
       
  6649 </xsl:text>
       
  6650           <xsl:text>        e.preventDefault();
       
  6651 </xsl:text>
       
  6652           <xsl:text>    });
       
  6653 </xsl:text>
  6640           <xsl:text>    for(let eltid in detachable_elements){
  6654           <xsl:text>    for(let eltid in detachable_elements){
  6641 </xsl:text>
  6655 </xsl:text>
  6642           <xsl:text>        let [element,parent] = detachable_elements[eltid];
  6656           <xsl:text>        let [element,parent] = detachable_elements[eltid];
  6643 </xsl:text>
  6657 </xsl:text>
  6644           <xsl:text>        parent.removeChild(element);
  6658           <xsl:text>        parent.removeChild(element);