2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

01_FHEMWEB.pm/fhemweb.js: move confirmJSError to body, "patch" FWEXT/CONTENTFUNC data with attributes, to enable confirmJSError in FLOORPLAN and other modules

git-svn-id: https://svn.fhem.de/fhem/trunk@13263 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-01-28 19:22:27 +00:00
parent 1612f0e0f6
commit e255bcd813
2 changed files with 19 additions and 10 deletions

View File

@ -852,6 +852,13 @@ FW_answerCall($)
#Returns undef as FW_RETTYPE if it already sent a HTTP header
no strict "refs";
($FW_RETTYPE, $FW_RET) = &{$h->{FUNC}}($arg);
if(defined($FW_RETTYPE) && $FW_RETTYPE =~ m,text/html,) {
my $dataAttr =
"data-confirmDelete='" .AttrVal($FW_wname,"confirmDelete",1) ."' ".
"data-confirmJSError='".AttrVal($FW_wname,"confirmJSError",1)."' ".
"data-webName='$FW_wname '";
$FW_RET =~ s/<body/<body $dataAttr/;
}
use strict "refs";
return defined($FW_RETTYPE) ? 0 : -1;
}
@ -971,7 +978,12 @@ FW_answerCall($)
my $gen = 'generated="'.(time()-1).'"';
my $lp = 'longpoll="'.AttrVal($FW_wname,"longpoll",1).'"';
$FW_id = $FW_chash->{NR} if( !$FW_id );
FW_pO "</head>\n<body name=\"$t\" fw_id=\"$FW_id\" $gen $lp $csrf>";
my $dataAttr =
"data-confirmDelete='" .AttrVal($FW_wname,"confirmDelete",1) ."' ".
"data-confirmJSError='".AttrVal($FW_wname,"confirmJSError",1)."' ".
"data-webName='$FW_wname '";
FW_pO "</head>\n<body name='$t' fw_id='$FW_id' $gen $lp $csrf $dataAttr>";
if($FW_activateInform) {
$cmd = "style eventMonitor $FW_activateInform";
@ -1037,10 +1049,7 @@ sub
FW_addContent(;$)
{
my $add = ($_[0] ? " $_[0]" : "");
FW_pO "<div id='content' ".
"data-confirmDelete='" .AttrVal($FW_wname,"confirmDelete",1) ."' ".
"data-confirmJSError='".AttrVal($FW_wname,"confirmJSError",1)."' ".
"data-webName='$FW_wname'$add>";
FW_pO "<div id='content' $add>";
}
sub

View File

@ -35,7 +35,7 @@ window.onbeforeunload = function(e)
window.onerror = function(errMsg, url, lineno)
{
url = url.replace(/.*\//,'');
if($("div#content").attr("data-confirmJSError") != 0)
if($("body").attr("data-confirmJSError") != 0)
FW_okDialog(url+" line "+lineno+":<br>"+errMsg);
}
@ -252,12 +252,12 @@ FW_filterIcons()
function
FW_confirmDelete()
{
var d = $("div#content");
var cd = $(d).attr("data-confirmDelete");
var b = $("body");
var cd = $(b).attr("data-confirmDelete");
if(!cd || cd == 0)
return;
var wn = $(d).attr("data-webName");
$(d).find("a").each(function(){
var wn = $(b).attr("data-webName");
$("div#content").find("a").each(function(){
var href = $(this).attr("href");
if(!href)
return;