diff -r 30b0635fe92e -r 9771a724af09 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Mon Aug 03 18:22:19 2020 +0200 +++ b/svghmi/gen_index_xhtml.xslt Mon Aug 03 18:25:23 2020 +0200 @@ -1001,6 +1001,14 @@ + get_idx(index) { + + let orig = this.indexes[index]; + + return this.offset ? orig + this.offset : orig; + + } + } @@ -1188,7 +1196,7 @@ } - change_hmi_value(this.indexes[0], "=1"); + apply_hmi_value(this.get_idx(0), 1); }, @@ -1202,7 +1210,7 @@ } - change_hmi_value(this.indexes[0], "=0"); + apply_hmi_value(this.get_idx(0), 0); }, @@ -1437,11 +1445,7 @@ this.close(); - let orig = this.indexes[0]; - - let idx = this.offset ? orig - this.offset : orig; - - apply_hmi_value(idx, selection); + apply_hmi_value(this.get_idx(0), selection); }, @@ -1993,43 +1997,43 @@ - foreach_widgets_do(new_offset, todo){ + foreach_widgets_do(todo){ + + for(let i = 0; i < this.items.length; i++) { + + let item = this.items[i]; + + let orig_item_index = this.index_pool[i]; + + let item_index = this.index_pool[i+this.item_offset]; + + let item_index_offset = item_index - orig_item_index; + + for(let widget of item) { + + todo(widget).call(widget, this.offset + item_index_offset); + + } + + } + + } + + + + sub(new_offset=0){ this.offset = new_offset; - for(let i = 0; i < this.items.length; i++) { - - let item = this.items[i]; - - let orig_item_index = this.index_pool[i]; - - let item_index = this.index_pool[i+this.item_offset]; - - let item_index_offset = item_index - orig_item_index; - - for(let widget of item) { - - todo(widget).call(widget, new_offset + item_index_offset); - - } - - } + this.foreach_widgets_do(w=>w.sub); } - sub(new_offset=0){ - - this.foreach_widgets_do(new_offset, w=>w.sub); - - } - - - apply_cache() { - this.foreach_widgets_do(this.offset, w=>w.apply_cache); + this.foreach_widgets_do(w=>w.apply_cache); } @@ -2134,11 +2138,7 @@ on_op_click: function(opstr) { - let orig = this.indexes[0]; - - let idx = this.offset ? orig - this.offset : orig; - - let new_val = change_hmi_value(idx, opstr); + let new_val = change_hmi_value(this.get_idx(0), opstr); }, @@ -2154,11 +2154,7 @@ edit_callback: function(new_val) { - let orig = this.indexes[0]; - - let idx = this.offset ? orig - this.offset : orig; - - apply_hmi_value(idx, new_val); + apply_hmi_value(this.get_idx(0), new_val); }, @@ -3413,7 +3409,7 @@ dispatch: function(value) { - change_hmi_value(heartbeat_index, "+1"); + apply_hmi_value(heartbeat_index, value+1); }