mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 16:46:35 +00:00
fhemweb.js: add devStateIcon okDialog widgets (Forum #33766)
git-svn-id: https://svn.fhem.de/fhem/trunk@8003 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
92bfd5c3ac
commit
e2ebe0a371
@ -2404,7 +2404,7 @@ FW_devState($$@)
|
||||
my ($hasOnOff, $link);
|
||||
|
||||
my $cmdList = AttrVal($d, "webCmd", "");
|
||||
my $allSets = getAllSets($d);
|
||||
my $allSets = FW_widgetOverride($d, getAllSets($d));
|
||||
my $state = $defs{$d}{STATE};
|
||||
$state = "" if(!defined($state));
|
||||
|
||||
@ -2431,7 +2431,35 @@ FW_devState($$@)
|
||||
my ($icon, $isHtml);
|
||||
($icon, $link, $isHtml) = FW_dev2image($d);
|
||||
$txt = ($isHtml ? $icon : FW_makeImage($icon, $state)) if($icon);
|
||||
$link = "cmd.$d=set $d $link" if(defined($link));
|
||||
|
||||
my $cmdlist = $link // "";
|
||||
my $h = "";
|
||||
foreach my $cmd (split(":", $cmdlist)) {
|
||||
my $htmlTxt;
|
||||
my @c = split(' ', $cmd); # @c==0 if $cmd==" ";
|
||||
if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) {
|
||||
my $values = $1;
|
||||
foreach my $fn (sort keys %{$data{webCmdFn}}) {
|
||||
no strict "refs";
|
||||
$htmlTxt = &{$data{webCmdFn}{$fn}}($FW_wname,
|
||||
$d, $FW_room, $cmd, $values);
|
||||
use strict "refs";
|
||||
last if(defined($htmlTxt));
|
||||
}
|
||||
}
|
||||
|
||||
if( $htmlTxt ) {
|
||||
$h .= "<p>$htmlTxt</p>";
|
||||
}
|
||||
}
|
||||
|
||||
if( $h ) {
|
||||
$link = undef;
|
||||
$h =~ s/'/\\"/g;
|
||||
$txt = "<a onClick='FW_okDialog(\"$h\",this)'\>$txt</a>";
|
||||
} else {
|
||||
$link = "cmd.$d=set $d $link" if(defined($link));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,23 @@ window.onbeforeunload = function(e)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function
|
||||
FW_replaceWidgets(parent)
|
||||
{
|
||||
parent.find("div.fhemWidget").each(function() {
|
||||
var dev=$(this).attr("dev");
|
||||
var cmd=$(this).attr("cmd");
|
||||
var rd=$(this).attr("reading");
|
||||
var params = cmd.split(" ");
|
||||
FW_replaceWidget(this, dev, $(this).attr("arg").split(","),
|
||||
$(this).attr("current"), rd, params[0], params.slice(1),
|
||||
function(arg) {
|
||||
FW_cmd(FW_root+"?cmd=set "+dev+(params[0]=="state" ? "":" "+params[0])+
|
||||
" "+arg+"&XHR=1");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function
|
||||
FW_jqueryReadyFn()
|
||||
{
|
||||
@ -67,19 +84,8 @@ FW_jqueryReadyFn()
|
||||
var r = $("head").attr("root");
|
||||
if(r)
|
||||
FW_root = r;
|
||||
$("div.fhemWidget").each(function() {
|
||||
var dev=$(this).attr("dev");
|
||||
var cmd=$(this).attr("cmd");
|
||||
var rd=$(this).attr("reading");
|
||||
var params = cmd.split(" ");
|
||||
FW_replaceWidget(this, dev, $(this).attr("arg").split(","),
|
||||
$(this).attr("current"), rd, params[0], params.slice(1),
|
||||
function(arg) {
|
||||
FW_cmd(FW_root+"?cmd=set "+dev+(params[0]=="state" ? "":" "+params[0])+
|
||||
" "+arg+"&XHR=1");
|
||||
});
|
||||
});
|
||||
|
||||
FW_replaceWidgets($("html"));
|
||||
|
||||
// Fix the td count by setting colspan on the last column
|
||||
$("table.block.wide").each(function(){ // table
|
||||
@ -115,8 +121,9 @@ FW_jqueryReadyFn()
|
||||
$("#saveCheck")
|
||||
.css("cursor", "pointer")
|
||||
.click(function(){
|
||||
var parent = this;
|
||||
FW_cmd(FW_root+"?cmd=save ?&XHR=1", function(data) {
|
||||
FW_okDialog('<pre>'+data+'</pre>');
|
||||
FW_okDialog('<pre>'+data+'</pre>',parent);
|
||||
});
|
||||
});
|
||||
|
||||
@ -217,7 +224,7 @@ FW_errmsg(txt, timeout)
|
||||
}
|
||||
|
||||
function
|
||||
FW_okDialog(txt)
|
||||
FW_okDialog(txt, parent)
|
||||
{
|
||||
var div = $("<div id='FW_okDialog'>");
|
||||
$(div).html(txt);
|
||||
@ -230,6 +237,14 @@ FW_okDialog(txt)
|
||||
$(div).remove();
|
||||
}}]
|
||||
});
|
||||
|
||||
FW_replaceWidgets(div);
|
||||
|
||||
if(parent)
|
||||
$(div).dialog( "option", "position", {
|
||||
my: "left top", at: "right bottom",
|
||||
of: parent, collision: "flipfit"
|
||||
});
|
||||
}
|
||||
|
||||
function
|
||||
|
Loading…
x
Reference in New Issue
Block a user