2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-30 18:12:28 +00:00

fhemweb.js: enabe XHR switching for tablet/smallscreen (Forum #38045)

git-svn-id: https://svn.fhem.de/fhem/trunk@8734 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-06-12 17:02:39 +00:00
parent 2c94795bb5
commit 2510bd6f94

View File

@ -54,7 +54,7 @@ FW_jqueryReadyFn()
if(document.body.getAttribute("longpoll")) if(document.body.getAttribute("longpoll"))
setTimeout("FW_longpoll()", 100); setTimeout("FW_longpoll()", 100);
$("a[href]").each(function() { FW_replaceLink(this); }) $("a").each(function() { FW_replaceLink(this); })
$("head script").each(function() { $("head script").each(function() {
var sname = $(this).attr("src"), var sname = $(this).attr("src"),
p = FW_scripts[sname]; p = FW_scripts[sname];
@ -270,7 +270,7 @@ FW_okDialog(txt, parent)
}); });
FW_replaceWidgets(div); 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) if(parent)
$(div).dialog( "option", "position", { $(div).dialog( "option", "position", {
@ -339,10 +339,18 @@ function
FW_replaceLink(el) FW_replaceLink(el)
{ {
var attr = $(el).attr("href"); 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[^=]*=.*)$/); var ma = attr.match(/^(.*\?)(cmd[^=]*=.*)$/);
if(ma == null || ma.length == 0 || !ma[2].match(/=(save|set)/)) if(ma == null || ma.length == 0 || !ma[2].match(/=(save|set)/))
return; return;
$(el).removeAttr("href"); $(el).removeAttr("href");
$(el).removeAttr("onclick");
$(el).click(function() { FW_cmd(attr+"&XHR=1"); }); $(el).click(function() { FW_cmd(attr+"&XHR=1"); });
$(el).css("cursor", "pointer"); $(el).css("cursor", "pointer");
} }
@ -397,7 +405,7 @@ FW_doUpdate()
$(this).html(d[2]); // Readings-Value $(this).html(d[2]); // Readings-Value
if(d[0].match(/-ts$/)) // timestamps if(d[0].match(/-ts$/)) // timestamps
$(this).addClass('changed'); $(this).addClass('changed');
$(this).find("a[href]").each(function() { FW_replaceLink(this) }); $(this).find("a").each(function() { FW_replaceLink(this) });
} }
}); });
} }