--- a/svghmi/gen_index_xhtml.xslt Thu Sep 19 15:32:36 2019 +0200
+++ b/svghmi/gen_index_xhtml.xslt Fri Sep 20 13:38:58 2019 +0200
@@ -26,13 +26,25 @@
<xsl:apply-templates select="@* | node()"/>
+ <xsl:text>function evaluate_js_from_descriptions() { + <xsl:text> var Display; + <xsl:text> var res = []; <xsl:variable name="midmark">
<xsl:value-of select="$mark"/>
<xsl:apply-templates mode="code_from_descs" select="//*[contains(child::svg:desc, $midmark) or starts-with(child::svg:desc, $mark)]"/>
@@ -61,20 +73,40 @@
<xsl:template mode="code_from_descs" match="*">
- <xsl:text>function js_</xsl:text>
+ <xsl:text> var path, role, name, priv; + <xsl:text> var id = "</xsl:text> <xsl:value-of select="@id"/>
- <xsl:text>var path, role, path, priv;
+ <xsl:if test="«@inkscape:label»"> + <xsl:text>name = "</xsl:text> + <xsl:value-of select="@inkscape:label"/>
+ <xsl:text>/* -------------- */ <xsl:value-of select="substring-after(svg:desc, $mark)"/>
+ <xsl:text> /* -------------- */
<xsl:template mode="testgeo" match="bbox">
--- a/svghmi/gen_index_xhtml.ysl2 Thu Sep 19 15:32:36 2019 +0200
+++ b/svghmi/gen_index_xhtml.ysl2 Fri Sep 20 13:38:58 2019 +0200
@@ -50,11 +50,21 @@
+ function evaluate_js_from_descriptions() { variable "midmark" > \n«$mark»
apply """//*[contains(child::svg:desc, $midmark) or \
- starts-with(child::svg:desc, $mark)]""",
+ starts-with(child::svg:desc, $mark)]""",2
@@ -68,13 +78,33 @@
template "*", mode="code_from_descs" {
- | function js_«@id»() {
- | var path, role, path, priv;
+ var path, role, name, priv; + /* if label is used, use it as default name */ + |> name = "«@inkscape:label»"; + // this breaks indent, but fixing indent could break string literals value "substring-after(svg:desc, $mark)";
+ // nobody reads generated code anyhow... --- a/svghmi/svghmi.js Thu Sep 19 15:32:36 2019 +0200
+++ b/svghmi/svghmi.js Fri Sep 20 13:38:58 2019 +0200
@@ -1,11 +1,22 @@
- var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
- var ws = new WebSocket(relative_URI);
+ // Open WebSocket to relative "/ws" address + var ws = new WebSocket(window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws')); + // Register message reception handler ws.onmessage = function (evt) {
+ // TODO : dispatch and cache hmi tree updates var received_msg = evt.data;
alert("Message is received..."+received_msg);
+ // Once connection established ws.onopen = function (evt) {
+ // TODO : enable the HMI (was previously offline, or just starts)