2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-19 18:56:03 +00:00

FHEMWEB: multiple selector added

git-svn-id: https://svn.fhem.de/fhem/trunk@5012 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-02-21 19:59:59 +00:00
parent 1f791a036e
commit db7f36a612
3 changed files with 46 additions and 15 deletions

View File

@ -709,7 +709,7 @@ FW_digestCgi($)
if($p eq "room") { $FW_room = $v; }
if($p eq "cmd") { $cmd = $v; }
if($p =~ m/^arg\.(.*)$/) { $arg{$1} = $v; }
if($p =~ m/^val\.(.*)$/) { $val{$1} = $v; }
if($p =~ m/^val\.(.*)$/) { $val{$1} = ($val{$1} ? $val{$1}.",$v" : $v) }
if($p =~ m/^dev\.(.*)$/) { $dev{$1} = $v; }
if($p =~ m/^cmd\.(.*)$/) { $cmd = $v; $c = $1; }
if($p eq "pos") { %FW_pos = split(/[=;]/, $v); }
@ -914,7 +914,7 @@ FW_doDetail($)
FW_makeTable("Readings", $d, $h->{READINGS});
my $attrList = getAllAttr($d);
my $roomList = join(",", sort grep !/ /, keys %FW_rooms);
my $roomList = "multiple,".join(",", sort grep !/ /, keys %FW_rooms);
$attrList =~ s/room /room:$roomList /;
FW_makeSelect($d, "attr", $attrList,"attr");
@ -2850,6 +2850,8 @@ FW_ActivateInform()
<li>if the modifier is of the form
":slider,&lt;min&gt;,&lt;step&gt;,&lt;max&gt;", then a javascript
driven slider is displayed</li>
<li>if the modifier is of the form ":multiple,val1,val2,...", then
multiple values can be selected, the result is comma separated.
<li>else a dropdown with all the modifier values is displayed</li>
</ul>
If the command is state, then the value will be used as a command.<br>
@ -3329,6 +3331,9 @@ FW_ActivateInform()
":slider,&lt;min&gt;,&lt;step&gt;,&lt;max&gt;", so wird ein in
JavaScript programmierter Slider angezeigt</li>
<li>Ist der Modifier ":multiple,val1,val2,...", dann ein
Mehrfachauswahl ist m&ouml;glich, das Ergebnis ist Komma-separiert.
<li>In allen anderen F&auml;llen erscheint ein Dropdown mit allen
Modifier Werten.</li>
</ul>

View File

@ -0,0 +1,36 @@
function
FW_multipleSelChange(name, devName, vArr)
{
if(vArr.length < 2 || vArr[0] != "multiple")
return undefined;
var o = new Object();
o.newEl = document.createElement('select');
o.newEl.setAttribute('multiple', true);
for(var j=1; j < vArr.length; j++) {
o.newEl.options[j-1] = new Option(vArr[j], vArr[j]);
}
o.qFn = 'FW_multipleSetSelected(qArg, "%")';
o.qArg = o.newEl;
return o;
}
function
FW_multipleSetSelected(el, val)
{
if(typeof el == 'string')
el = document.getElementById(el);
var l = val.split(",");
for(var j=0;j<el.options.length;j++)
for(var i=0;i<l.length;i++)
if(el.options[j].value == l[i])
el.options[j].selected = true;
if(el.onchange)
el.onchange();
}
FW_widgets['multiple'] = {
selChange:FW_multipleSelChange
};

View File

@ -1,25 +1,16 @@
function
FW_textFieldUpdateLine(d)
{
var name = "textField."+d[0];
//console.log("Cmd "+d);
el = document.getElementById(name);
if(el) {
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);
@ -28,4 +19,3 @@ textField_setText(el,cmd)
FW_widgets['textField'] = {
updateLine:FW_textFieldUpdateLine
};