svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2902 1fcb50af0335
parent 2901 3f5194bba67d
child 2903 881d0248b3ce
equal deleted inserted replaced
2901:3f5194bba67d 2902:1fcb50af0335
   692       <xsl:otherwise>
   692       <xsl:otherwise>
   693         <func:result select="$txt"/>
   693         <func:result select="$txt"/>
   694       </xsl:otherwise>
   694       </xsl:otherwise>
   695     </xsl:choose>
   695     </xsl:choose>
   696   </func:function>
   696   </func:function>
       
   697   <xsl:template mode="widget_defs" match="widget[@type='Back']">
       
   698     <xsl:param name="hmi_element"/>
       
   699     <xsl:text>    on_click: function(evt) {
       
   700 </xsl:text>
       
   701     <xsl:text>        console.log("Back !");
       
   702 </xsl:text>
       
   703     <xsl:text>        if(jump_history.length &gt; 1){
       
   704 </xsl:text>
       
   705     <xsl:text>           jump_history.pop();
       
   706 </xsl:text>
       
   707     <xsl:text>           let [page_name, index] = jump_history.pop();
       
   708 </xsl:text>
       
   709     <xsl:text>           switch_page(page_name, index);
       
   710 </xsl:text>
       
   711     <xsl:text>        }
       
   712 </xsl:text>
       
   713     <xsl:text>    },
       
   714 </xsl:text>
       
   715     <xsl:text>    init: function() {
       
   716 </xsl:text>
       
   717     <xsl:text>        this.element.setAttribute("onclick", "hmi_widgets['</xsl:text>
       
   718     <xsl:value-of select="$hmi_element/@id"/>
       
   719     <xsl:text>'].on_click(evt)");
       
   720 </xsl:text>
       
   721     <xsl:text>    },
       
   722 </xsl:text>
       
   723   </xsl:template>
   697   <xsl:template mode="widget_defs" match="widget[@type='Display']">
   724   <xsl:template mode="widget_defs" match="widget[@type='Display']">
   698     <xsl:param name="hmi_element"/>
   725     <xsl:param name="hmi_element"/>
   699     <xsl:text>    frequency: 5,
   726     <xsl:text>    frequency: 5,
   700 </xsl:text>
   727 </xsl:text>
   701     <xsl:text>    dispatch: function(value) {
   728     <xsl:text>    dispatch: function(value) {
   888     <xsl:param name="hmi_element"/>
   915     <xsl:param name="hmi_element"/>
   889     <xsl:text>    on_click: function(evt) {
   916     <xsl:text>    on_click: function(evt) {
   890 </xsl:text>
   917 </xsl:text>
   891     <xsl:text>        const index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
   918     <xsl:text>        const index = this.indexes.length &gt; 0 ? this.indexes[0] + this.offset : undefined;
   892 </xsl:text>
   919 </xsl:text>
   893     <xsl:text>        switch_page(this.args[0], index);
   920     <xsl:text>        const name = this.args[0];
       
   921 </xsl:text>
       
   922     <xsl:text>        switch_page(name, index);
   894 </xsl:text>
   923 </xsl:text>
   895     <xsl:text>    },
   924     <xsl:text>    },
   896 </xsl:text>
   925 </xsl:text>
   897     <xsl:text>    init: function() {
   926     <xsl:text>    init: function() {
   898 </xsl:text>
   927 </xsl:text>
  1193 </xsl:text>
  1222 </xsl:text>
  1194     <xsl:text>var updates = {};
  1223     <xsl:text>var updates = {};
  1195 </xsl:text>
  1224 </xsl:text>
  1196     <xsl:text>var need_cache_apply = []; 
  1225     <xsl:text>var need_cache_apply = []; 
  1197 </xsl:text>
  1226 </xsl:text>
       
  1227     <xsl:text>var jump_history = [[default_page, undefined]];
       
  1228 </xsl:text>
  1198     <xsl:text>
  1229     <xsl:text>
  1199 </xsl:text>
  1230 </xsl:text>
  1200     <xsl:text>function dispatch_value_to_widget(widget, index, value, oldval) {
  1231     <xsl:text>function dispatch_value_to_widget(widget, index, value, oldval) {
  1201 </xsl:text>
  1232 </xsl:text>
  1202     <xsl:text>    try {
  1233     <xsl:text>    try {
  1729 </xsl:text>
  1760 </xsl:text>
  1730     <xsl:text>        /* page switch already going */
  1761     <xsl:text>        /* page switch already going */
  1731 </xsl:text>
  1762 </xsl:text>
  1732     <xsl:text>        /* TODO LOG ERROR */
  1763     <xsl:text>        /* TODO LOG ERROR */
  1733 </xsl:text>
  1764 </xsl:text>
  1734     <xsl:text>        return;
  1765     <xsl:text>        return false;
  1735 </xsl:text>
  1766 </xsl:text>
  1736     <xsl:text>    }
  1767     <xsl:text>    }
  1737 </xsl:text>
  1768 </xsl:text>
  1738     <xsl:text>
  1769     <xsl:text>
  1739 </xsl:text>
  1770 </xsl:text>
  1741 </xsl:text>
  1772 </xsl:text>
  1742     <xsl:text>        page_name = current_subscribed_page;
  1773     <xsl:text>        page_name = current_subscribed_page;
  1743 </xsl:text>
  1774 </xsl:text>
  1744     <xsl:text>
  1775     <xsl:text>
  1745 </xsl:text>
  1776 </xsl:text>
  1746     <xsl:text>    switch_subscribed_page(page_name, page_index);
  1777     <xsl:text>    return switch_subscribed_page(page_name, page_index);
  1747 </xsl:text>
  1778 </xsl:text>
  1748     <xsl:text>};
  1779     <xsl:text>};
  1749 </xsl:text>
  1780 </xsl:text>
  1750     <xsl:text>
  1781     <xsl:text>
  1751 </xsl:text>
  1782 </xsl:text>
  1933 </xsl:text>
  1964 </xsl:text>
  1934     <xsl:text>    if(new_desc == undefined){
  1965     <xsl:text>    if(new_desc == undefined){
  1935 </xsl:text>
  1966 </xsl:text>
  1936     <xsl:text>        /* TODO LOG ERROR */
  1967     <xsl:text>        /* TODO LOG ERROR */
  1937 </xsl:text>
  1968 </xsl:text>
  1938     <xsl:text>        return;
  1969     <xsl:text>        return false;
  1939 </xsl:text>
  1970 </xsl:text>
  1940     <xsl:text>    }
  1971     <xsl:text>    }
  1941 </xsl:text>
  1972 </xsl:text>
  1942     <xsl:text>
  1973     <xsl:text>
  1943 </xsl:text>
  1974 </xsl:text>
  1973 </xsl:text>
  2004 </xsl:text>
  1974     <xsl:text>
  2005     <xsl:text>
  1975 </xsl:text>
  2006 </xsl:text>
  1976     <xsl:text>    requestHMIAnimation();
  2007     <xsl:text>    requestHMIAnimation();
  1977 </xsl:text>
  2008 </xsl:text>
       
  2009     <xsl:text>
       
  2010 </xsl:text>
       
  2011     <xsl:text>    jump_history.push([page_name, page_index]);
       
  2012 </xsl:text>
       
  2013     <xsl:text>
       
  2014 </xsl:text>
       
  2015     <xsl:text>    return true;
       
  2016 </xsl:text>
  1978     <xsl:text>}
  2017     <xsl:text>}
  1979 </xsl:text>
  2018 </xsl:text>
  1980     <xsl:text>
  2019     <xsl:text>
  1981 </xsl:text>
  2020 </xsl:text>
  1982     <xsl:text>function switch_visible_page(page_name) {
  2021     <xsl:text>function switch_visible_page(page_name) {