diff -r 48e7e336c052 -r d454ed480c0f svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Aug 13 11:30:18 2020 +0200 +++ b/svghmi/gen_index_xhtml.xslt Thu Aug 13 11:37:39 2020 +0200 @@ -1141,29 +1141,101 @@ apply_cache() { + if(!this.unsubscribable) for(let index in this.indexes){ + + /* dispatch current cache in newly opened page widgets */ + + let realindex = this.get_variable_index(index); + + let cached_val = cache[realindex]; + + if(cached_val != undefined) + + this._dispatch(cached_val, cached_val, index); + + } + + } + + + + get_variable_index(varnum) { + + let index = this.indexes[varnum]; + + if(typeof(index) == "string"){ + + index = page_local_index(index, this.container_id); + + } else { + + if(this.relativeness[varnum]){ + + index += this.offset; + + } + + } + + return index; + + } + + change_hmi_value(index,opstr) { + + return change_hmi_value(this.get_variable_index(index), opstr); + + } + + + + apply_hmi_value(index, new_val) { + + return apply_hmi_value(this.get_variable_index(0), new_val); + + } + + + + new_hmi_value(index, value, oldval) { + + // TODO avoid searching, store index at sub() + + for(let i = 0; i < this.indexes.length; i++) { + + let refindex = this.get_variable_index(i); + + + + if(index == refindex) { + + this._dispatch(value, oldval, i); + + break; + + } + + } + + } + + + + _dispatch(value, oldval, varnum) { + let dispatch = this.dispatch; - if(dispatch == undefined) return; - - if(!this.unsubscribable) for(let index in this.indexes){ - - /* dispatch current cache in newly opened page widgets */ - - let realindex = this.get_variable_index(index); - - let cached_val = cache[realindex]; - - if(cached_val != undefined) - - try { - - dispatch.call(this, cached_val, cached_val, index); - - } catch(err) { - - console.log(err); - - } + if(dispatch != undefined){ + + try { + + dispatch.call(this, value, oldval, varnum); + + } catch(err) { + + console.log(err); + + } } @@ -1171,80 +1243,6 @@ - get_variable_index(varnum) { - - let index = this.indexes[varnum]; - - if(typeof(index) == "string"){ - - index = page_local_index(index, this.container_id); - - } else { - - if(this.relativeness[varnum]){ - - index += this.offset; - - } - - } - - return index; - - } - - change_hmi_value(index,opstr) { - - return change_hmi_value(this.get_variable_index(index), opstr); - - } - - - - apply_hmi_value(index, new_val) { - - return apply_hmi_value(this.get_variable_index(0), new_val); - - } - - - - new_hmi_value(index, value, oldval) { - - // TODO avoid searching, store index at sub() - - let dispatch = this.dispatch; - - if(dispatch == undefined) return; - - for(let i = 0; i < this.indexes.length; i++) { - - let refindex = this.get_variable_index(i); - - - - if(index == refindex) { - - try { - - dispatch.call(this, value, oldval, i); - - } catch(err) { - - console.log(err); - - } - - break; - - } - - } - - } - - - _animate(){ this.animate();