From 98e96ec407f18ee91efc1b3e73897aeae21bb4c8 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sat, 15 Nov 2014 14:01:13 +0000 Subject: [PATCH] 01_FHEMWEB: better dropdown (i.e. selectlist) handling with/without longpoll by Hoschiq (Forum #26313) git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6981 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 9fdfe6822..2e10e6f52 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -2509,17 +2509,27 @@ FW_dropdownFn() my $fpname = $FW_wname; $fpname =~ s/.*floorplan\/(\w+)$/$1/; #allow usage of attr fp_setbutton - my $fwsel; - $fwsel = ($cmd eq "state" ? "" : "$cmd ") . - FW_select("$d-$cmd","val.$d", \@tv, $txt,"dropdown","submit()"). - FW_hidden("cmd.$d", "set"); - $fwsel .= FW_hidden("fwcsrf", $defs{$FW_wname}{CSRFTOKEN}) if($FW_CSRF); - return "
". - FW_hidden("arg.$d", $cmd) . - FW_hidden("dev.$d", $d) . - ($FW_room ? FW_hidden("room", $FW_room) : "") . - "$fwsel
"; + my $readng = ($cmd eq "state" ? "" : "$cmd"." "); + + # TODO in case of running in a floorplan split $FW_wname to get name of + # webInstance. Actually in floorplan the dropdown will refresh the page + # always independently from setting in corresponding web instance, cause + # statement if( AttrVal($FW_wname, "longpoll", 0) == 1) will always fail. + my $selFunct=""; + if( AttrVal($FW_wname, "longpoll", 0) == 1) { + $selFunct = "FW_cmd('$FW_ME?XHR=1&cmd.$d=set $d $readng '+ ". + "this.options[this.selectedIndex].value+ ' &room=$FW_room')"; + + } else { + $selFunct = "window.location = addcsrf('$FW_ME?cmd.$d=set $d $readng '+". + "this.options[this.selectedIndex].value+ ' &room=$FW_room')"; + + } + my $fwsel; + $fwsel = ($cmd eq "state" ? "" : "$cmd ") . + FW_select("$d-$cmd","val.$d", \@tv, $txt,"dropdown","$selFunct"); + return "$fwsel"; } return undef; }