svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2829 4c2c50f60730
parent 2822 9101a72a1da0
child 2833 e74123b966ac
--- a/svghmi/gen_index_xhtml.ysl2	Wed Jan 15 11:13:39 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Fri Jan 17 16:25:45 2020 +0100
@@ -373,6 +373,21 @@
         | },
     }
 
+    def "func:escape_quotes" {
+        param "txt";
+        // have to use a python string to enter escaped quote
+        const "frst", !"substring-before($txt,'\"')"!;
+        const "frstln", "string-length($frst)";
+        choose {
+            when "$frstln > 0 and string-length($txt) > $frstln" {
+                result !"concat($frst,'\\\"',func:escape_quotes(substring-after($txt,'\"')))"!;
+            }
+            otherwise {
+                result "$txt";
+            }
+        }
+    }
+
     template "widget[@type='Input']", mode="widget_defs" {
         param "hmi_element";
         | frequency: 5,
@@ -387,10 +402,10 @@
         |         "click", 
         |         evt => alert('XXX TODO : Edit value'));
         }
-        foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-][0-9]+')]" {
+        foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
         |     document.getElementById("«@id»").addEventListener(
         |         "click", 
-        |         evt => {let new_val = change_hmi_value(this.indexes[0], "«@inkscape:label»");
+        |         evt => {let new_val = change_hmi_value(this.indexes[0], "«func:escape_quotes(@inkscape:label)»");
         |                 this.value_elt.textContent = String(new_val);});
                           /* could gray out value until refreshed */
         }