svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 3019 497aac6522a3
parent 3018 22b969b409b0
child 3021 49799de67540
equal deleted inserted replaced
3018:22b969b409b0 3019:497aac6522a3
     1 <?xml version="1.0"?>
     1 <?xml version="1.0"?>
     2 <xsl:stylesheet xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:definitions="definitions" xmlns:ns="beremiz" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:exsl="http://exslt.org/common" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:preamble="preamble" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:str="http://exslt.org/strings" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:debug="debug" xmlns:svg="http://www.w3.org/2000/svg" xmlns:declarations="declarations" xmlns:cc="http://creativecommons.org/ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions">
     2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0">
     3   <xsl:output cdata-section-elements="xhtml:script" method="xml"/>
     3   <xsl:output method="xml" cdata-section-elements="xhtml:script"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     4   <xsl:variable name="svg" select="/svg:svg"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     5   <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     6   <xsl:variable name="hmitree" select="ns:GetHMITree()"/>
     7   <xsl:variable name="_categories">
     7   <xsl:variable name="_categories">
     8     <noindex>
     8     <noindex>
    12       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    12       <xsl:text>HMI_CURRENT_PAGE</xsl:text>
    13     </noindex>
    13     </noindex>
    14   </xsl:variable>
    14   </xsl:variable>
    15   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    15   <xsl:variable name="categories" select="exsl:node-set($_categories)"/>
    16   <xsl:variable name="_indexed_hmitree">
    16   <xsl:variable name="_indexed_hmitree">
    17     <xsl:apply-templates select="$hmitree" mode="index"/>
    17     <xsl:apply-templates mode="index" select="$hmitree"/>
    18   </xsl:variable>
    18   </xsl:variable>
    19   <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/>
    19   <xsl:variable name="indexed_hmitree" select="exsl:node-set($_indexed_hmitree)"/>
    20   <preamble:hmi-tree/>
    20   <preamble:hmi-tree/>
    21   <xsl:template match="preamble:hmi-tree">
    21   <xsl:template match="preamble:hmi-tree">
    22     <xsl:text>
    22     <xsl:text>
    60     <xsl:text>
    60     <xsl:text>
    61 </xsl:text>
    61 </xsl:text>
    62     <xsl:text>
    62     <xsl:text>
    63 </xsl:text>
    63 </xsl:text>
    64   </xsl:template>
    64   </xsl:template>
    65   <xsl:template match="*" mode="index">
    65   <xsl:template mode="index" match="*">
    66     <xsl:param name="index" select="0"/>
    66     <xsl:param name="index" select="0"/>
    67     <xsl:param name="parentpath" select="''"/>
    67     <xsl:param name="parentpath" select="''"/>
    68     <xsl:variable name="content">
    68     <xsl:variable name="content">
    69       <xsl:variable name="path">
    69       <xsl:variable name="path">
    70         <xsl:choose>
    70         <xsl:choose>
    93             </xsl:attribute>
    93             </xsl:attribute>
    94             <xsl:for-each select="@*">
    94             <xsl:for-each select="@*">
    95               <xsl:copy/>
    95               <xsl:copy/>
    96             </xsl:for-each>
    96             </xsl:for-each>
    97           </xsl:copy>
    97           </xsl:copy>
    98           <xsl:apply-templates select="*[1]" mode="index">
    98           <xsl:apply-templates mode="index" select="*[1]">
    99             <xsl:with-param name="index" select="$index + 1"/>
    99             <xsl:with-param name="index" select="$index + 1"/>
   100             <xsl:with-param name="parentpath">
   100             <xsl:with-param name="parentpath">
   101               <xsl:value-of select="$path"/>
   101               <xsl:value-of select="$path"/>
   102             </xsl:with-param>
   102             </xsl:with-param>
   103           </xsl:apply-templates>
   103           </xsl:apply-templates>
   104         </xsl:when>
   104         </xsl:when>
   105         <xsl:otherwise>
   105         <xsl:otherwise>
   106           <xsl:apply-templates select="*[1]" mode="index">
   106           <xsl:apply-templates mode="index" select="*[1]">
   107             <xsl:with-param name="index" select="$index"/>
   107             <xsl:with-param name="index" select="$index"/>
   108             <xsl:with-param name="parentpath">
   108             <xsl:with-param name="parentpath">
   109               <xsl:value-of select="$path"/>
   109               <xsl:value-of select="$path"/>
   110             </xsl:with-param>
   110             </xsl:with-param>
   111           </xsl:apply-templates>
   111           </xsl:apply-templates>
   112         </xsl:otherwise>
   112         </xsl:otherwise>
   113       </xsl:choose>
   113       </xsl:choose>
   114     </xsl:variable>
   114     </xsl:variable>
   115     <xsl:copy-of select="$content"/>
   115     <xsl:copy-of select="$content"/>
   116     <xsl:apply-templates select="following-sibling::*[1]" mode="index">
   116     <xsl:apply-templates mode="index" select="following-sibling::*[1]">
   117       <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/>
   117       <xsl:with-param name="index" select="$index + count(exsl:node-set($content)/*)"/>
   118       <xsl:with-param name="parentpath">
   118       <xsl:with-param name="parentpath">
   119         <xsl:value-of select="$parentpath"/>
   119         <xsl:value-of select="$parentpath"/>
   120       </xsl:with-param>
   120       </xsl:with-param>
   121     </xsl:apply-templates>
   121     </xsl:apply-templates>
   122   </xsl:template>
   122   </xsl:template>
   123   <xsl:template match="*" mode="parselabel">
   123   <xsl:template mode="parselabel" match="*">
   124     <xsl:variable name="label" select="@inkscape:label"/>
   124     <xsl:variable name="label" select="@inkscape:label"/>
   125     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
   125     <xsl:variable name="description" select="substring-after($label,'HMI:')"/>
   126     <xsl:variable name="_args" select="substring-before($description,'@')"/>
   126     <xsl:variable name="_args" select="substring-before($description,'@')"/>
   127     <xsl:variable name="args">
   127     <xsl:variable name="args">
   128       <xsl:choose>
   128       <xsl:choose>
   182         </xsl:for-each>
   182         </xsl:for-each>
   183       </widget>
   183       </widget>
   184     </xsl:if>
   184     </xsl:if>
   185   </xsl:template>
   185   </xsl:template>
   186   <xsl:variable name="_parsed_widgets">
   186   <xsl:variable name="_parsed_widgets">
   187     <xsl:apply-templates select="$hmi_elements" mode="parselabel"/>
   187     <xsl:apply-templates mode="parselabel" select="$hmi_elements"/>
   188   </xsl:variable>
   188   </xsl:variable>
   189   <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/>
   189   <xsl:variable name="parsed_widgets" select="exsl:node-set($_parsed_widgets)"/>
   190   <func:function name="func:widget">
   190   <func:function name="func:widget">
   191     <xsl:param name="id"/>
   191     <xsl:param name="id"/>
   192     <func:result select="$parsed_widgets/widget[@id = $id]"/>
   192     <func:result select="$parsed_widgets/widget[@id = $id]"/>
   201     <xsl:param name="b"/>
   201     <xsl:param name="b"/>
   202     <xsl:variable name="class_a" select="$indexed_hmitree/*[@hmipath = $a]/@class"/>
   202     <xsl:variable name="class_a" select="$indexed_hmitree/*[@hmipath = $a]/@class"/>
   203     <xsl:variable name="class_b" select="$indexed_hmitree/*[@hmipath = $b]/@class"/>
   203     <xsl:variable name="class_b" select="$indexed_hmitree/*[@hmipath = $b]/@class"/>
   204     <func:result select="$class_a and $class_b and $class_a = $class_b"/>
   204     <func:result select="$class_a and $class_b and $class_a = $class_b"/>
   205   </func:function>
   205   </func:function>
   206   <xsl:template match="*" mode="testtree">
   206   <xsl:template mode="testtree" match="*">
   207     <xsl:param name="indent" select="''"/>
   207     <xsl:param name="indent" select="''"/>
   208     <xsl:value-of select="$indent"/>
   208     <xsl:value-of select="$indent"/>
   209     <xsl:text> </xsl:text>
   209     <xsl:text> </xsl:text>
   210     <xsl:value-of select="local-name()"/>
   210     <xsl:value-of select="local-name()"/>
   211     <xsl:text> </xsl:text>
   211     <xsl:text> </xsl:text>
   215       <xsl:value-of select="."/>
   215       <xsl:value-of select="."/>
   216       <xsl:text>" </xsl:text>
   216       <xsl:text>" </xsl:text>
   217     </xsl:for-each>
   217     </xsl:for-each>
   218     <xsl:text>
   218     <xsl:text>
   219 </xsl:text>
   219 </xsl:text>
   220     <xsl:apply-templates select="*" mode="testtree">
   220     <xsl:apply-templates mode="testtree" select="*">
   221       <xsl:with-param name="indent">
   221       <xsl:with-param name="indent">
   222         <xsl:value-of select="concat($indent,'&gt;')"/>
   222         <xsl:value-of select="concat($indent,'&gt;')"/>
   223       </xsl:with-param>
   223       </xsl:with-param>
   224     </xsl:apply-templates>
   224     </xsl:apply-templates>
   225   </xsl:template>
   225   </xsl:template>
   233 </xsl:text>
   233 </xsl:text>
   234     <xsl:text>
   234     <xsl:text>
   235 </xsl:text>
   235 </xsl:text>
   236     <xsl:text>Raw HMI tree
   236     <xsl:text>Raw HMI tree
   237 </xsl:text>
   237 </xsl:text>
   238     <xsl:apply-templates select="$hmitree" mode="testtree"/>
   238     <xsl:apply-templates mode="testtree" select="$hmitree"/>
   239     <xsl:text>
   239     <xsl:text>
   240 </xsl:text>
   240 </xsl:text>
   241     <xsl:text>Indexed HMI tree
   241     <xsl:text>Indexed HMI tree
   242 </xsl:text>
   242 </xsl:text>
   243     <xsl:apply-templates select="$indexed_hmitree" mode="testtree"/>
   243     <xsl:apply-templates mode="testtree" select="$indexed_hmitree"/>
   244     <xsl:text>
   244     <xsl:text>
   245 </xsl:text>
   245 </xsl:text>
   246     <xsl:text>Parsed Widgets
   246     <xsl:text>Parsed Widgets
   247 </xsl:text>
   247 </xsl:text>
   248     <xsl:copy-of select="_parsed_widgets"/>
   248     <xsl:copy-of select="_parsed_widgets"/>
   249     <xsl:apply-templates select="$parsed_widgets" mode="testtree"/>
   249     <xsl:apply-templates mode="testtree" select="$parsed_widgets"/>
   250     <xsl:text>
   250     <xsl:text>
   251 </xsl:text>
   251 </xsl:text>
   252   </xsl:template>
   252   </xsl:template>
   253   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   253   <xsl:variable name="geometry" select="ns:GetSVGGeometry()"/>
   254   <debug:geometry/>
   254   <debug:geometry/>
   457 </xsl:text>
   457 </xsl:text>
   458   </xsl:template>
   458   </xsl:template>
   459   <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/>
   459   <xsl:variable name="forEach_widgets_ids" select="$parsed_widgets/widget[@type = 'ForEach']/@id"/>
   460   <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/>
   460   <xsl:variable name="forEach_widgets" select="$hmi_elements[@id = $forEach_widgets_ids]"/>
   461   <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/>
   461   <xsl:variable name="in_forEach_widget_ids" select="func:refered_elements($forEach_widgets)[not(@id = $forEach_widgets_ids)]/@id"/>
   462   <xsl:template match="svg:*" mode="page_desc">
   462   <xsl:template mode="page_desc" match="svg:*">
   463     <xsl:variable name="desc" select="func:widget(@id)"/>
   463     <xsl:variable name="desc" select="func:widget(@id)"/>
   464     <xsl:variable name="page" select="."/>
   464     <xsl:variable name="page" select="."/>
   465     <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
   465     <xsl:variable name="p" select="$geometry[@Id = $page/@id]"/>
   466     <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
   466     <xsl:variable name="page_all_elements" select="func:all_related_elements($page)"/>
   467     <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/>
   467     <xsl:variable name="all_page_widgets" select="$hmi_elements[@id = $page_all_elements/@id and @id != $page/@id]"/>
   557       <xsl:text>
   557       <xsl:text>
   558 </xsl:text>
   558 </xsl:text>
   559     </xsl:for-each>
   559     </xsl:for-each>
   560     <xsl:text>    }
   560     <xsl:text>    }
   561 </xsl:text>
   561 </xsl:text>
   562     <xsl:apply-templates select="$parsed_widgets/widget[@id = $all_page_widgets/@id]" mode="per_page_widget_template">
   562     <xsl:apply-templates mode="per_page_widget_template" select="$parsed_widgets/widget[@id = $all_page_widgets/@id]">
   563       <xsl:with-param name="page_desc" select="$desc"/>
   563       <xsl:with-param name="page_desc" select="$desc"/>
   564     </xsl:apply-templates>
   564     </xsl:apply-templates>
   565     <xsl:text>  }</xsl:text>
   565     <xsl:text>  }</xsl:text>
   566     <xsl:if test="position()!=last()">
   566     <xsl:if test="position()!=last()">
   567       <xsl:text>,</xsl:text>
   567       <xsl:text>,</xsl:text>
   581 </xsl:text>
   581 </xsl:text>
   582     <xsl:text>
   582     <xsl:text>
   583 </xsl:text>
   583 </xsl:text>
   584     <xsl:text>var page_desc = {
   584     <xsl:text>var page_desc = {
   585 </xsl:text>
   585 </xsl:text>
   586     <xsl:apply-templates select="$hmi_pages" mode="page_desc"/>
   586     <xsl:apply-templates mode="page_desc" select="$hmi_pages"/>
   587     <xsl:text>}
   587     <xsl:text>}
   588 </xsl:text>
   588 </xsl:text>
   589     <xsl:text>
   589     <xsl:text>
   590 </xsl:text>
   590 </xsl:text>
   591   </xsl:template>
   591   </xsl:template>
   592   <xsl:template match="*" mode="per_page_widget_template"/>
   592   <xsl:template mode="per_page_widget_template" match="*"/>
   593   <debug:detachable-pages/>
   593   <debug:detachable-pages/>
   594   <xsl:template match="debug:detachable-pages">
   594   <xsl:template match="debug:detachable-pages">
   595     <xsl:text>
   595     <xsl:text>
   596 </xsl:text>
   596 </xsl:text>
   597     <xsl:text>/* </xsl:text>
   597     <xsl:text>/* </xsl:text>
   619 </xsl:text>
   619 </xsl:text>
   620     </xsl:for-each>
   620     </xsl:for-each>
   621     <xsl:text>
   621     <xsl:text>
   622 </xsl:text>
   622 </xsl:text>
   623   </xsl:template>
   623   </xsl:template>
   624   <xsl:template match="@* | node()" mode="inline_svg">
   624   <xsl:template mode="inline_svg" match="@* | node()">
   625     <xsl:if test="not(@id = $discardable_elements/@id)">
   625     <xsl:if test="not(@id = $discardable_elements/@id)">
   626       <xsl:copy>
   626       <xsl:copy>
   627         <xsl:apply-templates select="@* | node()" mode="inline_svg"/>
   627         <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
   628       </xsl:copy>
   628       </xsl:copy>
   629     </xsl:if>
   629     </xsl:if>
   630   </xsl:template>
   630   </xsl:template>
   631   <xsl:template match="svg:svg/@width" mode="inline_svg"/>
   631   <xsl:template mode="inline_svg" match="svg:svg/@width"/>
   632   <xsl:template match="svg:svg/@height" mode="inline_svg"/>
   632   <xsl:template mode="inline_svg" match="svg:svg/@height"/>
   633   <xsl:template xmlns="http://www.w3.org/2000/svg" match="svg:svg" mode="inline_svg">
   633   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:svg">
   634     <svg>
   634     <svg>
   635       <xsl:attribute name="preserveAspectRatio">
   635       <xsl:attribute name="preserveAspectRatio">
   636         <xsl:text>none</xsl:text>
   636         <xsl:text>none</xsl:text>
   637       </xsl:attribute>
   637       </xsl:attribute>
   638       <xsl:attribute name="height">
   638       <xsl:attribute name="height">
   639         <xsl:text>100vh</xsl:text>
   639         <xsl:text>100vh</xsl:text>
   640       </xsl:attribute>
   640       </xsl:attribute>
   641       <xsl:attribute name="width">
   641       <xsl:attribute name="width">
   642         <xsl:text>100vw</xsl:text>
   642         <xsl:text>100vw</xsl:text>
   643       </xsl:attribute>
   643       </xsl:attribute>
   644       <xsl:apply-templates select="@* | node()" mode="inline_svg"/>
   644       <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
   645     </svg>
   645     </svg>
   646   </xsl:template>
   646   </xsl:template>
   647   <xsl:template match="svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]" mode="inline_svg">
   647   <xsl:template mode="inline_svg" match="svg:svg[@viewBox!=concat('0 0 ', @width, ' ', @height)]">
   648     <xsl:message terminate="yes">
   648     <xsl:message terminate="yes">
   649       <xsl:text>ViewBox settings other than X=0, Y=0 and Scale=1 are not supported</xsl:text>
   649       <xsl:text>ViewBox settings other than X=0, Y=0 and Scale=1 are not supported</xsl:text>
   650     </xsl:message>
   650     </xsl:message>
   651   </xsl:template>
   651   </xsl:template>
   652   <xsl:template match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']" mode="inline_svg">
   652   <xsl:template mode="inline_svg" match="sodipodi:namedview[@units!='px' or @inkscape:document-units!='px']">
   653     <xsl:message terminate="yes">
   653     <xsl:message terminate="yes">
   654       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   654       <xsl:text>All units must be set to "px" in Inkscape's document properties</xsl:text>
   655     </xsl:message>
   655     </xsl:message>
   656   </xsl:template>
   656   </xsl:template>
   657   <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
   657   <xsl:variable name="hmi_lists_descs" select="$parsed_widgets/widget[@type = 'List']"/>
   658   <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
   658   <xsl:variable name="hmi_lists" select="$hmi_elements[@id = $hmi_lists_descs/@id]"/>
   659   <xsl:variable name="targets_not_to_unlink" select="$hmi_elements[@id = $hmi_lists/@id]/descendant::svg:*"/>
   659   <xsl:variable name="targets_not_to_unlink" select="$hmi_elements[@id = $hmi_lists/@id]/descendant::svg:*"/>
   660   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
   660   <xsl:variable name="to_unlink" select="$hmi_elements[not(@id = $hmi_pages/@id)]/descendant-or-self::svg:use"/>
   661   <xsl:template xmlns="http://www.w3.org/2000/svg" match="svg:use" mode="inline_svg">
   661   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="inline_svg" match="svg:use">
   662     <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
   662     <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
   663     <xsl:choose>
   663     <xsl:choose>
   664       <xsl:when test="@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)">
   664       <xsl:when test="@id = $to_unlink/@id and not($targetid = $targets_not_to_unlink/@id)">
   665         <xsl:call-template name="unlink_clone">
   665         <xsl:call-template name="unlink_clone">
   666           <xsl:with-param name="targetid" select="$targetid"/>
   666           <xsl:with-param name="targetid" select="$targetid"/>
   667         </xsl:call-template>
   667         </xsl:call-template>
   668       </xsl:when>
   668       </xsl:when>
   669       <xsl:otherwise>
   669       <xsl:otherwise>
   670         <xsl:copy>
   670         <xsl:copy>
   671           <xsl:apply-templates select="@* | node()" mode="inline_svg"/>
   671           <xsl:apply-templates mode="inline_svg" select="@* | node()"/>
   672         </xsl:copy>
   672         </xsl:copy>
   673       </xsl:otherwise>
   673       </xsl:otherwise>
   674     </xsl:choose>
   674     </xsl:choose>
   675   </xsl:template>
   675   </xsl:template>
   676   <xsl:variable name="_excluded_use_attrs">
   676   <xsl:variable name="_excluded_use_attrs">
   727                 <xsl:text> </xsl:text>
   727                 <xsl:text> </xsl:text>
   728               </xsl:if>
   728               </xsl:if>
   729               <xsl:value-of select="$target/@transform"/>
   729               <xsl:value-of select="$target/@transform"/>
   730             </xsl:attribute>
   730             </xsl:attribute>
   731           </xsl:if>
   731           </xsl:if>
   732           <xsl:apply-templates select="$target/*" mode="unlink_clone">
   732           <xsl:apply-templates mode="unlink_clone" select="$target/*">
   733             <xsl:with-param name="seed" select="@id"/>
   733             <xsl:with-param name="seed" select="@id"/>
   734           </xsl:apply-templates>
   734           </xsl:apply-templates>
   735         </xsl:when>
   735         </xsl:when>
   736         <xsl:otherwise>
   736         <xsl:otherwise>
   737           <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name)]">
   737           <xsl:for-each select="@*[not(local-name() = $excluded_use_attrs/name)]">
   738             <xsl:attribute name="{name()}">
   738             <xsl:attribute name="{name()}">
   739               <xsl:value-of select="."/>
   739               <xsl:value-of select="."/>
   740             </xsl:attribute>
   740             </xsl:attribute>
   741           </xsl:for-each>
   741           </xsl:for-each>
   742           <xsl:apply-templates select="$target" mode="unlink_clone">
   742           <xsl:apply-templates mode="unlink_clone" select="$target">
   743             <xsl:with-param name="seed" select="@id"/>
   743             <xsl:with-param name="seed" select="@id"/>
   744           </xsl:apply-templates>
   744           </xsl:apply-templates>
   745         </xsl:otherwise>
   745         </xsl:otherwise>
   746       </xsl:choose>
   746       </xsl:choose>
   747     </g>
   747     </g>
   748   </xsl:template>
   748   </xsl:template>
   749   <xsl:template xmlns="http://www.w3.org/2000/svg" match="@id" mode="unlink_clone">
   749   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="unlink_clone" match="@id">
   750     <xsl:param name="seed"/>
   750     <xsl:param name="seed"/>
   751     <xsl:attribute name="id">
   751     <xsl:attribute name="id">
   752       <xsl:value-of select="$seed"/>
   752       <xsl:value-of select="$seed"/>
   753       <xsl:text>_</xsl:text>
   753       <xsl:text>_</xsl:text>
   754       <xsl:value-of select="."/>
   754       <xsl:value-of select="."/>
   755     </xsl:attribute>
   755     </xsl:attribute>
   756   </xsl:template>
   756   </xsl:template>
   757   <xsl:template xmlns="http://www.w3.org/2000/svg" match="@*" mode="unlink_clone">
   757   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="unlink_clone" match="@*">
   758     <xsl:copy/>
   758     <xsl:copy/>
   759   </xsl:template>
   759   </xsl:template>
   760   <xsl:template xmlns="http://www.w3.org/2000/svg" match="svg:*" mode="unlink_clone">
   760   <xsl:template xmlns="http://www.w3.org/2000/svg" mode="unlink_clone" match="svg:*">
   761     <xsl:param name="seed"/>
   761     <xsl:param name="seed"/>
   762     <xsl:choose>
   762     <xsl:choose>
   763       <xsl:when test="@id = $hmi_elements/@id">
   763       <xsl:when test="@id = $hmi_elements/@id">
   764         <use>
   764         <use>
   765           <xsl:attribute name="xlink:href">
   765           <xsl:attribute name="xlink:href">
   767           </xsl:attribute>
   767           </xsl:attribute>
   768         </use>
   768         </use>
   769       </xsl:when>
   769       </xsl:when>
   770       <xsl:otherwise>
   770       <xsl:otherwise>
   771         <xsl:copy>
   771         <xsl:copy>
   772           <xsl:apply-templates select="@* | node()" mode="unlink_clone">
   772           <xsl:apply-templates mode="unlink_clone" select="@* | node()">
   773             <xsl:with-param name="seed" select="$seed"/>
   773             <xsl:with-param name="seed" select="$seed"/>
   774           </xsl:apply-templates>
   774           </xsl:apply-templates>
   775         </xsl:copy>
   775         </xsl:copy>
   776       </xsl:otherwise>
   776       </xsl:otherwise>
   777     </xsl:choose>
   777     </xsl:choose>
   778   </xsl:template>
   778   </xsl:template>
   779   <xsl:variable name="result_svg">
   779   <xsl:variable name="result_svg">
   780     <xsl:apply-templates select="/" mode="inline_svg"/>
   780     <xsl:apply-templates mode="inline_svg" select="/"/>
   781   </xsl:variable>
   781   </xsl:variable>
   782   <xsl:variable name="result_svg_ns" select="exsl:node-set($result_svg)"/>
   782   <xsl:variable name="result_svg_ns" select="exsl:node-set($result_svg)"/>
   783   <preamble:inline-svg/>
   783   <preamble:inline-svg/>
   784   <xsl:template match="preamble:inline-svg">
   784   <xsl:template match="preamble:inline-svg">
   785     <xsl:text>
   785     <xsl:text>
   826 </xsl:text>
   826 </xsl:text>
   827     </xsl:for-each>
   827     </xsl:for-each>
   828     <xsl:text>
   828     <xsl:text>
   829 </xsl:text>
   829 </xsl:text>
   830   </xsl:template>
   830   </xsl:template>
   831   <xsl:template match="svg:*" mode="hmi_widgets">
   831   <xsl:template mode="hmi_widgets" match="svg:*">
   832     <xsl:variable name="widget" select="func:widget(@id)"/>
   832     <xsl:variable name="widget" select="func:widget(@id)"/>
   833     <xsl:variable name="eltid" select="@id"/>
   833     <xsl:variable name="eltid" select="@id"/>
   834     <xsl:variable name="args">
   834     <xsl:variable name="args">
   835       <xsl:for-each select="$widget/arg">
   835       <xsl:for-each select="$widget/arg">
   836         <xsl:text>"</xsl:text>
   836         <xsl:text>"</xsl:text>
   874     <xsl:value-of select="$args"/>
   874     <xsl:value-of select="$args"/>
   875     <xsl:text>],[</xsl:text>
   875     <xsl:text>],[</xsl:text>
   876     <xsl:value-of select="$indexes"/>
   876     <xsl:value-of select="$indexes"/>
   877     <xsl:text>],{
   877     <xsl:text>],{
   878 </xsl:text>
   878 </xsl:text>
   879     <xsl:apply-templates select="$widget" mode="widget_defs">
   879     <xsl:apply-templates mode="widget_defs" select="$widget">
   880       <xsl:with-param name="hmi_element" select="."/>
   880       <xsl:with-param name="hmi_element" select="."/>
   881     </xsl:apply-templates>
   881     </xsl:apply-templates>
   882     <xsl:text>  })</xsl:text>
   882     <xsl:text>  })</xsl:text>
   883     <xsl:if test="position()!=last()">
   883     <xsl:if test="position()!=last()">
   884       <xsl:text>,</xsl:text>
   884       <xsl:text>,</xsl:text>
   913     <xsl:value-of select="local-name()"/>
   913     <xsl:value-of select="local-name()"/>
   914     <xsl:text> */
   914     <xsl:text> */
   915 </xsl:text>
   915 </xsl:text>
   916     <xsl:text>
   916     <xsl:text>
   917 </xsl:text>
   917 </xsl:text>
       
   918     <xsl:text>var pending_widget_animates = [];
       
   919 </xsl:text>
       
   920     <xsl:text>
       
   921 </xsl:text>
   918     <xsl:text>class Widget {
   922     <xsl:text>class Widget {
   919 </xsl:text>
   923 </xsl:text>
   920     <xsl:text>    offset = 0;
   924     <xsl:text>    offset = 0;
   921 </xsl:text>
   925 </xsl:text>
   922     <xsl:text>    frequency = 10; /* FIXME arbitrary default max freq. Obtain from config ? */
   926     <xsl:text>    frequency = 10; /* FIXME arbitrary default max freq. Obtain from config ? */
   923 </xsl:text>
   927 </xsl:text>
   924     <xsl:text>    unsubscribable = false;
   928     <xsl:text>    unsubscribable = false;
   925 </xsl:text>
   929 </xsl:text>
       
   930     <xsl:text>    pending_animate = false;
       
   931 </xsl:text>
       
   932     <xsl:text>
       
   933 </xsl:text>
   926     <xsl:text>    constructor(elt_id,args,indexes,members){
   934     <xsl:text>    constructor(elt_id,args,indexes,members){
   927 </xsl:text>
   935 </xsl:text>
   928     <xsl:text>        this.element_id = elt_id;
   936     <xsl:text>        this.element_id = elt_id;
   929 </xsl:text>
   937 </xsl:text>
   930     <xsl:text>        this.element = id(elt_id);
   938     <xsl:text>        this.element = id(elt_id);
  1086     <xsl:text>        } catch(err) {
  1094     <xsl:text>        } catch(err) {
  1087 </xsl:text>
  1095 </xsl:text>
  1088     <xsl:text>            console.log(err);
  1096     <xsl:text>            console.log(err);
  1089 </xsl:text>
  1097 </xsl:text>
  1090     <xsl:text>        }
  1098     <xsl:text>        }
       
  1099 </xsl:text>
       
  1100     <xsl:text>    }
       
  1101 </xsl:text>
       
  1102     <xsl:text>    
       
  1103 </xsl:text>
       
  1104     <xsl:text>    _animate(){
       
  1105 </xsl:text>
       
  1106     <xsl:text>        this.animate();
       
  1107 </xsl:text>
       
  1108     <xsl:text>        this.pending_animate = false;
       
  1109 </xsl:text>
       
  1110     <xsl:text>    }
       
  1111 </xsl:text>
       
  1112     <xsl:text>
       
  1113 </xsl:text>
       
  1114     <xsl:text>    request_animate(){
       
  1115 </xsl:text>
       
  1116     <xsl:text>        if(!this.pending_animate){
       
  1117 </xsl:text>
       
  1118     <xsl:text>            pending_widget_animates.push(this);
       
  1119 </xsl:text>
       
  1120     <xsl:text>            this.pending_animate = true;
       
  1121 </xsl:text>
       
  1122     <xsl:text>            requestHMIAnimation();
       
  1123 </xsl:text>
       
  1124     <xsl:text>        }
       
  1125 </xsl:text>
       
  1126     <xsl:text>
  1091 </xsl:text>
  1127 </xsl:text>
  1092     <xsl:text>    }
  1128     <xsl:text>    }
  1093 </xsl:text>
  1129 </xsl:text>
  1094     <xsl:text>}
  1130     <xsl:text>}
  1095 </xsl:text>
  1131 </xsl:text>
  1105     <xsl:text> */
  1141     <xsl:text> */
  1106 </xsl:text>
  1142 </xsl:text>
  1107     <xsl:text>
  1143     <xsl:text>
  1108 </xsl:text>
  1144 </xsl:text>
  1109     <xsl:variable name="used_widget_types" select="func:unique_types($parsed_widgets/widget)"/>
  1145     <xsl:variable name="used_widget_types" select="func:unique_types($parsed_widgets/widget)"/>
  1110     <xsl:apply-templates select="$used_widget_types" mode="widget_class"/>
  1146     <xsl:apply-templates mode="widget_class" select="$used_widget_types"/>
  1111     <xsl:text>
  1147     <xsl:text>
  1112 </xsl:text>
  1148 </xsl:text>
  1113   </xsl:template>
  1149   </xsl:template>
  1114   <xsl:template match="widget" mode="widget_class">
  1150   <xsl:template mode="widget_class" match="widget">
  1115     <xsl:text>class </xsl:text>
  1151     <xsl:text>class </xsl:text>
  1116     <xsl:value-of select="@type"/>
  1152     <xsl:value-of select="@type"/>
  1117     <xsl:text>Widget extends Widget{
  1153     <xsl:text>Widget extends Widget{
  1118 </xsl:text>
  1154 </xsl:text>
  1119     <xsl:text>    /* empty class, as </xsl:text>
  1155     <xsl:text>    /* empty class, as </xsl:text>
  1135 </xsl:text>
  1171 </xsl:text>
  1136     <xsl:text>
  1172     <xsl:text>
  1137 </xsl:text>
  1173 </xsl:text>
  1138     <xsl:text>var hmi_widgets = {
  1174     <xsl:text>var hmi_widgets = {
  1139 </xsl:text>
  1175 </xsl:text>
  1140     <xsl:apply-templates select="$hmi_elements[@id = $excluded_ids]" mode="hmi_widgets"/>
  1176     <xsl:apply-templates mode="hmi_widgets" select="$hmi_elements[@id = $excluded_ids]"/>
  1141     <xsl:text>}
  1177     <xsl:text>}
  1142 </xsl:text>
  1178 </xsl:text>
  1143     <xsl:text>
  1179     <xsl:text>
  1144 </xsl:text>
  1180 </xsl:text>
  1145   </xsl:template>
  1181   </xsl:template>
  1229       <xsl:otherwise>
  1265       <xsl:otherwise>
  1230         <func:result select="$txt"/>
  1266         <func:result select="$txt"/>
  1231       </xsl:otherwise>
  1267       </xsl:otherwise>
  1232     </xsl:choose>
  1268     </xsl:choose>
  1233   </func:function>
  1269   </func:function>
  1234   <xsl:template match="widget[@type='Back']" mode="widget_class">
  1270   <xsl:template mode="widget_class" match="widget[@type='Back']">
  1235     <xsl:text>class BackWidget extends Widget{
  1271     <xsl:text>class BackWidget extends Widget{
  1236 </xsl:text>
  1272 </xsl:text>
  1237     <xsl:text>    on_click(evt) {
  1273     <xsl:text>    on_click(evt) {
  1238 </xsl:text>
  1274 </xsl:text>
  1239     <xsl:text>        if(jump_history.length &gt; 1){
  1275     <xsl:text>        if(jump_history.length &gt; 1){
  1255     <xsl:text>    }
  1291     <xsl:text>    }
  1256 </xsl:text>
  1292 </xsl:text>
  1257     <xsl:text>}
  1293     <xsl:text>}
  1258 </xsl:text>
  1294 </xsl:text>
  1259   </xsl:template>
  1295   </xsl:template>
  1260   <xsl:template match="widget[@type='Button']" mode="widget_class">
  1296   <xsl:template mode="widget_class" match="widget[@type='Button']">
  1261     <xsl:text>t{
  1297     <xsl:text>t{
  1262 </xsl:text>
  1298 </xsl:text>
  1263     <xsl:text>5;
  1299     <xsl:text>5;
  1264 </xsl:text>
  1300 </xsl:text>
  1265     <xsl:text>0;
  1301     <xsl:text>0;
  1329     <xsl:text> }
  1365     <xsl:text> }
  1330 </xsl:text>
  1366 </xsl:text>
  1331     <xsl:text>||
  1367     <xsl:text>||
  1332 </xsl:text>
  1368 </xsl:text>
  1333   </xsl:template>
  1369   </xsl:template>
  1334   <xsl:template match="widget[@type='Button']" mode="widget_defs">
  1370   <xsl:template mode="widget_defs" match="widget[@type='Button']">
  1335     <xsl:param name="hmi_element"/>
  1371     <xsl:param name="hmi_element"/>
  1336     <xsl:call-template name="defs_by_labels">
  1372     <xsl:call-template name="defs_by_labels">
  1337       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1373       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1338       <xsl:with-param name="labels">
  1374       <xsl:with-param name="labels">
  1339         <xsl:text>active inactive</xsl:text>
  1375         <xsl:text>active inactive</xsl:text>
  1341       <xsl:with-param name="mandatory" select="'no'"/>
  1377       <xsl:with-param name="mandatory" select="'no'"/>
  1342     </xsl:call-template>
  1378     </xsl:call-template>
  1343     <xsl:text>
  1379     <xsl:text>
  1344 </xsl:text>
  1380 </xsl:text>
  1345   </xsl:template>
  1381   </xsl:template>
  1346   <xsl:template match="widget[@type='CircularBar']" mode="widget_defs">
  1382   <xsl:template mode="widget_defs" match="widget[@type='CircularBar']">
  1347     <xsl:param name="hmi_element"/>
  1383     <xsl:param name="hmi_element"/>
  1348     <xsl:text>frequency: 10,
  1384     <xsl:text>frequency: 10,
  1349 </xsl:text>
  1385 </xsl:text>
  1350     <xsl:call-template name="defs_by_labels">
  1386     <xsl:call-template name="defs_by_labels">
  1351       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1387       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1437     <xsl:text>    this.proportions = [rx, ry];
  1473     <xsl:text>    this.proportions = [rx, ry];
  1438 </xsl:text>
  1474 </xsl:text>
  1439     <xsl:text>},
  1475     <xsl:text>},
  1440 </xsl:text>
  1476 </xsl:text>
  1441   </xsl:template>
  1477   </xsl:template>
  1442   <xsl:template match="widget[@type='CircularSlider']" mode="widget_class">
  1478   <xsl:template mode="widget_class" match="widget[@type='CircularSlider']">
  1443     <xsl:text>class CircularSliderWidget extends Widget{
  1479     <xsl:text>class CircularSliderWidget extends Widget{
  1444 </xsl:text>
  1480 </xsl:text>
  1445     <xsl:text>    frequency = 5;
  1481     <xsl:text>    frequency = 5;
  1446 </xsl:text>
  1482 </xsl:text>
  1447     <xsl:text>    range = undefined;
  1483     <xsl:text>    range = undefined;
  1612 </xsl:text>
  1648 </xsl:text>
  1613     <xsl:text>            if(this.value_elt)
  1649     <xsl:text>            if(this.value_elt)
  1614 </xsl:text>
  1650 </xsl:text>
  1615     <xsl:text>                this.value_elt.textContent = String(Math.ceil(svg_dist));
  1651     <xsl:text>                this.value_elt.textContent = String(Math.ceil(svg_dist));
  1616 </xsl:text>
  1652 </xsl:text>
  1617     <xsl:text>            change_hmi_value(this.indexes[0], "="+Math.ceil(svg_dist));
  1653     <xsl:text>            this.apply_hmi_value(0, Math.ceil(svg_dist));
  1618 </xsl:text>
  1654 </xsl:text>
  1619     <xsl:text>
  1655     <xsl:text>
  1620 </xsl:text>
  1656 </xsl:text>
  1621     <xsl:text>            //reset timer
  1657     <xsl:text>            //reset timer
  1622 </xsl:text>
  1658 </xsl:text>
  1733     <xsl:text>    }
  1769     <xsl:text>    }
  1734 </xsl:text>
  1770 </xsl:text>
  1735     <xsl:text>}
  1771     <xsl:text>}
  1736 </xsl:text>
  1772 </xsl:text>
  1737   </xsl:template>
  1773   </xsl:template>
  1738   <xsl:template match="widget[@type='CircularSlider']" mode="widget_defs">
  1774   <xsl:template mode="widget_defs" match="widget[@type='CircularSlider']">
  1739     <xsl:param name="hmi_element"/>
  1775     <xsl:param name="hmi_element"/>
  1740     <xsl:call-template name="defs_by_labels">
  1776     <xsl:call-template name="defs_by_labels">
  1741       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1777       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1742       <xsl:with-param name="labels">
  1778       <xsl:with-param name="labels">
  1743         <xsl:text>handle range</xsl:text>
  1779         <xsl:text>handle range</xsl:text>
  1751       <xsl:with-param name="mandatory" select="'no'"/>
  1787       <xsl:with-param name="mandatory" select="'no'"/>
  1752     </xsl:call-template>
  1788     </xsl:call-template>
  1753     <xsl:text>
  1789     <xsl:text>
  1754 </xsl:text>
  1790 </xsl:text>
  1755   </xsl:template>
  1791   </xsl:template>
  1756   <xsl:template match="widget[@type='Display']" mode="widget_class">
  1792   <xsl:template mode="widget_class" match="widget[@type='Display']">
  1757     <xsl:text>class DisplayWidget extends Widget{
  1793     <xsl:text>class DisplayWidget extends Widget{
  1758 </xsl:text>
  1794 </xsl:text>
  1759     <xsl:text>    frequency = 5;
  1795     <xsl:text>    frequency = 5;
  1760 </xsl:text>
  1796 </xsl:text>
  1761     <xsl:text>    dispatch(value, oldval, index) {
  1797     <xsl:text>    dispatch(value, oldval, index) {
  1769     <xsl:text>    }
  1805     <xsl:text>    }
  1770 </xsl:text>
  1806 </xsl:text>
  1771     <xsl:text>}
  1807     <xsl:text>}
  1772 </xsl:text>
  1808 </xsl:text>
  1773   </xsl:template>
  1809   </xsl:template>
  1774   <xsl:template match="widget[@type='Display']" mode="widget_defs">
  1810   <xsl:template mode="widget_defs" match="widget[@type='Display']">
  1775     <xsl:param name="hmi_element"/>
  1811     <xsl:param name="hmi_element"/>
  1776     <xsl:if test="$hmi_element[not(self::svg:text)]">
  1812     <xsl:if test="$hmi_element[not(self::svg:text)]">
  1777       <xsl:message terminate="yes">
  1813       <xsl:message terminate="yes">
  1778         <xsl:text>Display Widget id="</xsl:text>
  1814         <xsl:text>Display Widget id="</xsl:text>
  1779         <xsl:value-of select="$hmi_element/@id"/>
  1815         <xsl:value-of select="$hmi_element/@id"/>
  2260     <xsl:text>}(); // eslint-disable-line    
  2296     <xsl:text>}(); // eslint-disable-line    
  2261 </xsl:text>
  2297 </xsl:text>
  2262     <xsl:text>
  2298     <xsl:text>
  2263 </xsl:text>
  2299 </xsl:text>
  2264   </xsl:template>
  2300   </xsl:template>
  2265   <xsl:template match="widget[@type='DropDown']" mode="widget_defs">
  2301   <xsl:template mode="widget_defs" match="widget[@type='DropDown']">
  2266     <xsl:param name="hmi_element"/>
  2302     <xsl:param name="hmi_element"/>
  2267     <xsl:call-template name="defs_by_labels">
  2303     <xsl:call-template name="defs_by_labels">
  2268       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  2304       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  2269       <xsl:with-param name="labels">
  2305       <xsl:with-param name="labels">
  2270         <xsl:text>text box button</xsl:text>
  2306         <xsl:text>text box button</xsl:text>
  2773     <xsl:text>        b.height.baseVal.value = 2 * tmargin + m.height;
  2809     <xsl:text>        b.height.baseVal.value = 2 * tmargin + m.height;
  2774 </xsl:text>
  2810 </xsl:text>
  2775     <xsl:text>    },
  2811     <xsl:text>    },
  2776 </xsl:text>
  2812 </xsl:text>
  2777   </xsl:template>
  2813   </xsl:template>
  2778   <xsl:template match="widget[@type='ForEach']" mode="widget_defs">
  2814   <xsl:template mode="widget_defs" match="widget[@type='ForEach']">
  2779     <xsl:param name="hmi_element"/>
  2815     <xsl:param name="hmi_element"/>
  2780     <xsl:if test="count(path) != 1">
  2816     <xsl:if test="count(path) != 1">
  2781       <xsl:message terminate="yes">
  2817       <xsl:message terminate="yes">
  2782         <xsl:text>ForEach widget </xsl:text>
  2818         <xsl:text>ForEach widget </xsl:text>
  2783         <xsl:value-of select="$hmi_element/@id"/>
  2819         <xsl:value-of select="$hmi_element/@id"/>
  2887     <xsl:text>    },
  2923     <xsl:text>    },
  2888 </xsl:text>
  2924 </xsl:text>
  2889     <xsl:text>    item_offset: 0,
  2925     <xsl:text>    item_offset: 0,
  2890 </xsl:text>
  2926 </xsl:text>
  2891   </xsl:template>
  2927   </xsl:template>
  2892   <xsl:template match="widget[@type='ForEach']" mode="widget_class">
  2928   <xsl:template mode="widget_class" match="widget[@type='ForEach']">
  2893     <xsl:text>class ForEachWidget extends Widget{
  2929     <xsl:text>class ForEachWidget extends Widget{
  2894 </xsl:text>
  2930 </xsl:text>
  2895     <xsl:text>
  2931     <xsl:text>
  2896 </xsl:text>
  2932 </xsl:text>
  2897     <xsl:text>    unsub_items(){
  2933     <xsl:text>    unsub_items(){
  3023     <xsl:text>    }
  3059     <xsl:text>    }
  3024 </xsl:text>
  3060 </xsl:text>
  3025     <xsl:text>}
  3061     <xsl:text>}
  3026 </xsl:text>
  3062 </xsl:text>
  3027   </xsl:template>
  3063   </xsl:template>
  3028   <xsl:template match="widget[@type='Input']" mode="widget_defs">
  3064   <xsl:template mode="widget_defs" match="widget[@type='Input']">
  3029     <xsl:param name="hmi_element"/>
  3065     <xsl:param name="hmi_element"/>
  3030     <xsl:call-template name="defs_by_labels">
  3066     <xsl:call-template name="defs_by_labels">
  3031       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3067       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3032       <xsl:with-param name="labels">
  3068       <xsl:with-param name="labels">
  3033         <xsl:text>key_pos</xsl:text>
  3069         <xsl:text>key_pos</xsl:text>
  3107     <xsl:text>        this.apply_hmi_value(0, new_val);
  3143     <xsl:text>        this.apply_hmi_value(0, new_val);
  3108 </xsl:text>
  3144 </xsl:text>
  3109     <xsl:text>    },
  3145     <xsl:text>    },
  3110 </xsl:text>
  3146 </xsl:text>
  3111   </xsl:template>
  3147   </xsl:template>
  3112   <xsl:template match="widget[@type='JsonTable']" mode="widget_class">
  3148   <xsl:template mode="widget_class" match="widget[@type='JsonTable']">
  3113     <xsl:text>class JsonTableWidget extends Widget{
  3149     <xsl:text>class JsonTableWidget extends Widget{
  3114 </xsl:text>
  3150 </xsl:text>
  3115     <xsl:text>    do_http_request() {
  3151     <xsl:text>    do_http_request() {
  3116 </xsl:text>
  3152 </xsl:text>
  3117     <xsl:text>        const query = {
  3153     <xsl:text>        const query = {
  3167     <xsl:text>    }
  3203     <xsl:text>    }
  3168 </xsl:text>
  3204 </xsl:text>
  3169     <xsl:text>}
  3205     <xsl:text>}
  3170 </xsl:text>
  3206 </xsl:text>
  3171   </xsl:template>
  3207   </xsl:template>
  3172   <xsl:template match="svg:*" mode="json_table_elt_render">
  3208   <xsl:template mode="json_table_elt_render" match="svg:*">
  3173     <xsl:message terminate="yes">
  3209     <xsl:message terminate="yes">
  3174       <xsl:text>JsonTable Widget can't contain element of type </xsl:text>
  3210       <xsl:text>JsonTable Widget can't contain element of type </xsl:text>
  3175       <xsl:value-of select="local-name()"/>
  3211       <xsl:value-of select="local-name()"/>
  3176       <xsl:text>.</xsl:text>
  3212       <xsl:text>.</xsl:text>
  3177     </xsl:message>
  3213     </xsl:message>
  3178   </xsl:template>
  3214   </xsl:template>
  3179   <xsl:template match="svg:use" mode="json_table_elt_render">
  3215   <xsl:template mode="json_table_elt_render" match="svg:use">
  3180     <xsl:param name="value_expr"/>
  3216     <xsl:param name="value_expr"/>
  3181     <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
  3217     <xsl:variable name="targetid" select="substring-after(@xlink:href,'#')"/>
  3182     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  3218     <xsl:variable name="from_list" select="$hmi_lists[(@id | */@id) = $targetid]"/>
  3183     <xsl:if test="count($from_list) = 0">
  3219     <xsl:if test="count($from_list) = 0">
  3184       <xsl:message terminate="yes">
  3220       <xsl:message terminate="yes">
  3196     <xsl:text>"].items[</xsl:text>
  3232     <xsl:text>"].items[</xsl:text>
  3197     <xsl:value-of select="$value_expr"/>
  3233     <xsl:value-of select="$value_expr"/>
  3198     <xsl:text>]);
  3234     <xsl:text>]);
  3199 </xsl:text>
  3235 </xsl:text>
  3200   </xsl:template>
  3236   </xsl:template>
  3201   <xsl:template match="svg:text" mode="json_table_elt_render">
  3237   <xsl:template mode="json_table_elt_render" match="svg:text">
  3202     <xsl:param name="value_expr"/>
  3238     <xsl:param name="value_expr"/>
  3203     <xsl:text>        id("</xsl:text>
  3239     <xsl:text>        id("</xsl:text>
  3204     <xsl:value-of select="@id"/>
  3240     <xsl:value-of select="@id"/>
  3205     <xsl:text>").textContent = String(</xsl:text>
  3241     <xsl:text>").textContent = String(</xsl:text>
  3206     <xsl:value-of select="$value_expr"/>
  3242     <xsl:value-of select="$value_expr"/>
  3207     <xsl:text>);
  3243     <xsl:text>);
  3208 </xsl:text>
  3244 </xsl:text>
  3209   </xsl:template>
  3245   </xsl:template>
  3210   <xsl:template match="svg:*" mode="json_table_render">
  3246   <xsl:template mode="json_table_render" match="svg:*">
  3211     <xsl:param name="objname"/>
  3247     <xsl:param name="objname"/>
  3212     <xsl:apply-templates select="." mode="json_table_elt_render">
  3248     <xsl:apply-templates mode="json_table_elt_render" select=".">
  3213       <xsl:with-param name="value_expr">
  3249       <xsl:with-param name="value_expr">
  3214         <xsl:value-of select="$objname"/>
  3250         <xsl:value-of select="$objname"/>
  3215         <xsl:value-of select="@inkscape:label"/>
  3251         <xsl:value-of select="@inkscape:label"/>
  3216       </xsl:with-param>
  3252       </xsl:with-param>
  3217     </xsl:apply-templates>
  3253     </xsl:apply-templates>
  3218   </xsl:template>
  3254   </xsl:template>
  3219   <xsl:template match="svg:g" mode="json_table_render">
  3255   <xsl:template mode="json_table_render" match="svg:g">
  3220     <xsl:param name="objname"/>
  3256     <xsl:param name="objname"/>
  3221     <xsl:text>        let obj_</xsl:text>
  3257     <xsl:text>        let obj_</xsl:text>
  3222     <xsl:value-of select="@id"/>
  3258     <xsl:value-of select="@id"/>
  3223     <xsl:text> = </xsl:text>
  3259     <xsl:text> = </xsl:text>
  3224     <xsl:value-of select="$objname"/>
  3260     <xsl:value-of select="$objname"/>
  3225     <xsl:value-of select="@inkscape:label"/>
  3261     <xsl:value-of select="@inkscape:label"/>
  3226     <xsl:text>;
  3262     <xsl:text>;
  3227 </xsl:text>
  3263 </xsl:text>
  3228     <xsl:apply-templates select="*[@inkscape:label]" mode="json_table_render">
  3264     <xsl:apply-templates mode="json_table_render" select="*[@inkscape:label]">
  3229       <xsl:with-param name="objname">
  3265       <xsl:with-param name="objname">
  3230         <xsl:text>obj_</xsl:text>
  3266         <xsl:text>obj_</xsl:text>
  3231         <xsl:value-of select="@id"/>
  3267         <xsl:value-of select="@id"/>
  3232       </xsl:with-param>
  3268       </xsl:with-param>
  3233     </xsl:apply-templates>
  3269     </xsl:apply-templates>
  3234   </xsl:template>
  3270   </xsl:template>
  3235   <xsl:template match="widget[@type='JsonTable']" mode="widget_defs">
  3271   <xsl:template mode="widget_defs" match="widget[@type='JsonTable']">
  3236     <xsl:param name="hmi_element"/>
  3272     <xsl:param name="hmi_element"/>
  3237     <xsl:call-template name="defs_by_labels">
  3273     <xsl:call-template name="defs_by_labels">
  3238       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3274       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3239       <xsl:with-param name="labels">
  3275       <xsl:with-param name="labels">
  3240         <xsl:text>data</xsl:text>
  3276         <xsl:text>data</xsl:text>
  3248       <xsl:with-param name="mandatory" select="'no'"/>
  3284       <xsl:with-param name="mandatory" select="'no'"/>
  3249     </xsl:call-template>
  3285     </xsl:call-template>
  3250     <xsl:variable name="data_elt" select="$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"/>
  3286     <xsl:variable name="data_elt" select="$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"/>
  3251     <xsl:text>    spread_json_data: function(jdata) {
  3287     <xsl:text>    spread_json_data: function(jdata) {
  3252 </xsl:text>
  3288 </xsl:text>
  3253     <xsl:apply-templates select="$data_elt/*" mode="json_table_render">
  3289     <xsl:apply-templates mode="json_table_render" select="$data_elt/*">
  3254       <xsl:with-param name="objname" select="'jdata'"/>
  3290       <xsl:with-param name="objname" select="'jdata'"/>
  3255     </xsl:apply-templates>
  3291     </xsl:apply-templates>
  3256     <xsl:text>    }
  3292     <xsl:text>    }
  3257 </xsl:text>
  3293 </xsl:text>
  3258   </xsl:template>
  3294   </xsl:template>
  3274         <xsl:text>disabled</xsl:text>
  3310         <xsl:text>disabled</xsl:text>
  3275       </xsl:with-param>
  3311       </xsl:with-param>
  3276       <xsl:with-param name="mandatory" select="'no'"/>
  3312       <xsl:with-param name="mandatory" select="'no'"/>
  3277     </xsl:call-template>
  3313     </xsl:call-template>
  3278   </xsl:template>
  3314   </xsl:template>
  3279   <xsl:template match="widget[@type='Jump']" mode="widget_defs">
  3315   <xsl:template mode="widget_defs" match="widget[@type='Jump']">
  3280     <xsl:param name="hmi_element"/>
  3316     <xsl:param name="hmi_element"/>
  3281     <xsl:variable name="activity">
  3317     <xsl:variable name="activity">
  3282       <xsl:call-template name="jump_widget_activity">
  3318       <xsl:call-template name="jump_widget_activity">
  3283         <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3319         <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3284       </xsl:call-template>
  3320       </xsl:call-template>
  3409       </xsl:otherwise>
  3445       </xsl:otherwise>
  3410     </xsl:choose>
  3446     </xsl:choose>
  3411     <xsl:text>    },
  3447     <xsl:text>    },
  3412 </xsl:text>
  3448 </xsl:text>
  3413   </xsl:template>
  3449   </xsl:template>
  3414   <xsl:template match="widget[@type='Jump']" mode="per_page_widget_template">
  3450   <xsl:template mode="per_page_widget_template" match="widget[@type='Jump']">
  3415     <xsl:param name="page_desc"/>
  3451     <xsl:param name="page_desc"/>
  3416     <xsl:if test="path">
  3452     <xsl:if test="path">
  3417       <xsl:variable name="target_page_name">
  3453       <xsl:variable name="target_page_name">
  3418         <xsl:choose>
  3454         <xsl:choose>
  3419           <xsl:when test="arg">
  3455           <xsl:when test="arg">
  3511     <xsl:text>}
  3547     <xsl:text>}
  3512 </xsl:text>
  3548 </xsl:text>
  3513     <xsl:text>
  3549     <xsl:text>
  3514 </xsl:text>
  3550 </xsl:text>
  3515   </xsl:template>
  3551   </xsl:template>
  3516   <xsl:template match="widget[@type='Keypad']" mode="widget_class">
  3552   <xsl:template mode="widget_class" match="widget[@type='Keypad']">
  3517     <xsl:text>class KeypadWidget extends Widget{
  3553     <xsl:text>class KeypadWidget extends Widget{
  3518 </xsl:text>
  3554 </xsl:text>
  3519     <xsl:text>     moving = undefined;
  3555     <xsl:text>     moving = undefined;
  3520 </xsl:text>
  3556 </xsl:text>
  3521     <xsl:text>     enTimer = undefined;
  3557     <xsl:text>     enTimer = undefined;
  3803     <xsl:text>     }
  3839     <xsl:text>     }
  3804 </xsl:text>
  3840 </xsl:text>
  3805     <xsl:text>}
  3841     <xsl:text>}
  3806 </xsl:text>
  3842 </xsl:text>
  3807   </xsl:template>
  3843   </xsl:template>
  3808   <xsl:template match="widget[@type='Keypad']" mode="widget_defs">
  3844   <xsl:template mode="widget_defs" match="widget[@type='Keypad']">
  3809     <xsl:param name="hmi_element"/>
  3845     <xsl:param name="hmi_element"/>
  3810     <xsl:call-template name="defs_by_labels">
  3846     <xsl:call-template name="defs_by_labels">
  3811       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3847       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3812       <xsl:with-param name="labels">
  3848       <xsl:with-param name="labels">
  3813         <xsl:text>Esc Enter BackSpace Keys Info Value</xsl:text>
  3849         <xsl:text>Esc Enter BackSpace Keys Info Value</xsl:text>
  3882     <xsl:text>, </xsl:text>
  3918     <xsl:text>, </xsl:text>
  3883     <xsl:value-of select="$g/@y"/>
  3919     <xsl:value-of select="$g/@y"/>
  3884     <xsl:text>],
  3920     <xsl:text>],
  3885 </xsl:text>
  3921 </xsl:text>
  3886   </xsl:template>
  3922   </xsl:template>
  3887   <xsl:template match="widget[@type='List']" mode="widget_defs">
  3923   <xsl:template mode="widget_defs" match="widget[@type='List']">
  3888     <xsl:param name="hmi_element"/>
  3924     <xsl:param name="hmi_element"/>
  3889     <xsl:text>    items: {
  3925     <xsl:text>    items: {
  3890 </xsl:text>
  3926 </xsl:text>
  3891     <xsl:for-each select="$hmi_element/*[@inkscape:label]">
  3927     <xsl:for-each select="$hmi_element/*[@inkscape:label]">
  3892       <xsl:text>        </xsl:text>
  3928       <xsl:text>        </xsl:text>
  3897 </xsl:text>
  3933 </xsl:text>
  3898     </xsl:for-each>
  3934     </xsl:for-each>
  3899     <xsl:text>    },
  3935     <xsl:text>    },
  3900 </xsl:text>
  3936 </xsl:text>
  3901   </xsl:template>
  3937   </xsl:template>
  3902   <xsl:template match="widget[@type='Meter']" mode="widget_defs">
  3938   <xsl:template mode="widget_defs" match="widget[@type='Meter']">
  3903     <xsl:param name="hmi_element"/>
  3939     <xsl:param name="hmi_element"/>
  3904     <xsl:text>    frequency: 10,
  3940     <xsl:text>    frequency: 10,
  3905 </xsl:text>
  3941 </xsl:text>
  3906     <xsl:call-template name="defs_by_labels">
  3942     <xsl:call-template name="defs_by_labels">
  3907       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3943       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  3955     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  3991     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  3956 </xsl:text>
  3992 </xsl:text>
  3957     <xsl:text>    },
  3993     <xsl:text>    },
  3958 </xsl:text>
  3994 </xsl:text>
  3959   </xsl:template>
  3995   </xsl:template>
  3960   <xsl:template match="widget[@type='MultiState']" mode="widget_class">
  3996   <xsl:template mode="widget_class" match="widget[@type='MultiState']">
  3961     <xsl:text>class MultiStateWidget extends Widget{
  3997     <xsl:text>class MultiStateWidget extends Widget{
  3962 </xsl:text>
  3998 </xsl:text>
  3963     <xsl:text>    frequency = 5;
  3999     <xsl:text>    frequency = 5;
  3964 </xsl:text>
  4000 </xsl:text>
  3965     <xsl:text>    state = 0;
  4001     <xsl:text>    state = 0;
  4022 </xsl:text>
  4058 </xsl:text>
  4023     <xsl:text>
  4059     <xsl:text>
  4024 </xsl:text>
  4060 </xsl:text>
  4025     <xsl:text>        //post value to plc
  4061     <xsl:text>        //post value to plc
  4026 </xsl:text>
  4062 </xsl:text>
  4027     <xsl:text>        change_hmi_value(this.indexes[0], "="+this.state);
  4063     <xsl:text>        this.apply_hmi_value(0, this.state);
  4028 </xsl:text>
  4064 </xsl:text>
  4029     <xsl:text>    }
  4065     <xsl:text>    }
  4030 </xsl:text>
  4066 </xsl:text>
  4031     <xsl:text>
  4067     <xsl:text>
  4032 </xsl:text>
  4068 </xsl:text>
  4037     <xsl:text>    }
  4073     <xsl:text>    }
  4038 </xsl:text>
  4074 </xsl:text>
  4039     <xsl:text>}
  4075     <xsl:text>}
  4040 </xsl:text>
  4076 </xsl:text>
  4041   </xsl:template>
  4077   </xsl:template>
  4042   <xsl:template match="widget[@type='MultiState']" mode="widget_defs">
  4078   <xsl:template mode="widget_defs" match="widget[@type='MultiState']">
  4043     <xsl:param name="hmi_element"/>
  4079     <xsl:param name="hmi_element"/>
  4044     <xsl:text>    choices: [
  4080     <xsl:text>    choices: [
  4045 </xsl:text>
  4081 </xsl:text>
  4046     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  4082     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  4047     <xsl:for-each select="$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]">
  4083     <xsl:for-each select="$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]">
  4068 </xsl:text>
  4104 </xsl:text>
  4069     </xsl:for-each>
  4105     </xsl:for-each>
  4070     <xsl:text>    ],
  4106     <xsl:text>    ],
  4071 </xsl:text>
  4107 </xsl:text>
  4072   </xsl:template>
  4108   </xsl:template>
  4073   <xsl:template match="widget[@type='Slider']" mode="widget_class">
  4109   <xsl:template mode="widget_class" match="widget[@type='Slider']">
  4074     <xsl:text>class SliderWidget extends Widget{
  4110     <xsl:text>class SliderWidget extends Widget{
  4075 </xsl:text>
  4111 </xsl:text>
  4076     <xsl:text>    frequency = 5;
  4112     <xsl:text>    frequency = 5;
  4077 </xsl:text>
  4113 </xsl:text>
  4078     <xsl:text>    range = undefined;
  4114     <xsl:text>    range = undefined;
  4081 </xsl:text>
  4117 </xsl:text>
  4082     <xsl:text>    drag = false;
  4118     <xsl:text>    drag = false;
  4083 </xsl:text>
  4119 </xsl:text>
  4084     <xsl:text>    enTimer = false;
  4120     <xsl:text>    enTimer = false;
  4085 </xsl:text>
  4121 </xsl:text>
       
  4122     <xsl:text>    svg_dist = 0
       
  4123 </xsl:text>
  4086     <xsl:text>
  4124     <xsl:text>
  4087 </xsl:text>
  4125 </xsl:text>
  4088     <xsl:text>    dispatch(value) {
  4126     <xsl:text>    dispatch(value) {
  4089 </xsl:text>
  4127 </xsl:text>
  4090     <xsl:text>        if(!this.drag){
  4128     <xsl:text>        if(this.value_elt)
  4091 </xsl:text>
  4129 </xsl:text>
  4092     <xsl:text>            if(this.value_elt)
  4130     <xsl:text>            this.value_elt.textContent = String(value);
  4093 </xsl:text>
  4131 </xsl:text>
  4094     <xsl:text>                this.value_elt.textContent = String(value);
  4132     <xsl:text>
  4095 </xsl:text>
  4133 </xsl:text>
  4096     <xsl:text>
  4134     <xsl:text>        this.handle_position(value);
  4097 </xsl:text>
  4135 </xsl:text>
  4098     <xsl:text>            this.handle_position(value);
  4136     <xsl:text>    }
       
  4137 </xsl:text>
       
  4138     <xsl:text>
       
  4139 </xsl:text>
       
  4140     <xsl:text>    handle_position(value){
       
  4141 </xsl:text>
       
  4142     <xsl:text>        let [min,max,start,totallength] = this.range;
       
  4143 </xsl:text>
       
  4144     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
       
  4145 </xsl:text>
       
  4146     <xsl:text>        let tip = this.range_elt.getPointAtLength(length);
       
  4147 </xsl:text>
       
  4148     <xsl:text>        this.handle_elt.setAttribute('transform',"translate("+(tip.x-start.x)+","+(tip.y-start.y)+")");
       
  4149 </xsl:text>
       
  4150     <xsl:text>    }
       
  4151 </xsl:text>
       
  4152     <xsl:text>
       
  4153 </xsl:text>
       
  4154     <xsl:text>    on_release(evt) {
       
  4155 </xsl:text>
       
  4156     <xsl:text>        if(this.drag){
       
  4157 </xsl:text>
       
  4158     <xsl:text>            this.drag = false;
  4099 </xsl:text>
  4159 </xsl:text>
  4100     <xsl:text>        }
  4160     <xsl:text>        }
  4101 </xsl:text>
  4161 </xsl:text>
  4102     <xsl:text>    }
  4162     <xsl:text>    }
  4103 </xsl:text>
  4163 </xsl:text>
  4104     <xsl:text>
  4164     <xsl:text>
  4105 </xsl:text>
  4165 </xsl:text>
  4106     <xsl:text>    handle_position(value){
  4166     <xsl:text>    update_position(evt){
  4107 </xsl:text>
  4167 </xsl:text>
  4108     <xsl:text>        let [min,max,start,totallength] = this.range;
  4168     <xsl:text>        if(this.drag){
  4109 </xsl:text>
  4169 </xsl:text>
  4110     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
  4170     <xsl:text>            var html_dist = 0;
  4111 </xsl:text>
  4171 </xsl:text>
  4112     <xsl:text>        let tip = this.range_elt.getPointAtLength(length);
  4172     <xsl:text>
  4113 </xsl:text>
  4173 </xsl:text>
  4114     <xsl:text>        this.handle_elt.setAttribute('transform',"translate("+(tip.x-start.x)+","+(tip.y-start.y)+")");
  4174     <xsl:text>            //calculate size of widget in html
       
  4175 </xsl:text>
       
  4176     <xsl:text>            var range_borders = this.range_elt.getBoundingClientRect();
       
  4177 </xsl:text>
       
  4178     <xsl:text>            var range_length = Math.sqrt( range_borders.height*range_borders.height + range_borders.width*range_borders.width );
       
  4179 </xsl:text>
       
  4180     <xsl:text>            var [minX,minY,maxX,maxY] = [range_borders.left,range_borders.bottom,range_borders.right,range_borders.top];
       
  4181 </xsl:text>
       
  4182     <xsl:text>
       
  4183 </xsl:text>
       
  4184     <xsl:text>            //get range and mouse coordinates
       
  4185 </xsl:text>
       
  4186     <xsl:text>            var mouseX = undefined;
       
  4187 </xsl:text>
       
  4188     <xsl:text>            var mouseY = undefined;
       
  4189 </xsl:text>
       
  4190     <xsl:text>            if (evt.type.startsWith("touch")){
       
  4191 </xsl:text>
       
  4192     <xsl:text>                mouseX = Math.ceil(evt.touches[0].clientX);
       
  4193 </xsl:text>
       
  4194     <xsl:text>                mouseY = Math.ceil(evt.touches[0].clientY);
       
  4195 </xsl:text>
       
  4196     <xsl:text>            }
       
  4197 </xsl:text>
       
  4198     <xsl:text>            else{
       
  4199 </xsl:text>
       
  4200     <xsl:text>                mouseX = evt.pageX;
       
  4201 </xsl:text>
       
  4202     <xsl:text>                mouseY = evt.pageY;
       
  4203 </xsl:text>
       
  4204     <xsl:text>            }
       
  4205 </xsl:text>
       
  4206     <xsl:text>
       
  4207 </xsl:text>
       
  4208     <xsl:text>            //get handle distance from mouse position
       
  4209 </xsl:text>
       
  4210     <xsl:text>            if (minX &gt; mouseX &amp;&amp; minY &lt; mouseY){
       
  4211 </xsl:text>
       
  4212     <xsl:text>                html_dist = 0;
       
  4213 </xsl:text>
       
  4214     <xsl:text>            }
       
  4215 </xsl:text>
       
  4216     <xsl:text>            else if (maxX &lt; mouseX &amp;&amp; maxY &gt; mouseY){
       
  4217 </xsl:text>
       
  4218     <xsl:text>                html_dist = range_length;
       
  4219 </xsl:text>
       
  4220     <xsl:text>            }
       
  4221 </xsl:text>
       
  4222     <xsl:text>            else{
       
  4223 </xsl:text>
       
  4224     <xsl:text>                // calculate distace
       
  4225 </xsl:text>
       
  4226     <xsl:text>                if(this.fi &gt; 0.7){
       
  4227 </xsl:text>
       
  4228     <xsl:text>                    html_dist = (minY - mouseY)/Math.sin(this.fi);
       
  4229 </xsl:text>
       
  4230     <xsl:text>                }
       
  4231 </xsl:text>
       
  4232     <xsl:text>                else{
       
  4233 </xsl:text>
       
  4234     <xsl:text>                    html_dist = (mouseX - minX)/Math.cos(this.fi);
       
  4235 </xsl:text>
       
  4236     <xsl:text>                }
       
  4237 </xsl:text>
       
  4238     <xsl:text>
       
  4239 </xsl:text>
       
  4240     <xsl:text>                //check if in range
       
  4241 </xsl:text>
       
  4242     <xsl:text>                if (html_dist &gt; range_length){
       
  4243 </xsl:text>
       
  4244     <xsl:text>                    html_dist = range_length;
       
  4245 </xsl:text>
       
  4246     <xsl:text>                }
       
  4247 </xsl:text>
       
  4248     <xsl:text>                else if (html_dist &lt; 0){
       
  4249 </xsl:text>
       
  4250     <xsl:text>                    html_dist = 0;
       
  4251 </xsl:text>
       
  4252     <xsl:text>                }
       
  4253 </xsl:text>
       
  4254     <xsl:text>            }
       
  4255 </xsl:text>
       
  4256     <xsl:text>
       
  4257 </xsl:text>
       
  4258     <xsl:text>            this.svg_dist=(html_dist/range_length)*this.range[1];
       
  4259 </xsl:text>
       
  4260     <xsl:text>
       
  4261 </xsl:text>
       
  4262     <xsl:text>            //redraw handle
       
  4263 </xsl:text>
       
  4264     <xsl:text>            //this.handle_position(svg_dist=(html_dist/range_length)*this.range[1]);
       
  4265 </xsl:text>
       
  4266     <xsl:text>            //this.value_elt.textContent = String(Math.ceil(svg_dist));
       
  4267 </xsl:text>
       
  4268     <xsl:text>
       
  4269 </xsl:text>
       
  4270     <xsl:text>            if(this.enTimer){
       
  4271 </xsl:text>
       
  4272     <xsl:text>                this.apply_hmi_value(0, Math.ceil(this.svg_dist));
       
  4273 </xsl:text>
       
  4274     <xsl:text>
       
  4275 </xsl:text>
       
  4276     <xsl:text>                // TODO : update ghost cursor and call this.request_animate()
       
  4277 </xsl:text>
       
  4278     <xsl:text>
       
  4279 </xsl:text>
       
  4280     <xsl:text>                //reset timer
       
  4281 </xsl:text>
       
  4282     <xsl:text>                this.enTimer = false;
       
  4283 </xsl:text>
       
  4284     <xsl:text>                setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100);
       
  4285 </xsl:text>
       
  4286     <xsl:text>            }
       
  4287 </xsl:text>
       
  4288     <xsl:text>        }
  4115 </xsl:text>
  4289 </xsl:text>
  4116     <xsl:text>    }
  4290     <xsl:text>    }
  4117 </xsl:text>
  4291 </xsl:text>
  4118     <xsl:text>
  4292     <xsl:text>
  4119 </xsl:text>
  4293 </xsl:text>
  4120     <xsl:text>    on_release(evt) {
  4294     <xsl:text>    on_select(evt){
  4121 </xsl:text>
  4295 </xsl:text>
  4122     <xsl:text>        if(this.drag){
  4296     <xsl:text>        this.drag = true;
  4123 </xsl:text>
  4297 </xsl:text>
  4124     <xsl:text>            this.drag = false;
  4298     <xsl:text>        this.enTimer = true;
  4125 </xsl:text>
  4299 </xsl:text>
  4126     <xsl:text>        }
  4300     <xsl:text>        this.update_position(evt);
  4127 </xsl:text>
  4301 </xsl:text>
  4128     <xsl:text>    }
  4302     <xsl:text>    }
  4129 </xsl:text>
  4303 </xsl:text>
  4130     <xsl:text>
  4304     <xsl:text>
  4131 </xsl:text>
  4305 </xsl:text>
  4132     <xsl:text>    update_position(evt){
  4306     <xsl:text>    init() {
  4133 </xsl:text>
  4307 </xsl:text>
  4134     <xsl:text>        if(this.drag &amp;&amp; this.enTimer){
  4308     <xsl:text>        let min = this.min_elt ?
  4135 </xsl:text>
  4309 </xsl:text>
  4136     <xsl:text>            var html_dist = 0;
  4310     <xsl:text>                    Number(this.min_elt.textContent) :
  4137 </xsl:text>
  4311 </xsl:text>
  4138     <xsl:text>            var svg_dist = 0;
  4312     <xsl:text>                    this.args.length &gt;= 1 ? this.args[0] : 0;
  4139 </xsl:text>
  4313 </xsl:text>
  4140     <xsl:text>
  4314     <xsl:text>        let max = this.max_elt ?
  4141 </xsl:text>
  4315 </xsl:text>
  4142     <xsl:text>            //calculate size of widget in html
  4316     <xsl:text>                    Number(this.max_elt.textContent) :
  4143 </xsl:text>
  4317 </xsl:text>
  4144     <xsl:text>            var range_borders = this.range_elt.getBoundingClientRect();
  4318     <xsl:text>                    this.args.length &gt;= 2 ? this.args[1] : 100;
  4145 </xsl:text>
  4319 </xsl:text>
  4146     <xsl:text>            var range_length = Math.sqrt( range_borders.height*range_borders.height + range_borders.width*range_borders.width );
  4320     <xsl:text>
  4147 </xsl:text>
  4321 </xsl:text>
  4148     <xsl:text>            var [minX,minY,maxX,maxY] = [range_borders.left,range_borders.bottom,range_borders.right,range_borders.top];
  4322     <xsl:text>        this.range = [min, max, this.range_elt.getPointAtLength(0),this.range_elt.getTotalLength()];
  4149 </xsl:text>
  4323 </xsl:text>
  4150     <xsl:text>
  4324     <xsl:text>        let start = this.range_elt.getPointAtLength(0);
  4151 </xsl:text>
  4325 </xsl:text>
  4152     <xsl:text>            //get range and mouse coordinates
  4326     <xsl:text>        let end = this.range_elt.getPointAtLength(this.range_elt.getTotalLength());
  4153 </xsl:text>
  4327 </xsl:text>
  4154     <xsl:text>            var mouseX = undefined;
  4328     <xsl:text>        this.fi = Math.atan2(start.y-end.y, end.x-start.x);
  4155 </xsl:text>
  4329 </xsl:text>
  4156     <xsl:text>            var mouseY = undefined;
  4330     <xsl:text>
  4157 </xsl:text>
  4331 </xsl:text>
  4158     <xsl:text>            if (evt.type.startsWith("touch")){
  4332     <xsl:text>
  4159 </xsl:text>
  4333 </xsl:text>
  4160     <xsl:text>                mouseX = Math.ceil(evt.touches[0].clientX);
  4334     <xsl:text>        this.handle_elt.addEventListener("touchstart", hmi_widgets[this.element_id].on_select.bind(this));
  4161 </xsl:text>
  4335 </xsl:text>
  4162     <xsl:text>                mouseY = Math.ceil(evt.touches[0].clientY);
  4336     <xsl:text>        this.handle_elt.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this));
  4163 </xsl:text>
  4337 </xsl:text>
  4164     <xsl:text>            }
  4338     <xsl:text>        this.element.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this));
  4165 </xsl:text>
  4339 </xsl:text>
  4166     <xsl:text>            else{
  4340     <xsl:text>
  4167 </xsl:text>
  4341 </xsl:text>
  4168     <xsl:text>                mouseX = evt.pageX;
  4342     <xsl:text>        window.addEventListener("touchmove", hmi_widgets[this.element_id].update_position.bind(this));
  4169 </xsl:text>
  4343 </xsl:text>
  4170     <xsl:text>                mouseY = evt.pageY;
  4344     <xsl:text>        window.addEventListener("mousemove", hmi_widgets[this.element_id].update_position.bind(this));
  4171 </xsl:text>
  4345 </xsl:text>
  4172     <xsl:text>            }
  4346     <xsl:text>
  4173 </xsl:text>
  4347 </xsl:text>
  4174     <xsl:text>
  4348     <xsl:text>        window.addEventListener("mouseup", hmi_widgets[this.element_id].on_release.bind(this))
  4175 </xsl:text>
  4349 </xsl:text>
  4176     <xsl:text>            //get handle distance from mouse position
  4350     <xsl:text>        window.addEventListener("touchend", hmi_widgets[this.element_id].on_release.bind(this));
  4177 </xsl:text>
  4351 </xsl:text>
  4178     <xsl:text>            if (minX &gt; mouseX &amp;&amp; minY &lt; mouseY){
  4352     <xsl:text>        window.addEventListener("touchcancel", hmi_widgets[this.element_id].on_release.bind(this));
  4179 </xsl:text>
       
  4180     <xsl:text>                html_dist = 0;
       
  4181 </xsl:text>
       
  4182     <xsl:text>            }
       
  4183 </xsl:text>
       
  4184     <xsl:text>            else if (maxX &lt; mouseX &amp;&amp; maxY &gt; mouseY){
       
  4185 </xsl:text>
       
  4186     <xsl:text>                html_dist = range_length;
       
  4187 </xsl:text>
       
  4188     <xsl:text>            }
       
  4189 </xsl:text>
       
  4190     <xsl:text>            else{
       
  4191 </xsl:text>
       
  4192     <xsl:text>                // calculate distace
       
  4193 </xsl:text>
       
  4194     <xsl:text>                if(this.fi &gt; 0.7){
       
  4195 </xsl:text>
       
  4196     <xsl:text>                    html_dist = (minY - mouseY)/Math.sin(this.fi);
       
  4197 </xsl:text>
       
  4198     <xsl:text>                }
       
  4199 </xsl:text>
       
  4200     <xsl:text>                else{
       
  4201 </xsl:text>
       
  4202     <xsl:text>                    html_dist = (mouseX - minX)/Math.cos(this.fi);
       
  4203 </xsl:text>
       
  4204     <xsl:text>                }
       
  4205 </xsl:text>
       
  4206     <xsl:text>
       
  4207 </xsl:text>
       
  4208     <xsl:text>                //check if in range
       
  4209 </xsl:text>
       
  4210     <xsl:text>                if (html_dist &gt; range_length){
       
  4211 </xsl:text>
       
  4212     <xsl:text>                    html_dist = range_length;
       
  4213 </xsl:text>
       
  4214     <xsl:text>                }
       
  4215 </xsl:text>
       
  4216     <xsl:text>                else if (html_dist &lt; 0){
       
  4217 </xsl:text>
       
  4218     <xsl:text>                    html_dist = 0;
       
  4219 </xsl:text>
       
  4220     <xsl:text>                }
       
  4221 </xsl:text>
       
  4222     <xsl:text>            }
       
  4223 </xsl:text>
       
  4224     <xsl:text>            //redraw handle
       
  4225 </xsl:text>
       
  4226     <xsl:text>            this.handle_position(svg_dist=(html_dist/range_length)*this.range[1]);
       
  4227 </xsl:text>
       
  4228     <xsl:text>            this.value_elt.textContent = String(Math.ceil(svg_dist));
       
  4229 </xsl:text>
       
  4230     <xsl:text>            change_hmi_value(this.indexes[0], "="+Math.ceil(svg_dist));
       
  4231 </xsl:text>
       
  4232     <xsl:text>            //reset timer
       
  4233 </xsl:text>
       
  4234     <xsl:text>            this.enTimer = false;
       
  4235 </xsl:text>
       
  4236     <xsl:text>            setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100);
       
  4237 </xsl:text>
       
  4238     <xsl:text>        }
       
  4239 </xsl:text>
  4353 </xsl:text>
  4240     <xsl:text>
  4354     <xsl:text>
  4241 </xsl:text>
  4355 </xsl:text>
  4242     <xsl:text>    }
  4356     <xsl:text>    }
  4243 </xsl:text>
  4357 </xsl:text>
  4244     <xsl:text>
       
  4245 </xsl:text>
       
  4246     <xsl:text>    on_select(evt){
       
  4247 </xsl:text>
       
  4248     <xsl:text>        this.drag = true;
       
  4249 </xsl:text>
       
  4250     <xsl:text>        this.enTimer = true;
       
  4251 </xsl:text>
       
  4252     <xsl:text>        this.update_position(evt);
       
  4253 </xsl:text>
       
  4254     <xsl:text>    }
       
  4255 </xsl:text>
       
  4256     <xsl:text>
       
  4257 </xsl:text>
       
  4258     <xsl:text>    init() {
       
  4259 </xsl:text>
       
  4260     <xsl:text>        let min = this.min_elt ?
       
  4261 </xsl:text>
       
  4262     <xsl:text>                    Number(this.min_elt.textContent) :
       
  4263 </xsl:text>
       
  4264     <xsl:text>                    this.args.length &gt;= 1 ? this.args[0] : 0;
       
  4265 </xsl:text>
       
  4266     <xsl:text>        let max = this.max_elt ?
       
  4267 </xsl:text>
       
  4268     <xsl:text>                    Number(this.max_elt.textContent) :
       
  4269 </xsl:text>
       
  4270     <xsl:text>                    this.args.length &gt;= 2 ? this.args[1] : 100;
       
  4271 </xsl:text>
       
  4272     <xsl:text>
       
  4273 </xsl:text>
       
  4274     <xsl:text>        this.range = [min, max, this.range_elt.getPointAtLength(0),this.range_elt.getTotalLength()];
       
  4275 </xsl:text>
       
  4276     <xsl:text>        let start = this.range_elt.getPointAtLength(0);
       
  4277 </xsl:text>
       
  4278     <xsl:text>        let end = this.range_elt.getPointAtLength(this.range_elt.getTotalLength());
       
  4279 </xsl:text>
       
  4280     <xsl:text>        this.fi = Math.atan2(start.y-end.y, end.x-start.x);
       
  4281 </xsl:text>
       
  4282     <xsl:text>
       
  4283 </xsl:text>
       
  4284     <xsl:text>
       
  4285 </xsl:text>
       
  4286     <xsl:text>        this.handle_elt.addEventListener("touchstart", hmi_widgets[this.element_id].on_select.bind(this));
       
  4287 </xsl:text>
       
  4288     <xsl:text>        this.handle_elt.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this));
       
  4289 </xsl:text>
       
  4290     <xsl:text>        this.element.addEventListener("mousedown", hmi_widgets[this.element_id].on_select.bind(this));
       
  4291 </xsl:text>
       
  4292     <xsl:text>
       
  4293 </xsl:text>
       
  4294     <xsl:text>        window.addEventListener("touchmove", hmi_widgets[this.element_id].update_position.bind(this));
       
  4295 </xsl:text>
       
  4296     <xsl:text>        window.addEventListener("mousemove", hmi_widgets[this.element_id].update_position.bind(this));
       
  4297 </xsl:text>
       
  4298     <xsl:text>
       
  4299 </xsl:text>
       
  4300     <xsl:text>        window.addEventListener("mouseup", hmi_widgets[this.element_id].on_release.bind(this))
       
  4301 </xsl:text>
       
  4302     <xsl:text>        window.addEventListener("touchend", hmi_widgets[this.element_id].on_release.bind(this));
       
  4303 </xsl:text>
       
  4304     <xsl:text>        window.addEventListener("touchcancel", hmi_widgets[this.element_id].on_release.bind(this));
       
  4305 </xsl:text>
       
  4306     <xsl:text>
       
  4307 </xsl:text>
       
  4308     <xsl:text>    }
       
  4309 </xsl:text>
       
  4310     <xsl:text>}
  4358     <xsl:text>}
  4311 </xsl:text>
  4359 </xsl:text>
  4312   </xsl:template>
  4360   </xsl:template>
  4313   <xsl:template match="widget[@type='Slider']" mode="widget_defs">
  4361   <xsl:template mode="widget_defs" match="widget[@type='Slider']">
  4314     <xsl:param name="hmi_element"/>
  4362     <xsl:param name="hmi_element"/>
  4315     <xsl:call-template name="defs_by_labels">
  4363     <xsl:call-template name="defs_by_labels">
  4316       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4364       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4317       <xsl:with-param name="labels">
  4365       <xsl:with-param name="labels">
  4318         <xsl:text>handle range</xsl:text>
  4366         <xsl:text>handle range</xsl:text>
  4326       <xsl:with-param name="mandatory" select="'no'"/>
  4374       <xsl:with-param name="mandatory" select="'no'"/>
  4327     </xsl:call-template>
  4375     </xsl:call-template>
  4328     <xsl:text>
  4376     <xsl:text>
  4329 </xsl:text>
  4377 </xsl:text>
  4330   </xsl:template>
  4378   </xsl:template>
  4331   <xsl:template match="widget[@type='Switch']" mode="widget_class">
  4379   <xsl:template mode="widget_class" match="widget[@type='Switch']">
  4332     <xsl:text>class SwitchWidget extends Widget{
  4380     <xsl:text>class SwitchWidget extends Widget{
  4333 </xsl:text>
  4381 </xsl:text>
  4334     <xsl:text>    frequency = 5;
  4382     <xsl:text>    frequency = 5;
  4335 </xsl:text>
  4383 </xsl:text>
  4336     <xsl:text>    dispatch(value) {
  4384     <xsl:text>    dispatch(value) {
  4352     <xsl:text>    }
  4400     <xsl:text>    }
  4353 </xsl:text>
  4401 </xsl:text>
  4354     <xsl:text>}
  4402     <xsl:text>}
  4355 </xsl:text>
  4403 </xsl:text>
  4356   </xsl:template>
  4404   </xsl:template>
  4357   <xsl:template match="widget[@type='Switch']" mode="widget_defs">
  4405   <xsl:template mode="widget_defs" match="widget[@type='Switch']">
  4358     <xsl:param name="hmi_element"/>
  4406     <xsl:param name="hmi_element"/>
  4359     <xsl:text>    choices: [
  4407     <xsl:text>    choices: [
  4360 </xsl:text>
  4408 </xsl:text>
  4361     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  4409     <xsl:variable name="regex" select="'^(&quot;[^&quot;].*&quot;|\-?[0-9]+|false|true)(#.*)?$'"/>
  4362     <xsl:for-each select="$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]">
  4410     <xsl:for-each select="$result_svg_ns//*[@id = $hmi_element/@id]//*[regexp:test(@inkscape:label,$regex)]">
  4383 </xsl:text>
  4431 </xsl:text>
  4384     </xsl:for-each>
  4432     </xsl:for-each>
  4385     <xsl:text>    ],
  4433     <xsl:text>    ],
  4386 </xsl:text>
  4434 </xsl:text>
  4387   </xsl:template>
  4435   </xsl:template>
  4388   <xsl:template match="widget[@type='ToggleButton']" mode="widget_class">
  4436   <xsl:template mode="widget_class" match="widget[@type='ToggleButton']">
  4389     <xsl:text>class ToggleButtonWidget extends Widget{
  4437     <xsl:text>class ToggleButtonWidget extends Widget{
  4390 </xsl:text>
  4438 </xsl:text>
  4391     <xsl:text>    frequency = 5;
  4439     <xsl:text>    frequency = 5;
  4392 </xsl:text>
  4440 </xsl:text>
  4393     <xsl:text>    state = 0;
  4441     <xsl:text>    state = 0;
  4424 </xsl:text>
  4472 </xsl:text>
  4425     <xsl:text>
  4473     <xsl:text>
  4426 </xsl:text>
  4474 </xsl:text>
  4427     <xsl:text>    on_click(evt) {
  4475     <xsl:text>    on_click(evt) {
  4428 </xsl:text>
  4476 </xsl:text>
  4429     <xsl:text>        change_hmi_value(this.indexes[0], "="+this.state);
  4477     <xsl:text>        this.apply_hmi_value(0, this.state);
  4430 </xsl:text>
  4478 </xsl:text>
  4431     <xsl:text>    }
  4479     <xsl:text>    }
  4432 </xsl:text>
  4480 </xsl:text>
  4433     <xsl:text>
  4481     <xsl:text>
  4434 </xsl:text>
  4482 </xsl:text>
  4443     <xsl:text>    }
  4491     <xsl:text>    }
  4444 </xsl:text>
  4492 </xsl:text>
  4445     <xsl:text>}
  4493     <xsl:text>}
  4446 </xsl:text>
  4494 </xsl:text>
  4447   </xsl:template>
  4495   </xsl:template>
  4448   <xsl:template match="widget[@type='ToggleButton']" mode="widget_defs">
  4496   <xsl:template mode="widget_defs" match="widget[@type='ToggleButton']">
  4449     <xsl:param name="hmi_element"/>
  4497     <xsl:param name="hmi_element"/>
  4450     <xsl:call-template name="defs_by_labels">
  4498     <xsl:call-template name="defs_by_labels">
  4451       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4499       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  4452       <xsl:with-param name="labels">
  4500       <xsl:with-param name="labels">
  4453         <xsl:text>active inactive</xsl:text>
  4501         <xsl:text>active inactive</xsl:text>
  4654 </xsl:text>
  4702 </xsl:text>
  4655           <xsl:text>
  4703           <xsl:text>
  4656 </xsl:text>
  4704 </xsl:text>
  4657           <xsl:text>    apply_updates();
  4705           <xsl:text>    apply_updates();
  4658 </xsl:text>
  4706 </xsl:text>
       
  4707           <xsl:text>
       
  4708 </xsl:text>
       
  4709           <xsl:text>    pending_widget_animates.forEach(widget =&gt; widget._animate());
       
  4710 </xsl:text>
       
  4711           <xsl:text>    pending_widget_animates = [];
       
  4712 </xsl:text>
       
  4713           <xsl:text>
       
  4714 </xsl:text>
  4659           <xsl:text>    requestAnimationFrameID = null;
  4715           <xsl:text>    requestAnimationFrameID = null;
  4660 </xsl:text>
  4716 </xsl:text>
  4661           <xsl:text>}
  4717           <xsl:text>}
  4662 </xsl:text>
  4718 </xsl:text>
  4663           <xsl:text>
  4719           <xsl:text>
  5250 </xsl:text>
  5306 </xsl:text>
  5251           <xsl:text>var xmlns = "http://www.w3.org/2000/svg";
  5307           <xsl:text>var xmlns = "http://www.w3.org/2000/svg";
  5252 </xsl:text>
  5308 </xsl:text>
  5253           <xsl:text>var edit_callback;
  5309           <xsl:text>var edit_callback;
  5254 </xsl:text>
  5310 </xsl:text>
  5255           <xsl:text>function edit_value(path, valuetype, callback, initial,size) {
  5311           <xsl:text>function edit_value(path, valuetype, callback, initial, size) {
  5256 </xsl:text>
  5312 </xsl:text>
  5257           <xsl:text>
  5313           <xsl:text>
  5258 </xsl:text>
  5314 </xsl:text>
  5259           <xsl:text>    let [keypadid, xcoord, ycoord] = keypads[valuetype];
  5315           <xsl:text>    let [keypadid, xcoord, ycoord] = keypads[valuetype];
  5260 </xsl:text>
  5316 </xsl:text>
  5262 </xsl:text>
  5318 </xsl:text>
  5263           <xsl:text>    edit_callback = callback;
  5319           <xsl:text>    edit_callback = callback;
  5264 </xsl:text>
  5320 </xsl:text>
  5265           <xsl:text>    let widget = hmi_widgets[keypadid];
  5321           <xsl:text>    let widget = hmi_widgets[keypadid];
  5266 </xsl:text>
  5322 </xsl:text>
  5267           <xsl:text>    widget.start_edit(path, valuetype, callback, initial,size);
  5323           <xsl:text>    widget.start_edit(path, valuetype, callback, initial, size);
  5268 </xsl:text>
  5324 </xsl:text>
  5269           <xsl:text>};
  5325           <xsl:text>};
  5270 </xsl:text>
  5326 </xsl:text>
  5271           <xsl:text>
  5327           <xsl:text>
  5272 </xsl:text>
  5328 </xsl:text>