From d676669d36cd9588761e8d00986d426a5380c4a1 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 10 Feb 2014 20:37:16 +0000 Subject: [PATCH] fhemweb.js: replace webCmd a/href links in longpoll mode with XHR calls. git-svn-id: https://svn.fhem.de/fhem/trunk@4878 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/fhemweb.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fhem/www/pgm2/fhemweb.js b/fhem/www/pgm2/fhemweb.js index 72006c1a4..ddc8ce8b1 100644 --- a/fhem/www/pgm2/fhemweb.js +++ b/fhem/www/pgm2/fhemweb.js @@ -124,10 +124,26 @@ FW_longpoll() 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 FW_delayedStart() { setTimeout("FW_longpoll()", 100); + FW_replaceLinks(); } /*************** LONGPOLL END **************/