mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
FHEMWEB: textField by justme1968
git-svn-id: https://svn.fhem.de/fhem/trunk@3922 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4b5bfc2d6a
commit
a1beda9398
@ -137,7 +137,8 @@ FHEMWEB_Initialize($)
|
||||
|
||||
$data{webCmdFn}{slider} = "FW_sliderFn";
|
||||
$data{webCmdFn}{timepicker} = "FW_timepickerFn";
|
||||
$data{webCmdFn}{noArg} = "FW_noArg";
|
||||
$data{webCmdFn}{noArg} = "FW_noArgFn";
|
||||
$data{webCmdFn}{textField} = "FW_textFieldFn";
|
||||
$data{webCmdFn}{"~dropdown"}= "FW_dropdownFn"; # Should be the last
|
||||
}
|
||||
|
||||
@ -2147,6 +2148,8 @@ FW_htmlEscape($)
|
||||
return $txt;
|
||||
}
|
||||
|
||||
###########################
|
||||
# Widgets START
|
||||
sub
|
||||
FW_sliderFn($$$$$)
|
||||
{
|
||||
@ -2173,7 +2176,7 @@ FW_sliderFn($$$$$)
|
||||
}
|
||||
|
||||
sub
|
||||
FW_noArg($$$$$)
|
||||
FW_noArgFn($$$$$)
|
||||
{
|
||||
my ($FW_wname, $d, $FW_room, $cmd, $values) = @_;
|
||||
|
||||
@ -2234,6 +2237,29 @@ FW_dropdownFn()
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub
|
||||
FW_textFieldFn($$$$)
|
||||
{
|
||||
my ($FW_wname, $d, $FW_room, $cmd, $values) = @_;
|
||||
|
||||
my @args = split("[ \t]+", $cmd);
|
||||
|
||||
return undef if($values !~ m/^textField$/);
|
||||
return "" if($cmd =~ m/ /);
|
||||
my $srf = $FW_room ? "&room=$FW_room" : "";
|
||||
my $cv = ReadingsVal($d, $cmd, "");
|
||||
my $id = ($cmd eq "state") ? "" : "-$cmd";
|
||||
|
||||
my $c = "$FW_ME?XHR=1&cmd=setreading $d $cmd %$srf";
|
||||
return '<td align="center">'.
|
||||
"<div>$cmd:<input id='textField.$d$id' type='text' value='$cv' ".
|
||||
"onChange='textField_setText(this,\"$c\")'></div>".
|
||||
'</td>';
|
||||
}
|
||||
|
||||
# Widgets END
|
||||
###########################
|
||||
|
||||
sub
|
||||
FW_ActivateInform()
|
||||
{
|
||||
@ -2642,6 +2668,7 @@ FW_ActivateInform()
|
||||
displayed </li>
|
||||
<li>if the modifier is ":time", then a javascript driven timepicker is
|
||||
displayed.</li>
|
||||
<li>if the modifier is ":textField", an input field is displayed.</li>
|
||||
<li>if the modifier is of the form
|
||||
":slider,<min>,<step>,<max>", then a javascript
|
||||
driven slider is displayed</li>
|
||||
|
31
fhem/www/pgm2/fhemweb_textField.js
Normal file
31
fhem/www/pgm2/fhemweb_textField.js
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
function
|
||||
FW_textFieldUpdateLine(d)
|
||||
{
|
||||
var name = "textField."+d[0];
|
||||
//console.log("Cmd "+d);
|
||||
|
||||
el = document.getElementById(name);
|
||||
|
||||
if(el) {
|
||||
el.value = d[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function
|
||||
textField_setText(el,cmd)
|
||||
{
|
||||
var v = el.value;
|
||||
//console.log("Got "+v);
|
||||
//console.log("Cmd "+cmd);
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", cmd.replace('%',v), true);
|
||||
req.send(null);
|
||||
}
|
||||
|
||||
FW_widgets['textField'] = {
|
||||
updateLine:FW_textFieldUpdateLine
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user