beremiz
Clone
Summary
Browse
Changes
Graph
SVGHMI: Added scripts.ysl2
svghmi
2020-04-18, Edouard Tisserant
1379cd5c69dd
Parents
9226a830fbc3
Children
4296ab974d4d
SVGHMI: Added scripts.ysl2
3 files changed, 75 insertions(+), 73 deletions(-)
+23
-23
svghmi/gen_index_xhtml.xslt
+2
-50
svghmi/gen_index_xhtml.ysl2
+50
-0
svghmi/scripts.ysl2
--- a/svghmi/gen_index_xhtml.xslt Sat Apr 18 11:49:02 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Sat Apr 18 13:14:45 2020 +0200
@@ -2072,28 +2072,6 @@
<xsl:text> ],
</xsl:text>
</xsl:template>
- <xsl:template mode="debug_as_comment" match="*[namespace-uri()='reflect']">
- <xsl:comment>
- <xsl:value-of select="local-name()"/>
- <xsl:text> :
-</xsl:text>
- <xsl:apply-templates mode="debug" select="."/>
- </xsl:comment>
- </xsl:template>
- <xsl:template match="/">
- <xsl:comment>
- <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
- </xsl:comment>
- <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
- <head/>
- <body style="margin:0;overflow:hidden;">
- <xsl:copy-of select="$result_svg"/>
- <script>
- <xsl:call-template name="scripts"/>
- </script>
- </body>
- </html>
- </xsl:template>
<xsl:template name="scripts">
<xsl:text>
</xsl:text>
@@ -2103,7 +2081,7 @@
</xsl:text>
<xsl:text>var hmi_hash = [</xsl:text>
<xsl:value-of select="$hmitree/@hash"/>
- <xsl:text>];
+ <xsl:text>];
</xsl:text>
<xsl:text>var hmi_widgets = {
</xsl:text>
@@ -3244,4 +3222,26 @@
<xsl:text>};
</xsl:text>
</xsl:template>
+ <xsl:template mode="debug_as_comment" match="*[namespace-uri()='reflect']">
+ <xsl:comment>
+ <xsl:value-of select="local-name()"/>
+ <xsl:text> :
+</xsl:text>
+ <xsl:apply-templates mode="debug" select="."/>
+ </xsl:comment>
+ </xsl:template>
+ <xsl:template match="/">
+ <xsl:comment>
+ <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
+ </xsl:comment>
+ <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml">
+ <head/>
+ <body style="margin:0;overflow:hidden;">
+ <xsl:copy-of select="$result_svg"/>
+ <script>
+ <xsl:call-template name="scripts"/>
+ </script>
+ </body>
+ </html>
+ </xsl:template>
</xsl:stylesheet>
--- a/svghmi/gen_index_xhtml.ysl2 Sat Apr 18 11:49:02 2020 +0200
+++ b/svghmi/gen_index_xhtml.ysl2 Sat Apr 18 13:14:45 2020 +0200
@@ -35,6 +35,8 @@
include widget_*.ysl2
+ include scripts.ysl2
+
template "*[namespace-uri()='reflect']", mode="debug_as_comment" {
comment {
| «local-name()» :
@@ -61,54 +63,4 @@
}
}
}
-
- function "scripts"
- {
- |
- | id = idstr => document.getElementById(idstr);
- |
- | var hmi_hash = [«$hmitree/@hash»];
-
- | var hmi_widgets = {
- apply "$hmi_elements", mode="hmi_elements";
- | }
- |
- | var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»;
- |
- | var hmitree_types = [
-
- foreach "$indexed_hmitree/*" {
- | /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
- }
-
- | ]
- |
-
- | var detachable_elements = {
- foreach "$detachable_elements"{
- | "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
- }
- | }
-
- |
- | var page_desc = {
- apply "$hmi_pages", mode="page_desc";
- | }
-
- | var keypads = {
- foreach "$keypads_descs"{
- const "keypad_id","@id";
- foreach "arg"{
- const "g", "$geometry[@Id = $keypad_id]";
- | "«@value»":["«$keypad_id»", «$g/@x», «$g/@y»],
- }
- }
- | }
-
-
- |
- | var default_page = "«$default_page»";
- | var svg_root = id("«/svg:svg/@id»");
- include text svghmi.js
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/scripts.ysl2 Sat Apr 18 13:14:45 2020 +0200
@@ -0,0 +1,50 @@
+function "scripts"
+{
+ |
+ | id = idstr => document.getElementById(idstr);
+ |
+ | var hmi_hash = [«$hmitree/@hash»];
+
+ | var hmi_widgets = {
+ apply "$hmi_elements", mode="hmi_elements";
+ | }
+ |
+ | var heartbeat_index = «$indexed_hmitree/*[@hmipath = '/HEARTBEAT']/@index»;
+ |
+ | var hmitree_types = [
+
+ foreach "$indexed_hmitree/*" {
+ | /* «@index» «@hmipath» */ "«substring(local-name(), 5)»"`if "position()!=last()" > ,`
+ }
+
+ | ]
+ |
+
+ | var detachable_elements = {
+ foreach "$detachable_elements"{
+ | "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
+ }
+ | }
+
+ |
+ | var page_desc = {
+ apply "$hmi_pages", mode="page_desc";
+ | }
+
+ | var keypads = {
+ foreach "$keypads_descs"{
+ const "keypad_id","@id";
+ foreach "arg"{
+ const "g", "$geometry[@Id = $keypad_id]";
+ | "«@value»":["«$keypad_id»", «$g/@x», «$g/@y»],
+ }
+ }
+ | }
+
+
+ |
+ | var default_page = "«$default_page»";
+ | var svg_root = id("«/svg:svg/@id»");
+ include text svghmi.js
+}
+