mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
01_FHEMWEB.pm: multi-line devStateIcon patch from justme1968 (Forum #97586)
git-svn-id: https://svn.fhem.de/fhem/trunk@18650 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
55103443ca
commit
e137fec533
@ -3177,65 +3177,70 @@ FW_devState($$@)
|
|||||||
$cmdList = "desiredTemperature" if(!$cmdList);
|
$cmdList = "desiredTemperature" if(!$cmdList);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
my ($icon, $isHtml);
|
my $html;
|
||||||
($icon, $link, $isHtml) = FW_dev2image($d);
|
foreach my $state (split("\n", $state)) {
|
||||||
$txt = ($isHtml ? $icon : FW_makeImage($icon, $state)) if($icon);
|
$txt = $state;
|
||||||
|
my ($icon, $isHtml);
|
||||||
|
($icon, $link, $isHtml) = FW_dev2image($d,$state);
|
||||||
|
$txt = ($isHtml ? $icon : FW_makeImage($icon, $state)) if($icon);
|
||||||
|
|
||||||
my $cmdlist = (defined($link) ? $link : "");
|
my $cmdlist = (defined($link) ? $link : "");
|
||||||
my $h = "";
|
my $h = "";
|
||||||
foreach my $cmd (split(":", $cmdlist)) {
|
foreach my $cmd (split(":", $cmdlist)) {
|
||||||
my $htmlTxt;
|
my $htmlTxt;
|
||||||
my @c = split(' ', $cmd); # @c==0 if $cmd==" ";
|
my @c = split(' ', $cmd); # @c==0 if $cmd==" ";
|
||||||
if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) {
|
if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) {
|
||||||
my $values = $1;
|
my $values = $1;
|
||||||
foreach my $fn (sort keys %{$data{webCmdFn}}) {
|
foreach my $fn (sort keys %{$data{webCmdFn}}) {
|
||||||
no strict "refs";
|
no strict "refs";
|
||||||
$htmlTxt = &{$data{webCmdFn}{$fn}}($FW_wname,
|
$htmlTxt = &{$data{webCmdFn}{$fn}}($FW_wname,
|
||||||
$d, $FW_room, $cmd, $values);
|
$d, $FW_room, $cmd, $values);
|
||||||
use strict "refs";
|
use strict "refs";
|
||||||
last if(defined($htmlTxt));
|
last if(defined($htmlTxt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( $htmlTxt ) {
|
||||||
|
$h .= "<p>$htmlTxt</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $htmlTxt ) {
|
if( $h ) {
|
||||||
$h .= "<p>$htmlTxt</p>";
|
$link = undef;
|
||||||
}
|
$h =~ s/'/\\"/g;
|
||||||
}
|
$txt = "<a onClick='FW_okDialog(\"$h\",this)'\>$txt</a>";
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($hasOnOff) {
|
|
||||||
my $isUpperCase = ($allSets =~ m/(^| )ON(:[^ ]*)?( |$)/ &&
|
|
||||||
$allSets =~ m/(^| )OFF(:[^ ]*)?( |$)/);
|
|
||||||
# Have to cover: "on:An off:Aus", "A0:Aus AI:An Aus:off An:on"
|
|
||||||
my $on = ReplaceEventMap($d, $isUpperCase ? "ON" :"on" , 1);
|
|
||||||
my $off = ReplaceEventMap($d, $isUpperCase ? "OFF":"off", 1);
|
|
||||||
$link = "cmd.$d=set $d " . ($state eq $on ? $off : $on) if(!defined($link));
|
|
||||||
$cmdList = "$on:$off" if(!$cmdList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined($link)) { # Have command to execute
|
|
||||||
my $room = AttrVal($d, "room", undef);
|
|
||||||
if($room) {
|
|
||||||
if($FW_room && $room =~ m/\b$FW_room\b/) {
|
|
||||||
$room = $FW_room;
|
|
||||||
} else {
|
} else {
|
||||||
$room =~ s/,.*//;
|
$link = "cmd.$d=set $d $link" if(defined($link));
|
||||||
}
|
}
|
||||||
$link .= "&room=".urlEncode($room);
|
|
||||||
|
if($hasOnOff) {
|
||||||
|
my $isUpperCase = ($allSets =~ m/(^| )ON(:[^ ]*)?( |$)/ &&
|
||||||
|
$allSets =~ m/(^| )OFF(:[^ ]*)?( |$)/);
|
||||||
|
# Have to cover: "on:An off:Aus", "A0:Aus AI:An Aus:off An:on"
|
||||||
|
my $on = ReplaceEventMap($d, $isUpperCase ? "ON" :"on" , 1);
|
||||||
|
my $off = ReplaceEventMap($d, $isUpperCase ? "OFF":"off", 1);
|
||||||
|
$link = "cmd.$d=set $d " . ($state eq $on ? $off : $on)
|
||||||
|
if(!defined($link));
|
||||||
|
$cmdList = "$on:$off" if(!$cmdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defined($link)) { # Have command to execute
|
||||||
|
my $room = AttrVal($d, "room", undef);
|
||||||
|
if($room) {
|
||||||
|
if($FW_room && $room =~ m/\b$FW_room\b/) {
|
||||||
|
$room = $FW_room;
|
||||||
|
} else {
|
||||||
|
$room =~ s/,.*//;
|
||||||
|
}
|
||||||
|
$link .= "&room=".urlEncode($room);
|
||||||
|
}
|
||||||
|
$txt = "<a href=\"$FW_ME$FW_subdir?$link$rf$FW_CSRF\">$txt</a>"
|
||||||
|
if($link !~ m/ noFhemwebLink\b/);
|
||||||
|
}
|
||||||
|
$html .= ' ' if( $html );
|
||||||
|
$html .= $txt;
|
||||||
}
|
}
|
||||||
$txt = "<a href=\"$FW_ME$FW_subdir?$link$rf$FW_CSRF\">$txt</a>"
|
$txt = $html;
|
||||||
if($link !~ m/ noFhemwebLink\b/);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $style = AttrVal($d, "devStateStyle", "");
|
my $style = AttrVal($d, "devStateStyle", "");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user