From 32bfe6b3a55f1bbe35775d5de739e64bd3c43ba5 Mon Sep 17 00:00:00 2001 From: ulimaass Date: Tue, 17 Feb 2015 20:29:08 +0000 Subject: [PATCH] FLOORPLAN: fixed interference with WVC, added style8 for command-popup git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8023 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/95_FLOORPLAN.pm | 68 ++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/fhem/FHEM/95_FLOORPLAN.pm b/fhem/FHEM/95_FLOORPLAN.pm index 949c714de..ddb6d4745 100644 --- a/fhem/FHEM/95_FLOORPLAN.pm +++ b/fhem/FHEM/95_FLOORPLAN.pm @@ -48,6 +48,7 @@ # 0037: updated to match fhemweb.js developments (Rudi, Jan 17, 2015) # 0038: added arrange by drag&drop provided by Markus (mluckey), added longpollfilter (nesges), # added processing of global userattr fp_ 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_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); } - ## process cgi + ### process cgi my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands my $FP_ret = AnalyzeCommand(undef, $commands, - AttrVal($FW_wname,"allowedCommands",undef)) if $commands; #Execute commands - Log3 "FLOORPLAN", 1, "FLOORPLAN: regex-error. commands: $commands; FP_ret: $FP_ret" if($FP_ret && ($FP_ret =~ m/regex/ )); #test - #####redirect URL - either back to fhemweb-detailscreen, or for redirectCmds to suppress repeated execution of commands upon browser refresh + AttrVal($FW_wname,"allowedCommands",undef)) ; # Execute commands + 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 my $me = $defs{$FW_cname}; # from FHEMWEB: Current connection name my $tgt = undef; if( !$htmlpart[0] || (AttrVal($FW_wname, "redirectCmds", 1) && $me && $commands && !$FP_ret)) { @@ -471,7 +474,7 @@ FP_htmlHeader($) { my $jsTemplate = ''; 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/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")) { FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_drag.js") ; #arrange-mode drag&drop } @@ -479,7 +482,7 @@ FP_htmlHeader($) { ####################### # Other JavaScripts + their Attributes map { FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/$_") } @FW_fhemwebjs; - $jsTemplate = ''; + $jsTemplate = ''."\n"; map { my $n = $_; $n =~ s+.*/++; $n =~ s/.js$//; $n =~ s/fhem_//; $n .= "Param"; FW_pO sprintf($jsTemplate, AttrVal($FP_name, $n, ""), "$FW_ME/$_"); @@ -511,8 +514,7 @@ FP_htmlHeader($) { # show startscreen sub FP_showStart() { - FP_htmlHeader("Floorplans"); - FW_pO ""; + FP_htmlHeader("Floorplans"); # incl. body-tag FW_pO "
"; FP_menu(); FW_pO "
"; @@ -544,8 +546,7 @@ FP_showStart() { sub FP_show(){ ### Page start - FP_htmlHeader("$FP_name"); - ## body + FP_htmlHeader("$FP_name"); ## incl. body-tag my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : ""; FW_pO "
"; 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); # $top = position in px, top # $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 # $text2 = special for style3+6: $text = ReadingID, $text2=alternativeCaption $left = 0 if (!$left); @@ -634,7 +635,9 @@ FP_show(){ if ($style == 3 || $style == 6) { FW_pO "
$txt
"; # reading } elsif ($style == 4) { - FW_pO "$txt"; # state style4 + FW_pO "$txt"; # state style4 + } elsif ($cmdlist && $style == 8) { + # first collect the popup data } else { FW_pO "$txt"; # state } @@ -650,13 +653,14 @@ FP_show(){ ######################## # 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 @rList = map { ReplaceEventMap($d,$_,1) } @cList; my $firstIdx = 0; FW_pO " "; my $oldMe = $FW_ME; + my $h = ""; foreach my $cmd (sort @cList) { # Special handling (slider, dropdown, timepicker, ...) my $htmlTxt; @@ -673,17 +677,35 @@ FP_show(){ last if(defined($htmlTxt)); } } - if(defined($htmlTxt)) { - $htmlTxt =~ s/>desired-temp/>/; #for FHT - $htmlTxt =~ s/>desiredTemperature/>/; #for MAX! - FW_pO $htmlTxt; - # END # Special handling (slider, dropdown, timepicker, ...) + if( $style == 8 ) { + if( $htmlTxt ) { + $h .= "

$htmlTxt

"; + } elsif($cmd) { + my $link = "cmd.$d=set $d $cmd"; + $h .= "

$cmd

"; + } } else { - FW_pH "cmd.$d=set $d $cmd", - ReplaceEventMap($d,$cmd,1),1,"devicecommands"; + if(defined($htmlTxt)) { + $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; + if( $style == 8 ) { + $h =~ s/'/\\"/g; + if( $txt =~ m/]*)>]*>(.*)<\/a>/ ) { + $txt = ""; + } else { + FW_pO "
$txt
"; # reading + } + FW_pO "
$txt
"; # reading + } FW_pO ""; } elsif($type eq "FileLog") { @@ -1019,7 +1041,8 @@ FP_pOfill($@) {
  • 5 icon/state and commands
  • 6 device-reading, reading-timestamp and optional description
  • 7 commands only
  • - +
  • 8 commands popup
  • +
  • description will be displayed instead of the original devicename

  • @@ -1188,6 +1211,7 @@ FP_pOfill($@) {
  • 5 icon/Status und Kommandos (ohne Gerätename)
  • 6 Geräte-reading, Zeitstempel und optionale Beschreibung
  • 7 nur Kommandos
  • +
  • 8 popup für kommandos
  • Eine ggf. angegebene Bschreibung wird anstelle des original-Gerätenamens angezeigt.