2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

FLOORPLAN: fixed interference with WVC, added style8 for command-popup

git-svn-id: https://svn.fhem.de/fhem/trunk@8023 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ulimaass 2015-02-17 20:29:08 +00:00
parent c73d44eb3c
commit e803f6a430

View File

@ -48,6 +48,7 @@
# 0037: updated to match fhemweb.js developments (Rudi, Jan 17, 2015) # 0037: updated to match fhemweb.js developments (Rudi, Jan 17, 2015)
# 0038: added arrange by drag&drop provided by Markus (mluckey), added longpollfilter (nesges), # 0038: added arrange by drag&drop provided by Markus (mluckey), added longpollfilter (nesges),
# added processing of global userattr fp_<name> and their value per device for rename, copy, delete (Jan 31, 2015) # added processing of global userattr fp_<name> and their value per device for rename, copy, delete (Jan 31, 2015)
# 0039: added style 8 for commands-popup provided by André (justme68) (Feb 17, 2015)
# #
################################################################ ################################################################
# #
@ -151,7 +152,8 @@ my $FW_plotmode=""; # like in FHEMWEB: SVG
my $FW_plotsize; # like in FHEMWEB: like in fhemweb dependent on regular/smallscreen/touchpad my $FW_plotsize; # like in FHEMWEB: like in fhemweb dependent on regular/smallscreen/touchpad
my %FW_zoom; # copied from FHEMWEB - using local version to avoid global variable my %FW_zoom; # copied from FHEMWEB - using local version to avoid global variable
my @FW_zoom; # copied from FHEMWEB - using local version to avoid global variable my @FW_zoom; # copied from FHEMWEB - using local version to avoid global variable
my @styles = ("0 (Icon only)","1 (Name+Icon)","2 (Name+Icon+Commands)","3 (Device-Reading)","4 (S300TH-specific)","5 (Icon+Commands)","6 (Reading+Timestamp)","7 (Commands only)"); my @styles = ("0 (Icon only)","1 (Name+Icon)","2 (Name+Icon+Commands)","3 (Device-Reading)","4 (S300TH-specific)","5 (Icon+Commands)",
"6 (Reading+Timestamp)","7 (Commands only)","8 (Icon+Commands popup)");
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -338,12 +340,13 @@ FP_CGI(){
$FP_arrange = AttrVal($FP_name, "fp_arrange", 0); $FP_arrange = AttrVal($FP_name, "fp_arrange", 0);
} }
## process cgi ### process cgi
my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands
my $FP_ret = AnalyzeCommand(undef, $commands, my $FP_ret = AnalyzeCommand(undef, $commands,
AttrVal($FW_wname,"allowedCommands",undef)) if $commands; #Execute commands AttrVal($FW_wname,"allowedCommands",undef)) ; # Execute commands
Log3 "FLOORPLAN", 1, "FLOORPLAN: regex-error. commands: $commands; FP_ret: $FP_ret" if($FP_ret && ($FP_ret =~ m/regex/ )); #test Log3 "FLOORPLAN", 1, "FLOORPLAN: regex-error. commands: $commands, FP_name: $FP_name, FP_ret: $FP_ret" if($FP_ret && ($FP_ret =~ m/regex/ )); #errormessage
#####redirect URL - either back to fhemweb-detailscreen, or for redirectCmds to suppress repeated execution of commands upon browser refresh
### redirect URL - either back to fhemweb-detailscreen, or for redirectCmds to suppress repeated execution of commands upon browser refresh
my $me = $defs{$FW_cname}; # from FHEMWEB: Current connection name my $me = $defs{$FW_cname}; # from FHEMWEB: Current connection name
my $tgt = undef; my $tgt = undef;
if( !$htmlpart[0] || (AttrVal($FW_wname, "redirectCmds", 1) && $me && $commands && !$FP_ret)) { if( !$htmlpart[0] || (AttrVal($FW_wname, "redirectCmds", 1) && $me && $commands && !$FP_ret)) {
@ -471,7 +474,7 @@ FP_htmlHeader($) {
my $jsTemplate = '<script type="text/javascript" src="%s"></script>'; my $jsTemplate = '<script type="text/javascript" src="%s"></script>';
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery.min.js"); FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery.min.js");
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery-ui.min.js"); FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery-ui.min.js");
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_click.js"); #enlarge clickable area per widget # FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_click.js"); #enlarge clickable area per widget
if ($FP_arrange && ($FP_arrange eq "1" || ($FP_arrange eq $FW_wname) || $FP_arrange eq "detail")) { if ($FP_arrange && ($FP_arrange eq "1" || ($FP_arrange eq $FW_wname) || $FP_arrange eq "detail")) {
FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_drag.js") ; #arrange-mode drag&drop FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_drag.js") ; #arrange-mode drag&drop
} }
@ -479,7 +482,7 @@ FP_htmlHeader($) {
####################### #######################
# Other JavaScripts + their Attributes # Other JavaScripts + their Attributes
map { FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/$_") } @FW_fhemwebjs; map { FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/$_") } @FW_fhemwebjs;
$jsTemplate = '<script attr=\'%s\' type="text/javascript" src="%s"></script>'; $jsTemplate = '<script attr=\'%s\' type="text/javascript" src="%s"></script>'."\n";
map { map {
my $n = $_; $n =~ s+.*/++; $n =~ s/.js$//; $n =~ s/fhem_//; $n .= "Param"; my $n = $_; $n =~ s+.*/++; $n =~ s/.js$//; $n =~ s/fhem_//; $n .= "Param";
FW_pO sprintf($jsTemplate, AttrVal($FP_name, $n, ""), "$FW_ME/$_"); FW_pO sprintf($jsTemplate, AttrVal($FP_name, $n, ""), "$FW_ME/$_");
@ -511,8 +514,7 @@ FP_htmlHeader($) {
# show startscreen # show startscreen
sub sub
FP_showStart() { FP_showStart() {
FP_htmlHeader("Floorplans"); FP_htmlHeader("Floorplans"); # incl. body-tag
FW_pO "<body>";
FW_pO "<div id=\"logo\"></div>"; FW_pO "<div id=\"logo\"></div>";
FP_menu(); FP_menu();
FW_pO "<div class=\"screen\" id=\"hdr\">"; FW_pO "<div class=\"screen\" id=\"hdr\">";
@ -544,8 +546,7 @@ FP_showStart() {
sub sub
FP_show(){ FP_show(){
### Page start ### Page start
FP_htmlHeader("$FP_name"); FP_htmlHeader("$FP_name"); ## incl. body-tag
## body
my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : ""; my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : "";
FW_pO "<div id=\"backimg\" style=\"width: 99%; height: 99%;\">"; FW_pO "<div id=\"backimg\" style=\"width: 99%; height: 99%;\">";
FW_pO FW_makeImage(AttrVal($FP_name, "fp_backgroundimg", "fp_$FP_name")); FW_pO FW_makeImage(AttrVal($FP_name, "fp_backgroundimg", "fp_$FP_name"));
@ -573,7 +574,7 @@ FP_show(){
my ($top, $left, $style, $text, $text2) = split(/,/ , $attr); my ($top, $left, $style, $text, $text2) = split(/,/ , $attr);
# $top = position in px, top # $top = position in px, top
# $left = position in px, left # $left = position in px, left
# $style = style (0=icon only, 1=name+icon, 2=name+icon+commands, 3=device-Reading + name from $text2, 4=S300TH, 5=icon+commands, 6 device-Reading+timestamp) # $style = style (0=icon only, 1=name+icon, 2=name+icon+commands, 3=device-Reading + name from $text2, 4=S300TH, 5=icon+commands, 6 device-Reading+timestamp, 7 command only, 8 icon+commands popup)
# $text = alternativeCaption # $text = alternativeCaption
# $text2 = special for style3+6: $text = ReadingID, $text2=alternativeCaption # $text2 = special for style3+6: $text = ReadingID, $text2=alternativeCaption
$left = 0 if (!$left); $left = 0 if (!$left);
@ -634,7 +635,9 @@ FP_show(){
if ($style == 3 || $style == 6) { if ($style == 3 || $style == 6) {
FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
} elsif ($style == 4) { } elsif ($style == 4) {
FW_pO "<td>$txt"; # state style4 FW_pO "<td>$txt"; # state style4
} elsif ($cmdlist && $style == 8) {
# first collect the popup data
} else { } else {
FW_pO "<td informId=\"$d\" colspan=\"$cols\">$txt"; # state FW_pO "<td informId=\"$d\" colspan=\"$cols\">$txt"; # state
} }
@ -650,13 +653,14 @@ FP_show(){
######################## ########################
# Commands per device # Commands per device
if($cmdlist && ( $style == 2 || $style == 5 || $style == 7) ) { if($cmdlist && ( $style == 2 || $style == 5 || $style == 7 || $style == 8) ) {
my @cList = split(":", $cmdlist); my @cList = split(":", $cmdlist);
my @rList = map { ReplaceEventMap($d,$_,1) } @cList; my @rList = map { ReplaceEventMap($d,$_,1) } @cList;
my $firstIdx = 0; my $firstIdx = 0;
FW_pO " <tr class=\"devicecommands\" id=\"$d-devicecommands\">"; FW_pO " <tr class=\"devicecommands\" id=\"$d-devicecommands\">";
my $oldMe = $FW_ME; my $oldMe = $FW_ME;
my $h = "";
foreach my $cmd (sort @cList) { foreach my $cmd (sort @cList) {
# Special handling (slider, dropdown, timepicker, ...) # Special handling (slider, dropdown, timepicker, ...)
my $htmlTxt; my $htmlTxt;
@ -673,17 +677,35 @@ FP_show(){
last if(defined($htmlTxt)); last if(defined($htmlTxt));
} }
} }
if(defined($htmlTxt)) { if( $style == 8 ) {
$htmlTxt =~ s/>desired-temp/>/; #for FHT if( $htmlTxt ) {
$htmlTxt =~ s/>desiredTemperature/>/; #for MAX! $h .= "<p>$htmlTxt</p>";
FW_pO $htmlTxt; } elsif($cmd) {
# END # Special handling (slider, dropdown, timepicker, ...) my $link = "cmd.$d=set $d $cmd";
$h .= "<p><a href='$FW_ME$FW_subdir?$link$FW_CSRF'>$cmd</a></p>";
}
} else { } else {
FW_pH "cmd.$d=set $d $cmd", if(defined($htmlTxt)) {
ReplaceEventMap($d,$cmd,1),1,"devicecommands"; $htmlTxt =~ s/>desired-temp/>/; #for FHT
$htmlTxt =~ s/>desiredTemperature/>/; #for MAX!
FW_pO $htmlTxt;
# END # Special handling (slider, dropdown, timepicker, ...)
} else {
FW_pH "cmd.$d=set $d $cmd",
ReplaceEventMap($d,$cmd,1),1,"devicecommands";
}
} }
} }
$FW_ME = $oldMe; $FW_ME = $oldMe;
if( $style == 8 ) {
$h =~ s/'/\\"/g;
if( $txt =~ m/<div([^>]*)><a[^>]*>(.*)<\/a>/ ) {
$txt = "<div $1><a onClick='FW_okDialog(\"$h\",this.children[0]);\$(\"a[href]\").each(function() { FW_replaceLink(this); })'\><div informId=\"$d\">$2</div></a></div>";
} else {
FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
}
FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
}
FW_pO "</tr>"; FW_pO "</tr>";
} elsif($type eq "FileLog") { } elsif($type eq "FileLog") {
@ -1019,7 +1041,8 @@ FP_pOfill($@) {
<li>5 icon/state and commands</li> <li>5 icon/state and commands</li>
<li>6 device-reading, reading-timestamp and optional description</li> <li>6 device-reading, reading-timestamp and optional description</li>
<li>7 commands only</li> <li>7 commands only</li>
</ul> <li>8 commands popup</li>
</ul>
</li> </li>
<li>description will be displayed instead of the original devicename</li> <li>description will be displayed instead of the original devicename</li>
</ul></li><br> </ul></li><br>
@ -1188,6 +1211,7 @@ FP_pOfill($@) {
<li>5 icon/Status und Kommandos (ohne Gerätename)</li> <li>5 icon/Status und Kommandos (ohne Gerätename)</li>
<li>6 Geräte-reading, Zeitstempel und optionale Beschreibung</li> <li>6 Geräte-reading, Zeitstempel und optionale Beschreibung</li>
<li>7 nur Kommandos</li> <li>7 nur Kommandos</li>
<li>8 popup für kommandos</li>
</ul> </ul>
</li> </li>
<li>Eine ggf. angegebene Bschreibung wird anstelle des original-Gerätenamens angezeigt.</li> <li>Eine ggf. angegebene Bschreibung wird anstelle des original-Gerätenamens angezeigt.</li>