svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2896 99c5335ed59f
parent 2895 89c02b452717
child 2897 bf8a39cc65e4
equal deleted inserted replaced
2895:89c02b452717 2896:99c5335ed59f
   721       <xsl:text>
   721       <xsl:text>
   722 </xsl:text>
   722 </xsl:text>
   723     </xsl:for-each>
   723     </xsl:for-each>
   724     <xsl:text>    ],
   724     <xsl:text>    ],
   725 </xsl:text>
   725 </xsl:text>
   726     <xsl:text>    buttons: [
   726     <xsl:text>    init: function() {
   727 </xsl:text>
   727 </xsl:text>
   728     <xsl:variable name="prefix" select="concat($class,':')"/>
   728     <xsl:variable name="prefix" select="concat($class,':')"/>
   729     <xsl:variable name="buttons_regex" select="concat('^',$prefix,'[+\-][0-9]+')"/>
   729     <xsl:variable name="buttons_regex" select="concat('^',$prefix,'[+\-][0-9]+')"/>
   730     <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]">
   730     <xsl:variable name="buttons" select="$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"/>
   731       <xsl:text>        ["</xsl:text>
   731     <xsl:for-each select="$buttons">
   732       <xsl:value-of select="substring-after(@inkscape:label, concat(arg[1]/@value, ':'))"/>
   732       <xsl:variable name="op" select="substring-after(@inkscape:label, $prefix)"/>
   733       <xsl:text>", id("</xsl:text>
   733       <xsl:text>        id("</xsl:text>
   734       <xsl:value-of select="@id"/>
   734       <xsl:value-of select="@id"/>
   735       <xsl:text>")]</xsl:text>
   735       <xsl:text>").setAttribute("onclick", "hmi_widgets['</xsl:text>
   736       <xsl:if test="position()!=last()">
   736       <xsl:value-of select="$hmi_element/@id"/>
   737         <xsl:text>,</xsl:text>
   737       <xsl:text>'].on_click('</xsl:text>
   738       </xsl:if>
   738       <xsl:value-of select="$op"/>
   739       <xsl:text>
   739       <xsl:text>', evt)");
   740 </xsl:text>
   740 </xsl:text>
   741     </xsl:for-each>
   741     </xsl:for-each>
   742     <xsl:text>    ],
   742     <xsl:text>
   743 </xsl:text>
       
   744     <xsl:text>    init: function() {
       
   745 </xsl:text>
       
   746     <xsl:text>        /* TODO elt.setAttribute("onclick", "hmi_widgets['</xsl:text>
       
   747     <xsl:value-of select="$hmi_element/@id"/>
       
   748     <xsl:text>'].on_click(evt)");*/
       
   749 </xsl:text>
   743 </xsl:text>
   750     <xsl:text>        this.items = [
   744     <xsl:text>        this.items = [
   751 </xsl:text>
   745 </xsl:text>
   752     <xsl:variable name="items_regex" select="concat('^',$prefix,'[0-9]+')"/>
   746     <xsl:variable name="items_regex" select="concat('^',$prefix,'[0-9]+')"/>
   753     <xsl:variable name="unordered_items" select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"/>
   747     <xsl:variable name="unordered_items" select="$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"/>
   777             <xsl:value-of select="@id"/>
   771             <xsl:value-of select="@id"/>
   778             <xsl:text>" label="</xsl:text>
   772             <xsl:text>" label="</xsl:text>
   779             <xsl:value-of select="@inkscape:label"/>
   773             <xsl:value-of select="@inkscape:label"/>
   780             <xsl:text>" is having wrong path. Accroding to ForEach widget ancestor id="</xsl:text>
   774             <xsl:text>" is having wrong path. Accroding to ForEach widget ancestor id="</xsl:text>
   781             <xsl:value-of select="$hmi_element/@id"/>
   775             <xsl:value-of select="$hmi_element/@id"/>
   782             <xsl:text>", path should be descendant of </xsl:text>
   776             <xsl:text>", path should be descendant of "</xsl:text>
   783             <xsl:value-of select="$item_path"/>
   777             <xsl:value-of select="$item_path"/>
   784             <xsl:text>.</xsl:text>
   778             <xsl:text>".</xsl:text>
   785           </xsl:message>
   779           </xsl:message>
   786         </xsl:if>
   780         </xsl:if>
   787         <xsl:text>            hmi_widgets["</xsl:text>
   781         <xsl:text>            hmi_widgets["</xsl:text>
   788         <xsl:value-of select="@id"/>
   782         <xsl:value-of select="@id"/>
   789         <xsl:text>"]</xsl:text>
   783         <xsl:text>"]</xsl:text>
   802     </xsl:for-each>
   796     </xsl:for-each>
   803     <xsl:text>        ]
   797     <xsl:text>        ]
   804 </xsl:text>
   798 </xsl:text>
   805     <xsl:text>    },
   799     <xsl:text>    },
   806 </xsl:text>
   800 </xsl:text>
       
   801     <xsl:text>    on_click: function(opstr, evt) {
       
   802 </xsl:text>
       
   803     <xsl:text>        console.log(opstr);
       
   804 </xsl:text>
       
   805     <xsl:text>    },
       
   806 </xsl:text>
   807     <xsl:text>    item_offset: 0,
   807     <xsl:text>    item_offset: 0,
   808 </xsl:text>
   808 </xsl:text>
   809   </xsl:template>
   809   </xsl:template>
   810   <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']">
   810   <xsl:template mode="widget_subscribe" match="widget[@type='ForEach']">
   811     <xsl:text>    sub: function(off){
   811     <xsl:text>    sub: function(off){
   812 </xsl:text>
   812 </xsl:text>
   813     <xsl:text>        subscribe_foreach.call(this,off);
   813     <xsl:text>        foreach_subscribe.call(this,off);
   814 </xsl:text>
   814 </xsl:text>
   815     <xsl:text>    },
   815     <xsl:text>    },
   816 </xsl:text>
   816 </xsl:text>
   817     <xsl:text>    unsub: function(){
   817     <xsl:text>    unsub: function(){
   818 </xsl:text>
   818 </xsl:text>
   819     <xsl:text>        unsubscribe_foreach.call(this);
   819     <xsl:text>        foreach_unsubscribe.call(this);
   820 </xsl:text>
   820 </xsl:text>
   821     <xsl:text>    },
   821     <xsl:text>    },
   822 </xsl:text>
   822 </xsl:text>
   823   </xsl:template>
   823   </xsl:template>
   824   <xsl:template mode="widget_defs" match="widget[@type='Input']">
   824   <xsl:template mode="widget_defs" match="widget[@type='Input']">
  1749 </xsl:text>
  1749 </xsl:text>
  1750     <xsl:text>}
  1750     <xsl:text>}
  1751 </xsl:text>
  1751 </xsl:text>
  1752     <xsl:text>
  1752     <xsl:text>
  1753 </xsl:text>
  1753 </xsl:text>
  1754     <xsl:text>function unsubscribe_foreach(){
  1754     <xsl:text>function foreach_unsubscribe(){
  1755 </xsl:text>
  1755 </xsl:text>
  1756     <xsl:text>    for(let item of this.items){
  1756     <xsl:text>    for(let item of this.items){
  1757 </xsl:text>
  1757 </xsl:text>
  1758     <xsl:text>        for(let widget of item) {
  1758     <xsl:text>        for(let widget of item) {
  1759 </xsl:text>
  1759 </xsl:text>
  1765 </xsl:text>
  1765 </xsl:text>
  1766     <xsl:text>}
  1766     <xsl:text>}
  1767 </xsl:text>
  1767 </xsl:text>
  1768     <xsl:text>
  1768     <xsl:text>
  1769 </xsl:text>
  1769 </xsl:text>
  1770     <xsl:text>function subscribe_foreach(new_offset=0){
  1770     <xsl:text>function foreach_subscribe(new_offset=0){
  1771 </xsl:text>
  1771 </xsl:text>
  1772     <xsl:text>    for(let i = 0; i &lt; this.items.length; i++) {
  1772     <xsl:text>    for(let i = 0; i &lt; this.items.length; i++) {
  1773 </xsl:text>
  1773 </xsl:text>
  1774     <xsl:text>        let item = this.items[i];
  1774     <xsl:text>        let item = this.items[i];
  1775 </xsl:text>
  1775 </xsl:text>