2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

Fixing console.js for endless connections

git-svn-id: https://svn.fhem.de/fhem/trunk@2205 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-11-27 14:01:13 +00:00
parent fc480fccaf
commit 70c6ae03f7

View File

@ -3,18 +3,29 @@ var consConn;
function
consUpdate()
{
if(consConn.readyState != 4 || consConn.status != 200)
if(consConn.readyState == 4) {
var errdiv = document.createElement('div');
errdiv.innerHTML = "Connection lost, reconnecting in 5 seconds...";
errdiv.setAttribute("id","connect_err");
document.body.appendChild(errdiv);
setTimeout("consFill()", 5000);
return; // some problem connecting
}
if(consConn.readyState != 3)
return;
var el = document.getElementById("console");
if(el)
el.innerHTML=el.innerHTML+consConn.responseText;
consConn.abort();
consFill();
el.innerHTML="Events:<br>"+consConn.responseText;
}
function
consFill()
{
var errdiv = document.getElementById("connect_err");
if(errdiv)
document.body.removeChild(errdiv);
consConn = new XMLHttpRequest();
consConn.open("GET", document.location.pathname+"?XHR=1&inform=console", true);
consConn.onreadystatechange = consUpdate;