mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 12:58:13 +00:00
55_InfoPanel.pm: code cleanup
- code cleanup - added template layout git-svn-id: https://svn.fhem.de/fhem/trunk@7948 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
654e5abd66
commit
3a21a94335
@ -49,11 +49,11 @@ sub btIP_itemTextBox;
|
|||||||
sub btIP_itemTime;
|
sub btIP_itemTime;
|
||||||
sub btIP_itemTrash;
|
sub btIP_itemTrash;
|
||||||
|
|
||||||
|
sub btIP_changeColor;
|
||||||
sub btIP_color;
|
sub btIP_color;
|
||||||
|
sub btIP_FileRead;
|
||||||
sub btIP_findTarget;
|
sub btIP_findTarget;
|
||||||
sub btIP_xy;
|
sub btIP_xy;
|
||||||
sub btIP_changeColor;
|
|
||||||
sub btIP_FileRead;
|
|
||||||
|
|
||||||
sub btIP_ReturnSVG;
|
sub btIP_ReturnSVG;
|
||||||
sub btIP_evalLayout;
|
sub btIP_evalLayout;
|
||||||
@ -443,6 +443,8 @@ sub btIP_itemRect {
|
|||||||
($link,$target) = btIP_findTarget($link);
|
($link,$target) = btIP_findTarget($link);
|
||||||
my $width = $x2 - $x1;
|
my $width = $x2 - $x1;
|
||||||
my $height = $y2 - $y1;
|
my $height = $y2 - $y1;
|
||||||
|
$filled //= 0;
|
||||||
|
$stroked //= 0;
|
||||||
my $output = "";
|
my $output = "";
|
||||||
$output .= "<a id=\”${id}_link\” xlink:href=\"$link\" target=\"$target\">\n" if($link && length($link));
|
$output .= "<a id=\”${id}_link\” xlink:href=\"$link\" target=\"$target\">\n" if($link && length($link));
|
||||||
$output .= "<rect id=\”${id}_rect\” x=\"$x1\" y=\"$y1\" width=\"$width\" height=\"$height\" rx=\"$rx\" ry=\"$ry\" ";
|
$output .= "<rect id=\”${id}_rect\” x=\"$x1\" y=\"$y1\" width=\"$width\" height=\"$height\" rx=\"$rx\" ry=\"$ry\" ";
|
||||||
@ -588,35 +590,6 @@ $data = '<?xml version="1.0" encoding="utf-8"?>'.
|
|||||||
|
|
||||||
##### Helper
|
##### Helper
|
||||||
|
|
||||||
sub btIP_color {
|
|
||||||
my ($rgb)= @_;
|
|
||||||
my $alpha = 1;
|
|
||||||
my @d= split("", $rgb);
|
|
||||||
if(length($rgb) == 8) {
|
|
||||||
$alpha = hex("$d[6]$d[7]");
|
|
||||||
$alpha = $alpha/255;
|
|
||||||
}
|
|
||||||
return (hex("$d[0]$d[1]"),hex("$d[2]$d[3]"),hex("$d[4]$d[5]"),$alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub btIP_findTarget {
|
|
||||||
my ($link) = shift;
|
|
||||||
my $target = 'secret';
|
|
||||||
$target = '_top' if $link =~ s/^-//;
|
|
||||||
$target = '_blank' if $link =~ s/^\+//;
|
|
||||||
return ($link,$target);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub btIP_xy {
|
|
||||||
my ($x,$y,%params)= @_;
|
|
||||||
|
|
||||||
$x = $params{xx} if($x eq 'x');
|
|
||||||
$y = $params{yy} if($y eq 'y');
|
|
||||||
if((-1 < $x) && ($x < 1)) { $x *= $params{width}; }
|
|
||||||
if((-1 < $y) && ($y < 1)) { $y *= $params{height}; }
|
|
||||||
return($x,$y);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub btIP_changeColor {
|
sub btIP_changeColor {
|
||||||
my($file,$oldcolor,$newcolor) = @_;
|
my($file,$oldcolor,$newcolor) = @_;
|
||||||
Log3(undef,4,"InfoPanel: read file $file for changeColor");
|
Log3(undef,4,"InfoPanel: read file $file for changeColor");
|
||||||
@ -632,6 +605,17 @@ sub btIP_changeColor {
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub btIP_color {
|
||||||
|
my ($rgb)= @_;
|
||||||
|
my $alpha = 1;
|
||||||
|
my @d= split("", $rgb);
|
||||||
|
if(length($rgb) == 8) {
|
||||||
|
$alpha = hex("$d[6]$d[7]");
|
||||||
|
$alpha = $alpha/255;
|
||||||
|
}
|
||||||
|
return (hex("$d[0]$d[1]"),hex("$d[2]$d[3]"),hex("$d[4]$d[5]"),$alpha);
|
||||||
|
}
|
||||||
|
|
||||||
sub btIP_FileRead {
|
sub btIP_FileRead {
|
||||||
my ($file) = @_;
|
my ($file) = @_;
|
||||||
my ($data,$counter);
|
my ($data,$counter);
|
||||||
@ -658,6 +642,24 @@ sub btIP_FileRead {
|
|||||||
return ($counter,$data);
|
return ($counter,$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub btIP_findTarget {
|
||||||
|
my ($link) = shift;
|
||||||
|
my $target = 'secret';
|
||||||
|
$target = '_top' if $link =~ s/^-//;
|
||||||
|
$target = '_blank' if $link =~ s/^\+//;
|
||||||
|
return ($link,$target);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub btIP_xy {
|
||||||
|
my ($x,$y,%params)= @_;
|
||||||
|
|
||||||
|
$x = $params{xx} if($x eq 'x');
|
||||||
|
$y = $params{yy} if($y eq 'y');
|
||||||
|
if((-1 < $x) && ($x < 1)) { $x *= $params{width}; }
|
||||||
|
if((-1 < $y) && ($y < 1)) { $y *= $params{height}; }
|
||||||
|
return($x,$y);
|
||||||
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
#
|
#
|
||||||
# create SVG content
|
# create SVG content
|
||||||
@ -759,8 +761,8 @@ sub btIP_evalLayout {
|
|||||||
my ($width,$height)= split(/x/, AttrVal($name,"size","800x600"));
|
my ($width,$height)= split(/x/, AttrVal($name,"size","800x600"));
|
||||||
my @layout= split("\n", $layout);
|
my @layout= split("\n", $layout);
|
||||||
|
|
||||||
my %pstack;
|
|
||||||
my $pstackcount = 0;
|
my $pstackcount = 0;
|
||||||
|
my %pstack;
|
||||||
my %params;
|
my %params;
|
||||||
|
|
||||||
$params{name} = $name;
|
$params{name} = $name;
|
||||||
@ -1188,10 +1190,10 @@ sub btIP_HTMLHead {
|
|||||||
'"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">'."\n";
|
'"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">'."\n";
|
||||||
my $xmlns = "";
|
my $xmlns = "";
|
||||||
|
|
||||||
my $refresh = (defined($refresh) && $refresh) ? "<meta http-equiv=\"refresh\" content=\"$refresh\"/>\n" : "";
|
my $r = (defined($refresh) && $refresh) ? "<meta http-equiv=\"refresh\" content=\"$refresh\"/>\n" : "";
|
||||||
my $scripts = btIP_getScript();
|
my $scripts = btIP_getScript();
|
||||||
my $meta = "<meta charset=\"UTF-8\">\n";
|
my $meta = "<meta charset=\"UTF-8\">\n";
|
||||||
my $code = "$doctype\n<html $xmlns>\n<head>\n<title>$title</title>\n$meta$refresh$scripts</head>\n";
|
my $code = "$doctype\n<html $xmlns>\n<head>\n<title>$title</title>\n$meta$r$scripts</head>\n";
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
fhem/FHEM/template.layout
Normal file
5
fhem/FHEM/template.layout
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# This template file can be used for layout creation
|
||||||
|
# needed by 02_RSS.pm and 55_InfoPanel.pm
|
||||||
|
#
|
||||||
|
# Use "save as" once to create the file with your desired name
|
||||||
|
#
|
Loading…
x
Reference in New Issue
Block a user