diff --git a/contrib/95_FLOORPLAN/95_FLOORPLAN.pm b/contrib/95_FLOORPLAN/95_FLOORPLAN.pm index 035ae395d..ada1463f3 100644 --- a/contrib/95_FLOORPLAN/95_FLOORPLAN.pm +++ b/contrib/95_FLOORPLAN/95_FLOORPLAN.pm @@ -17,8 +17,8 @@ # 0009: updated selection of add-device-list: suppress CUL$ only (instead of CUL.*) # 0010: Added Style3, fp_stylesheetPrefix, fp_noMenu (Mar 13, 2012) # 0011: Added Style4, code beautification, css review, minor $text2-fix (SVN 1342) -# 0012: Added startscreen-text when no floorplans defined, fixed startscreen-stylesheet, added div for bg-img, added arrangeByMouse -# +# 0012: Added startscreen-text when no floorplans defined, fixed startscreen-stylesheet, added div for bg-img, added arrangeByMouse (1368) +# 0013: implemented redirectCmd, fixed minor -error in html-output, fp_arrange for single web-devices, fp_arrange detail (Mar 23, 2012) # ################################################################ # @@ -112,6 +112,7 @@ my $FW_detail; # copied from FHEMWEB - using local version to 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 # $FW_subdir # from FHEMWEB: path of floorplan-subdir - enables reusability of FHEMWEB-routines for sub-URLS like floorplan +# $FW_cname # from FHEMWEB: Current connection name #------------------------------------------------------------------------------- sub @@ -135,7 +136,6 @@ FLOORPLAN_Initialize($) # $data{FWEXT}{$fhem_url}{EMBEDDED} = 1; # not using embedded-mode to save screen-space $data{FWEXT}{$fhem_url}{STYLESHEET} = "floorplanstyle.css"; # Global-Config for CSS -# $attr{global}{VIEW_CSS} = ""; # mod20120314 $modules{_internal_}{AttrList} .= " VIEW_CSS"; my $n = 0; @FW_zoom = ("qday", "day","week","month","year"); #copied from FHEMWEB - using local version to avoid global variable @@ -196,6 +196,8 @@ FP_CGI(){ $FW_subdir = "/floorplan/$FP_name"; } else { # no floorplan-name in URL $FW_subdir = "/floorplan"; + $FP_arrange_default = undef; + $FP_arrange_selected = undef; my $dev = undef; my @devs = devspec2array("*"); foreach my $fp (@devs) { @@ -203,14 +205,26 @@ FP_CGI(){ $FP_name = $fp; $FW_subdir = "/floorplan/$fp"; $FP_arrange = AttrVal($fp, "fp_arrange", undef); - $FP_arrange_default = undef; - $FP_arrange_selected = undef; + } } } my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands my $FP_ret = AnalyzeCommand(undef, $commands) if $commands; # Execute commands + #####redirect commands - to suppress repeated execution of commands upon browser refresh + my $me = $defs{$FW_cname}; # from FHEMWEB: Current connection name + if( AttrVal($FW_wname, "redirectCmds", 1) && $me && $commands && !$FP_ret) { + my $tgt = $FW_ME; + if($FP_name) { $tgt .= "/floorplan/$FP_name" } + else { $tgt .= "/floorplan" } + my $c = $me->{CD}; + print $c "HTTP/1.1 302 Found\r\n", + "Content-Length: 0\r\n", + "Location: $tgt\r\n", + "\r\n"; + } + ###################################### ### output html-pages if($FP_name) { @@ -244,8 +258,8 @@ FP_digestCgi($) { $v =~ s/[\r]\n/\\\n/g if($v && $p && $p ne "data"); $FP_webArgs{$p} = $v; - if($p eq "arr.dev") { $FP_arrange_selected = $v; $FP_arrange_default = $v; } - if($p eq "add.dev") { $cmd = "attr $v fp_$FP_name 50,100"; } + if($p eq "arr.dev") { $v =~ m,^(\w*)\s\(,; $v = $1 if ($1); $FP_arrange_selected = $v; $FP_arrange_default = $v; } + if($p eq "add.dev") { $v =~ m,^(\w*)\s\(,; $v = $1 if ($1); $cmd = "attr $v fp_$FP_name 50,100"; } if($p eq "cmd") { $cmd = $v; } if($p =~ m/^cmd\.(.*)$/) { $cmd = $v; $c = $1; } if($p =~ m/^dev\.(.*)$/) { $dev{$1} = $v; } @@ -327,7 +341,7 @@ FP_showStart() { FW_pO "
"; #input-field FW_pO " |
define <name> FLOORPLAN