--- a/svghmi/gen_index_xhtml.xslt Tue Oct 29 11:18:58 2019 +0100
+++ b/svghmi/gen_index_xhtml.xslt Wed Oct 30 15:17:05 2019 +0100
@@ -344,6 +344,38 @@
+ <xsl:text>function dispatch_value_to_widget(widget, index, value, oldval) { + <xsl:text> let idxidx = widget.indexes.indexOf(index); + <xsl:text> if(idxidx == -1){ + <xsl:text> throw new Error("Dispatching to widget not interested, should not happen."); + <xsl:text> let d = widget.dispatch; + <xsl:text> if(typeof(d) == "function" && idxidx == 0){ + <xsl:text> return d.call(widget, value, oldval); + <xsl:text> }else if(typeof(d) == "object" && d.length >= idxidx){ + <xsl:text> return d[idxidx].call(widget, value, oldval); + <xsl:text> }/* else dispatch_0, ..., dispatch_n ? */ + <xsl:text> throw new Error("Dunno how to dispatch to widget at index = " + index); <xsl:text>function dispatch_value(index, value) {
<xsl:text> let widgets = subscribers[index];
@@ -360,31 +392,7 @@
<xsl:text> for(let widget of widgets){
- <xsl:text> let idxidx = widget.indexes.indexOf(index);
- <xsl:text> if(idxidx == -1){
- <xsl:text> throw new Error("Dispatching to widget not interested, should not happen.");
- <xsl:text> let d = widget.dispatch;
- <xsl:text> if(typeof(d) == "function" && idxidx == 0){
- <xsl:text> return d.call(widget, value, oldval);
- <xsl:text> }else if(typeof(d) == "object" && d.length >= idxidx){
- <xsl:text> return d[idxidx].call(widget, value, oldval);
- <xsl:text> }/* else dispatch_0, ..., dispatch_n ? */
- <xsl:text> throw new Error("Dunno how to dispatch to widget at index = " + index);
+ <xsl:text> dispatch_value_to_widget(widget, index, value, oldval); @@ -726,12 +734,22 @@
<xsl:text> subscribers[index].add(widget);
+ <xsl:text> let cached_val = cache[index]; + <xsl:text> if(cached_val != undefined) + <xsl:text> dispatch_value_to_widget(widget, index, cached_val, cached_val); <xsl:text> svg_root.setAttribute('viewBox',new_desc.bbox.join(" "));
+ <xsl:text> // TODO dispatch current cache in newly opened page <xsl:text> current_page = page_name;
--- a/svghmi/svghmi.js Tue Oct 29 11:18:58 2019 +0100
+++ b/svghmi/svghmi.js Wed Oct 30 15:17:05 2019 +0100
@@ -2,6 +2,22 @@
var cache = hmitree_types.map(_ignored => undefined);
+function dispatch_value_to_widget(widget, index, value, oldval) { + let idxidx = widget.indexes.indexOf(index); + throw new Error("Dispatching to widget not interested, should not happen."); + let d = widget.dispatch; + if(typeof(d) == "function" && idxidx == 0){ + return d.call(widget, value, oldval); + }else if(typeof(d) == "object" && d.length >= idxidx){ + return d[idxidx].call(widget, value, oldval); + }/* else dispatch_0, ..., dispatch_n ? */ + throw new Error("Dunno how to dispatch to widget at index = " + index); function dispatch_value(index, value) {
let widgets = subscribers[index];
@@ -10,19 +26,7 @@
for(let widget of widgets){
- let idxidx = widget.indexes.indexOf(index);
- throw new Error("Dispatching to widget not interested, should not happen.");
- let d = widget.dispatch;
- if(typeof(d) == "function" && idxidx == 0){
- return d.call(widget, value, oldval);
- }else if(typeof(d) == "object" && d.length >= idxidx){
- return d[idxidx].call(widget, value, oldval);
- }/* else dispatch_0, ..., dispatch_n ? */
- throw new Error("Dunno how to dispatch to widget at index = " + index);
+ dispatch_value_to_widget(widget, index, value, oldval); @@ -193,6 +197,10 @@
for(let widget of new_desc.widgets){
for(let index of widget.indexes){
subscribers[index].add(widget);
+ let cached_val = cache[index]; + if(cached_val != undefined) + dispatch_value_to_widget(widget, index, cached_val, cached_val); svg_root.setAttribute('viewBox',new_desc.bbox.join(" "));