mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
bugfix: webCmdfn (slider, timepicker, dropdown)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@3220 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1ad3744497
commit
1dc8ec486b
@ -33,7 +33,8 @@
|
||||
# 0022: longpoll by Matthias Gehre (November 27, 2012)
|
||||
# 0023: longpoll updates readings also - by Matthias Gehre; FW_longpoll is now a global variable (January 21, 2013)
|
||||
# 0024: fix for readings longpoll, added js-extension from Dirk (February 16, 2013)
|
||||
# 0025: Added fp_viewport-attribute from (March 03, 2013)
|
||||
# 0025: Added fp_viewport-attribute from Jens (March 03, 2013)
|
||||
# 0026: Adapted to FHEMWEB-changes re webCmdFn - fp_setbutton not functional (May 23, 2013)
|
||||
#
|
||||
################################################################
|
||||
#
|
||||
@ -430,7 +431,6 @@ FP_show(){
|
||||
FW_pO "<form method=\"get\" action=\"$FW_ME/floorplan/$FP_name/$d\" autocomplete=\"off\">";
|
||||
FW_pO " <table class=\"$type fp_$FP_name\" id=\"table-$d\" align=\"center\">"; # Main table per device
|
||||
my ($allSets, $cmdlist, $txt) = FW_devState($d, "");
|
||||
#Debug "txt is \"$txt\"";
|
||||
$txt = ReadingsVal($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
|
||||
my $cols = ($cmdlist ? (split(":", $cmdlist)) : 0); # Need command-count for colspan of devicename+state
|
||||
|
||||
@ -494,70 +494,30 @@ FP_show(){
|
||||
my @rList = map { ReplaceEventMap($d,$_,1) } @cList;
|
||||
my $firstIdx = 0;
|
||||
FW_pO " <tr class=\"devicecommands\" id=\"$d-devicecommands\">";
|
||||
# Special handling (slider, dropdown)
|
||||
my $FW_room = undef; ##needed to be able to reuse code from FHEMWEB
|
||||
|
||||
# Special handling (slider, dropdown, timepicker)
|
||||
# my $FW_room = undef; ##needed to be able to reuse code from FHEMWEB
|
||||
my $cmd = $cList[0];
|
||||
if($allSets && $allSets =~ m/$cmd:([^ ]*)/) {
|
||||
my $values = $1;
|
||||
|
||||
if($values =~ m/^slider,(.*),(.*),(.*)/) { ##### Slider
|
||||
my ($min,$stp, $max) = ($1, $2, $3);
|
||||
my $srf = $FW_room ? "&room=$FW_room" : "";
|
||||
my $cv = ReadingsVal($d, $cmd, Value($d));
|
||||
$cmd = "" if($cmd eq "state");
|
||||
$cv =~ s/[^\d\.]//g;
|
||||
FW_pO "<td colspan='2'>".
|
||||
"<div class='slider' id='slider.$d'>".
|
||||
"<div class='handle'>$min</div></div>".
|
||||
"</div>".
|
||||
"<script type=\"text/javascript\">" .
|
||||
"Slider(document.getElementById('slider.$d'),".
|
||||
"'$min','$stp','$max','$cv',".
|
||||
"'$FW_ME/floorplan/$FP_name?cmd=set $d $cmd %$srf')".
|
||||
"</script>".
|
||||
"</td>";
|
||||
my $oldMe = $FW_ME;
|
||||
$FW_ME = "$FW_ME/floorplan/$FP_name";
|
||||
foreach my $fn (sort keys %{$data{webCmdFn}}) {
|
||||
my $FW_room = ""; ##needed to be able to reuse code from FHEMWEB
|
||||
no strict "refs";
|
||||
my $htmlTxt = &{$data{webCmdFn}{$fn}}("$FW_ME",
|
||||
$d, $FW_room, $cmd, $values);
|
||||
use strict "refs";
|
||||
if(defined($htmlTxt)) {
|
||||
# Debug "FP webCmdFn: ".$data{webCmdFn}{$fn}."(\"$FW_ME\",$d, $FW_room, $cmd, $values)";
|
||||
FW_pO $htmlTxt;
|
||||
$firstIdx = 1;
|
||||
} elsif($values =~ m/^time$/) { ##### Time picker
|
||||
my $srf = $FW_room ? "&room=$FW_room" : "";
|
||||
my $cv = ReadingsVal($d, $cmd, Value($d));
|
||||
$cmd = "" if($cmd eq "state");
|
||||
my $c = "\"$FW_ME/floorplan/$FP_name?cmd=set $d $cmd %$srf\"";
|
||||
FW_pO "<td colspan='2'>".
|
||||
"<input name='time.$d' value='$cv' type='text'".
|
||||
" readonly size='5'>".
|
||||
"<input type='button' value='+'".
|
||||
" onclick='addTime(this,$c)'>".
|
||||
"</td>";
|
||||
$firstIdx=1;
|
||||
|
||||
} else { ##### Dropdown
|
||||
|
||||
my @tv = split(",", $values);
|
||||
# Hack: eventmap (translation only) should not result in a
|
||||
# dropdown. eventMap/webCmd/etc handling must be cleaned up.
|
||||
if(@tv > 1) {
|
||||
$firstIdx=1;
|
||||
my @array = qw/desired-temp desiredTemperature/;
|
||||
if(/$cmd/i ~~ @array) {
|
||||
$txt = ReadingsVal($d, $cmd, 20);
|
||||
$txt =~ s/ .*//; # Cut off Celsius
|
||||
$txt = sprintf("%2.1f", int(2*$txt)/2) if($txt =~ m/[0-9.-]/);
|
||||
} else {
|
||||
$txt = Value($d);
|
||||
$txt =~ s/$cmd //;
|
||||
}
|
||||
FW_pO "<td>".
|
||||
FW_hidden("arg.$d", $cmd) .
|
||||
FW_hidden("dev.$d", $d) .
|
||||
($FW_room ? FW_hidden("room", $FW_room) : "") .
|
||||
(AttrVal($FP_name,'fp_setbutton',1) ? FW_select("$d-$cmd","val.$d", \@tv, $txt, "dropdown") : FW_select("$d-$cmd","val.$d", \@tv, $txt, "dropdown", "submit()")).
|
||||
(AttrVal($FP_name,'fp_setbutton',1) ? FW_submit("cmd.$d", "set") : FW_hidden("cmd.$d", "set")).
|
||||
"</td>";
|
||||
last;
|
||||
}
|
||||
}
|
||||
$FW_ME = $oldMe;
|
||||
}
|
||||
# END # Special handling (slider, dropdown)
|
||||
|
||||
# END # Special handling (slider, dropdown, timepicker)
|
||||
|
||||
for(my $idx=$firstIdx; $idx < @cList; $idx++) {
|
||||
FW_pH "cmd.$d=set $d $cList[$idx]",
|
||||
|
Loading…
x
Reference in New Issue
Block a user