From 4d10fd49733d0e1dae7d1b2663a16e4ed722c45c Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Fri, 12 Jun 2015 17:02:39 +0000 Subject: [PATCH] fhemweb.js: enabe XHR switching for tablet/smallscreen (Forum #38045) git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8734 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/fhemweb.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fhem/www/pgm2/fhemweb.js b/fhem/www/pgm2/fhemweb.js index 6513b8f1e..6a4b87480 100644 --- a/fhem/www/pgm2/fhemweb.js +++ b/fhem/www/pgm2/fhemweb.js @@ -54,7 +54,7 @@ FW_jqueryReadyFn() if(document.body.getAttribute("longpoll")) setTimeout("FW_longpoll()", 100); - $("a[href]").each(function() { FW_replaceLink(this); }) + $("a").each(function() { FW_replaceLink(this); }) $("head script").each(function() { var sname = $(this).attr("src"), p = FW_scripts[sname]; @@ -270,7 +270,7 @@ FW_okDialog(txt, parent) }); FW_replaceWidgets(div); - $(div).find("a[href]").each(function(){FW_replaceLink(this);}); //Forum #33766 + $(div).find("a").each(function(){FW_replaceLink(this);}); //Forum #33766 if(parent) $(div).dialog( "option", "position", { @@ -339,10 +339,18 @@ function FW_replaceLink(el) { var attr = $(el).attr("href"); + if(!attr) { + attr = $(el).attr("onclick"); // Tablet/smallScreen version + if(!attr) + return; + attr = attr.replace(/^location.href='/,''); + attr = attr.replace(/'$/,''); + } var ma = attr.match(/^(.*\?)(cmd[^=]*=.*)$/); if(ma == null || ma.length == 0 || !ma[2].match(/=(save|set)/)) return; $(el).removeAttr("href"); + $(el).removeAttr("onclick"); $(el).click(function() { FW_cmd(attr+"&XHR=1"); }); $(el).css("cursor", "pointer"); } @@ -397,7 +405,7 @@ FW_doUpdate() $(this).html(d[2]); // Readings-Value if(d[0].match(/-ts$/)) // timestamps $(this).addClass('changed'); - $(this).find("a[href]").each(function() { FW_replaceLink(this) }); + $(this).find("a").each(function() { FW_replaceLink(this) }); } }); }