diff --git a/www/pgm2/fhemweb.js b/www/pgm2/fhemweb.js index e4a7a2ec8..25472e376 100644 --- a/www/pgm2/fhemweb.js +++ b/www/pgm2/fhemweb.js @@ -928,6 +928,32 @@ FW_doUpdate(evt) var retryTime = 5000; var now = new Date()/1000; + function + setValue(d) // is Callable from eval below + { + $("[informId='"+d[0]+"']").each(function(){ + if(this.setValueFn) { // change the select/etc value + this.setValueFn(d[1].replace(/\n/g, '\u2424')); + + } else { + if(d[2].match(/\n/) && !d[2].match(/<.*>/)) // format multiline + d[2] = '
'+d[2]+'
'; + + var ma = /^([\s\S]*)<\/html>$/.exec(d[2]); + if(!d[0].match("-")) // not a reading + $(this).html(d[2]); + else if(ma) + $(this).html(ma[1]); + else + $(this).text(d[2]); + + if(d[0].match(/-ts$/)) // timestamps + $(this).addClass('changed'); + $(this).find("a").each(function() { FW_replaceLink(this) }); + } + }); + } + // iOS closes HTTP after 60s idle, websocket after 240s idle if(now-FW_lastDataTime > 59) { errstr=""; @@ -989,32 +1015,6 @@ FW_doUpdate(evt) if(d.length != 3) continue; - function - setValue(d) // is Callable from eval below - { - $("[informId='"+d[0]+"']").each(function(){ - if(this.setValueFn) { // change the select/etc value - this.setValueFn(d[1].replace(/\n/g, '\u2424')); - - } else { - if(d[2].match(/\n/) && !d[2].match(/<.*>/)) // format multiline - d[2] = '
'+d[2]+'
'; - - var ma = /^([\s\S]*)<\/html>$/.exec(d[2]); - if(!d[0].match("-")) // not a reading - $(this).html(d[2]); - else if(ma) - $(this).html(ma[1]); - else - $(this).text(d[2]); - - if(d[0].match(/-ts$/)) // timestamps - $(this).addClass('changed'); - $(this).find("a").each(function() { FW_replaceLink(this) }); - } - }); - } - if( d[0].match(/^#FHEMWEB:/) ) { eval(d[1]);