2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

contrib/InfoPanel: updated

added: include for layout files
fixed: error in <rect>

git-svn-id: https://svn.fhem.de/fhem/trunk@7755 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2015-01-28 12:34:47 +00:00
parent db0009fea0
commit 14c5871ea0

View File

@ -99,6 +99,7 @@ sub btIP_Define($$) {
$hash->{NOTIFYDEV} = 'global'; $hash->{NOTIFYDEV} = 'global';
$hash->{fhem}{hostname}= $hostname; $hash->{fhem}{hostname}= $hostname;
$hash->{fhem}{filename}= $filename; $hash->{fhem}{filename}= $filename;
$hash->{fhem}{div} = '';
$hash->{LAYOUTFILE} = $filename; $hash->{LAYOUTFILE} = $filename;
btIP_readLayout($hash); btIP_readLayout($hash);
@ -145,7 +146,22 @@ sub btIP_readLayout($) {
Log 1, "InfoPanel $name: $err"; Log 1, "InfoPanel $name: $err";
$hash->{fhem}{layout}= ("text 0.1 0.1 'Error: $err'"); $hash->{fhem}{layout}= ("text 0.1 0.1 'Error: $err'");
} else { } else {
$hash->{fhem}{layout}= join("\n", @layoutfile); $hash->{fhem}{layout} = join("\n", @layoutfile);
while($hash->{fhem}{layout} =~ m/\@include/ ) {
my (@layout2,@include);
foreach my $ll (@layoutfile) {
if($ll !~ m/^\@include/) {
push(@layout2,$ll);
} else {
my ($cmd, $def)= split("[ \t]+", $ll, 2);
($err,@include) = FileRead($def) if($def);
splice(@layout2,-1,0,@include) unless $err;
}
}
@layoutfile = @layout2;
@layout2 = undef;
$hash->{fhem}{layout} = join("\n",@layoutfile);
}
$hash->{fhem}{layout} =~ s/\n\n/\n/g; $hash->{fhem}{layout} =~ s/\n\n/\n/g;
} }
return; return;
@ -580,6 +596,7 @@ sub btIP_evalLayout($$@) {
chomp $line; chomp $line;
# kill comments and blank lines # kill comments and blank lines
$line=~ s/\#.*$//; $line=~ s/\#.*$//;
$line=~ s/\@.*$//;
$line=~ s/\s+$//; $line=~ s/\s+$//;
$line= $cont . $line; $line= $cont . $line;
if($line=~ s/\\$//) { $cont= $line; undef $line; } if($line=~ s/\\$//) { $cont= $line; undef $line; }
@ -650,7 +667,7 @@ sub btIP_evalLayout($$@) {
when("group") { when("group") {
($id,$text,$arg) = split("[ \t]+", $def, 3); ($id,$text,$arg) = split("[ \t]+", $def, 3);
my $arg = AnalyzePerlCommand(undef, $arg); my $arg = AnalyzePerlCommand(undef, $arg) if($arg);
$svg .= btIP_itemGroup($id,$text,$arg); $svg .= btIP_itemGroup($id,$text,$arg);
} }
@ -748,6 +765,7 @@ sub btIP_evalLayout($$@) {
($id,$x,$y,$boxwidth,$boxheight,$text)= split("[ \t]+", $def, 6); ($id,$x,$y,$boxwidth,$boxheight,$text)= split("[ \t]+", $def, 6);
($x,$y)= btIP_xy($x,$y,%params); ($x,$y)= btIP_xy($x,$y,%params);
my $txt= AnalyzePerlCommand(undef, $text); my $txt= AnalyzePerlCommand(undef, $text);
$txt =~ s/\n/<br\/>/g;
my $name = $params{name}; my $name = $params{name};
$svg .= btIP_itemTextBox($id,$x,$y,$boxwidth,$boxheight,$txt,%params); $svg .= btIP_itemTextBox($id,$x,$y,$boxwidth,$boxheight,$txt,%params);
$params{xx} = $x; $params{xx} = $x;
@ -761,7 +779,9 @@ sub btIP_evalLayout($$@) {
$params{yy} = $y; $params{yy} = $y;
$svg .= btIP_itemTime($id,$x,$y,%params); $svg .= btIP_itemTime($id,$x,$y,%params);
} }
when('@include') {}
default { default {
if($cmd ~~ @cmd_halign) { if($cmd ~~ @cmd_halign) {
my $d = AnalyzePerlCommand(undef, $def); my $d = AnalyzePerlCommand(undef, $def);
@ -864,11 +884,9 @@ sub btIP_returnHTML($) {
$code .= "<body topmargin=\"0\" leftmargin=\"0\" margin=\"0\" padding=\"0\">\n". $code .= "<body topmargin=\"0\" leftmargin=\"0\" margin=\"0\" padding=\"0\">\n".
"<div id=\"svg_content\" z-index=\"1\" >\n". "<div id=\"svg_content\" z-index=\"1\" >\n".
btIP_returnSVG($name). btIP_returnSVG($name)."\n</div>\n";
"\n</div>\n". $code .= $defs{$name}{fhem}{div} if($defs{$name}{fhem}{div});
$defs{$name}{fhem}{div}. $code .= "</body>\n".btIP_HTMLTail();
"</body>\n".
btIP_HTMLTail();
return ("text/html; charset=utf-8", $code); return ("text/html; charset=utf-8", $code);
} }