fhemweb.js: replace webCmd a/href links in longpoll mode with XHR calls.

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@4878 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-02-10 20:37:16 +00:00
parent 9243f3c548
commit 24eb1f7dad

View File

@ -124,10 +124,26 @@ FW_longpoll()
FW_pollConn.send(null); FW_pollConn.send(null);
} }
function
FW_replaceLinks()
{
var elArr = document.querySelectorAll("a[href]");
for(var i1=0; i1< elArr.length; i1++) {
var a = elArr[i1];
var ma = a.getAttribute("href").match(/^(.*\?)(cmd[^=]*=.*)$/);
if(ma == null || ma.length == 0 || ma[2].match(/=style/))
continue;
a.removeAttribute("href");
a.setAttribute("onclick", "FW_cmd('"+ma[1]+"XHR=1&"+ma[2]+"')");
a.setAttribute("style", "cursor:pointer");
}
}
function function
FW_delayedStart() FW_delayedStart()
{ {
setTimeout("FW_longpoll()", 100); setTimeout("FW_longpoll()", 100);
FW_replaceLinks();
} }
/*************** LONGPOLL END **************/ /*************** LONGPOLL END **************/