SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 05 Mar 2020 10:23:03 +0100
branchsvghmi
changeset 2857 a5c781b2f8f9
parent 2856 1b529ba018ad
child 2858 39c8d6079f0f
SVGHMI: Meter widget accepts 2 arguments : min and max, taken in account when min or max text element is missing
svghmi/gen_index_xhtml.xslt
svghmi/gen_index_xhtml.ysl2
--- a/svghmi/gen_index_xhtml.xslt	Wed Mar 04 20:02:15 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Thu Mar 05 10:23:03 2020 +0100
@@ -1332,9 +1332,17 @@
 </xsl:text>
     <xsl:text>    init: function() {
 </xsl:text>
-    <xsl:text>        let min = this.min_elt ? Number(this.min_elt.textContent) : 0;
-</xsl:text>
-    <xsl:text>        let max = this.max_elt ? Number(this.max_elt.textContent) : 100;
+    <xsl:text>        let min = this.min_elt ?
+</xsl:text>
+    <xsl:text>                    Number(this.min_elt.textContent) :
+</xsl:text>
+    <xsl:text>                    this.args.length &gt;= 1 ? this.args[0] : 0;
+</xsl:text>
+    <xsl:text>        let max = this.max_elt ?
+</xsl:text>
+    <xsl:text>                    Number(this.max_elt.textContent) :
+</xsl:text>
+    <xsl:text>                    this.args.length &gt;= 2 ? this.args[1] : 100;
 </xsl:text>
     <xsl:text>        this.range = [min, max, this.range_elt.getTotalLength()]
 </xsl:text>
--- a/svghmi/gen_index_xhtml.ysl2	Wed Mar 04 20:02:15 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2	Thu Mar 05 10:23:03 2020 +0100
@@ -720,8 +720,12 @@
         |     origin: undefined,
         |     range: undefined,
         |     init: function() {
-        |         let min = this.min_elt ? Number(this.min_elt.textContent) : 0;
-        |         let max = this.max_elt ? Number(this.max_elt.textContent) : 100;
+        |         let min = this.min_elt ?
+        |                     Number(this.min_elt.textContent) :
+        |                     this.args.length >= 1 ? this.args[0] : 0;
+        |         let max = this.max_elt ?
+        |                     Number(this.max_elt.textContent) :
+        |                     this.args.length >= 2 ? this.args[1] : 100;
         |         this.range = [min, max, this.range_elt.getTotalLength()]
         |         this.origin = this.needle_elt.getPointAtLength(0);
         |     },