diff --git a/fhem/CHANGED b/fhem/CHANGED index a86040d27..91a43e3fa 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -24,7 +24,7 @@ - feature: dummy got a setList attribute - feature: new module 02_RSS.pm - feature: at attribute alignTime added - - feature: FHEMWEB attribute values via dropdown + - feature: FHEMWEB attribute values via dropdown, slider for dimmer - 2011-12-31 (5.2) - bugfix: applying smallscreen attributes to firefox/opera diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index cc3a59cd9..ee2ebb22b 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -949,16 +949,13 @@ CUL_HM_Set($@) $cmd = "pct"; } elsif(!defined($h)) { - my $usg = "Unknown argument $cmd, choose one of " . - join(" ",sort keys %culHmGlobalSets); - $usg .= " ". join(" ",sort keys %{$culHmSubTypeSets{$st}}) - if($culHmSubTypeSets{$st}); - $usg .= " ". join(" ",sort keys %{$culHmModelSets{$md}}) - if($culHmModelSets{$md}); + my @arr = keys %culHmGlobalSets; + push @arr, keys %{$culHmSubTypeSets{$st}} if($culHmSubTypeSets{$st}); + push @arr, keys %{$culHmModelSets{$md}} if($culHmModelSets{$md}); + my $usg = "Unknown argument $cmd, choose one of ".join(" ",sort @arr); if($usg =~ m/ pct/) { - my $pct = join(" ", (0..100)); - $usg =~ s/ pct/ $pct/; + $usg =~ s/ pct/ pct:slider,0,1,100/; } elsif($md eq "HM-CC-TC") { my @list = map { ($_.".0", $_+0.5) } (6..30); @@ -969,6 +966,9 @@ CUL_HM_Set($@) return $usg; + } elsif($cmd eq "pct") { + splice @a, 1, 1; + } elsif($h eq "" && @a != 2) { return "$cmd requires no parameters"; diff --git a/fhem/FHEM/10_FS20.pm b/fhem/FHEM/10_FS20.pm index 8109636c4..df9b5bca1 100755 --- a/fhem/FHEM/10_FS20.pm +++ b/fhem/FHEM/10_FS20.pm @@ -184,6 +184,12 @@ FS20_Set($@) return "no set value specified" if($na < 2 || $na > 3); return "Readonly value $a[1]" if(defined($readonly{$a[1]})); + if($na > 2 && $a[1] eq "dim") { + $a[1] = ($a[2] eq "0" ? "off" : "dim$a[2]%"); + splice @a, 2, 1; + $na = int(@a); + } + my $c = $fs20_c2b{$a[1]}; my $name = $a[0]; if(!defined($c)) { @@ -197,7 +203,8 @@ FS20_Set($@) if($mt && $mt eq "simple"); } return "Unknown argument $a[1], choose one of " . - join(" ", sort keys %fs20_c2b); + join(" ", sort keys %fs20_c2b) . + " dim:slider,0,6.25,100"; } diff --git a/fhem/TODO b/fhem/TODO index eeb1734a6..a4700ea87 100644 --- a/fhem/TODO +++ b/fhem/TODO @@ -1,9 +1,6 @@ FHEM: - FHEM2FHEM reconnect - HomeMatic set log 2 - -- autodetect physical hardware -- RFR: Error message for uncomplete last message - implement wiki decisions Webpgm2 diff --git a/fhem/webfrontend/pgm2/01_FHEMWEB.pm b/fhem/webfrontend/pgm2/01_FHEMWEB.pm index ad4715761..a7afe5087 100755 --- a/fhem/webfrontend/pgm2/01_FHEMWEB.pm +++ b/fhem/webfrontend/pgm2/01_FHEMWEB.pm @@ -26,7 +26,7 @@ sub FW_showLog($); sub FW_showRoom(); sub FW_showWeblink($$$$); sub FW_style($$); -sub FW_submit($$); +sub FW_submit($$@); sub FW_substcfg($$$$$$); sub FW_textfield($$$); sub FW_updateHashes(); @@ -668,13 +668,22 @@ FW_makeSelect($$$$) return if(!$list || $FW_hiddenroom{input}); my @al = sort map { s/:.*//;$_ } split(" ", $list); + my $selEl = $al[0]; + $selEl = $1 if($list =~ m/([^ ]*):slider,/); # if available + $selEl = "room" if($list =~ m/room:/); + FW_pO "
"; FW_pO FW_hidden("detail", $d); FW_pO FW_hidden("dev.$cmd$d", $d); - FW_pO FW_submit("cmd.$cmd$d", $cmd) . " $d"; - FW_pO FW_select("arg.$cmd$d",\@al, undef, $class, + FW_pO FW_submit("cmd.$cmd$d", $cmd, $class); + FW_pO "
 $d 
"; + FW_pO FW_select("arg.$cmd$d",\@al, $selEl, $class, "FW_selChange(this.options[selectedIndex].text,'$list','val.$cmd$d')"); FW_pO FW_textfield("val.$cmd$d", 30, $class); + + # Initial setting + FW_pO ""; FW_pO "
"; } @@ -696,7 +705,8 @@ FW_doDetail($) FW_pO ""; foreach my $cmd (split(":", $webCmd)) { FW_pO ""; - FW_pH "cmd.$d=set $d $cmd&detail=$d", ReplaceEventMap($d,$cmd,1), 1, "col1"; + FW_pH "cmd.$d=set $d $cmd&detail=$d", + ReplaceEventMap($d,$cmd,1), 1, "col1"; FW_pO ""; } FW_pO "
"; @@ -707,10 +717,12 @@ FW_doDetail($) FW_makeTable($d, $defs{$d}); FW_pO "Readings" if($defs{$d}{READINGS}); FW_makeTable($d, $defs{$d}{READINGS}); + my $attrList = getAllAttr($d); my $roomList = join(",", sort keys %FW_rooms); $roomList=~s/ /\ /g; $attrList =~ s/room /room:$roomList /; + FW_makeSelect($d, "attr", $attrList,"attr"); FW_makeTable($d, $attr{$d}, "deleteattr"); @@ -1282,9 +1294,9 @@ FW_hidden($$) sub FW_select($$$$@) { - my ($n, $va, $def,$class,$jfn) = @_; - $jfn = ($jfn ? "onchange=\"$jfn\"" : ""); - my $s = ""; foreach my $v (@{$va}) { if($def && $v eq $def) { @@ -1309,10 +1321,11 @@ FW_textfield($$$) ################## sub -FW_submit($$) +FW_submit($$@) { - my ($n, $v) = @_; - my $s =""; + my ($n, $v, $class) = @_; + $class = ($class ? "class=\"$class\"" : ""); + my $s =""; return $s; } diff --git a/fhem/webfrontend/pgm2/darkstyle.css b/fhem/webfrontend/pgm2/darkstyle.css index 27eafbb2b..c1d3e78cb 100644 --- a/fhem/webfrontend/pgm2/darkstyle.css +++ b/fhem/webfrontend/pgm2/darkstyle.css @@ -36,3 +36,10 @@ h2,h3,h4 { color:#EEE; line-height:1.3; margin-top:1.5em; font-family:Verdana; } select.attr,input.attr,select.set,input.set { margin-bottom:10px; } a img { border-style:none; } + +.set,.attr { margin-bottom:10px; float:left; } +.slider { float:right; width:250px; height:26px; background:#F0F0D8; + margin-left:10px; -moz-border-radius:8px; border-radius:8px; } +.handle { position:absolute; cursor:pointer; width:50px; height:20px; line-height:20px; + border:3px solid; color:white; text-align:center; } +.downText { margin-top:2px; } diff --git a/fhem/webfrontend/pgm2/fhemweb.js b/fhem/webfrontend/pgm2/fhemweb.js index 1efcfee62..220273537 100644 --- a/fhem/webfrontend/pgm2/fhemweb.js +++ b/fhem/webfrontend/pgm2/fhemweb.js @@ -48,7 +48,49 @@ FW_delayedStart() { setTimeout("FW_longpoll()", 1000); } +/*************** LONGPOLL END **************/ +/*************** SLIDER **************/ +function +Slider(slider, min, stp, max) +{ + var sh = slider.firstChild; + var lastX=-1, offX=-1, minX, maxX, val=-1; + + sh.onselectstart = function() { return false; } + sh.onmousedown = function(e) { + var oldMoveFn = document['onmousemove']; + var oldUpFn = document['onmouseup']; + + if(offX == -1) { + minX = offX = slider.offsetLeft; + maxX = minX+slider.offsetWidth-sh.offsetWidth; + } + lastX = e.clientX; + + document['onmousemove'] = function(e) { + var diff = e.clientX-lastX; lastX = e.clientX; + offX += diff; + if(offX < minX) offX = minX; + if(offX > maxX) offX = maxX; + val = min+((offX-minX)/(maxX-minX) * (max-min)); + val = Math.floor(Math.floor(val/stp)*stp); + sh.innerHTML = val; + sh.setAttribute('style', 'left:'+offX+'px;'); + } + + document.onmouseup = function(e) { + document['onmousemove'] = oldMoveFn; + document['onmouseup'] = oldUpFn; + slider.nextSibling.setAttribute('value', val); + }; + }; + +} + + +/*************** Select **************/ +/** Change attr/set argument type to input:text or select **/ function FW_selChange(sel, list, elName) { @@ -62,17 +104,34 @@ FW_selChange(sel, list, elName) } var el = document.getElementsByName(elName)[0]; + var name = el.getAttribute('name'); + if(value==undefined) { newEl = document.createElement('input'); newEl.type='text'; newEl.size=30; + } else { - newEl = document.createElement('select'); - var vArr = value.split(","); - for(var j=0; j < vArr.length; j++) { - newEl.options[j] = new Option(vArr[j], vArr[j]); + var vArr = value.split(","); + if(vArr.length == 4 && vArr[0] == "slider") { + var min=parseFloat(vArr[1]), + stp=parseFloat(vArr[2]), + max=parseFloat(vArr[3]); + newEl = document.createElement('div'); + newEl.innerHTML= + '
'+min+'
'+ + ''; + Slider(newEl.firstChild, min, stp, max); + + } else { + newEl = document.createElement('select'); + for(var j=0; j < vArr.length; j++) { + newEl.options[j] = new Option(vArr[j], vArr[j]); + } } } - newEl.class=el.class; newEl.name=el.name; + + newEl.setAttribute('class', el.getAttribute('class')); //changed from el.class + newEl.setAttribute('name', el.getAttribute('name')); el.parentNode.replaceChild(newEl, el); + } -/*************** LONGPOLL END **************/ diff --git a/fhem/webfrontend/pgm2/smallscreenstyle.css b/fhem/webfrontend/pgm2/smallscreenstyle.css index 43b8a6b9f..2bfb7f75b 100644 --- a/fhem/webfrontend/pgm2/smallscreenstyle.css +++ b/fhem/webfrontend/pgm2/smallscreenstyle.css @@ -58,3 +58,11 @@ h2,h3,h4 { color:#52865D; line-height:1.3; margin-top:1.5em; font-family:Arial,Sans-serif; } div#block { border:1px solid gray; background: #F8F8E0; padding:0.7em; } div#dist { padding-top:0.3em; } + + +.set,.attr { margin-bottom:5px; float:left; } +.slider { float:right; width:250px; height:26px; background:#F0F0D8; + margin-left:10px; -moz-border-radius:8px; border-radius:8px; } +.handle { position:absolute; cursor:pointer; width:50px; height:20px; line-height:20px; + border:3px solid; color:#278727; text-align:center; } +.downText { margin-top:2px; } diff --git a/fhem/webfrontend/pgm2/style.css b/fhem/webfrontend/pgm2/style.css index 56ca3e45b..e1016815d 100644 --- a/fhem/webfrontend/pgm2/style.css +++ b/fhem/webfrontend/pgm2/style.css @@ -29,5 +29,11 @@ h2,h3,h4 { color:#52865D; line-height:1.3; div#block { border:1px solid gray; background: #F8F8E0; padding:0.7em; } div#dist { padding-top:0.3em; } -select.attr,input.attr,select.set,input.set { margin-bottom:5px; } a img { border-style:none; } + +.set,.attr { margin-bottom:5px; float:left; } +.slider { float:right; width:250px; height:26px; background:#F0F0D8; + margin-left:10px; -moz-border-radius:8px; border-radius:8px; } +.handle { position:absolute; cursor:pointer; width:50px; height:20px; line-height:20px; + border:3px solid; color:#278727; text-align:center; } +.downText { margin-top:2px; } diff --git a/fhem/webfrontend/pgm2/touchpadstyle.css b/fhem/webfrontend/pgm2/touchpadstyle.css index 02f39962b..7f812e4d2 100644 --- a/fhem/webfrontend/pgm2/touchpadstyle.css +++ b/fhem/webfrontend/pgm2/touchpadstyle.css @@ -23,3 +23,10 @@ table { -moz-border-radius:8px; border-radius:8px; } table#room { border:1px solid gray; width: 100%; background: #D7FFFF; } table#room tr.sel { background: #A0FFFF; } + +.set,.attr { margin-bottom:5px; float:left; } +.slider { float:right; width:250px; height:26px; background:#F0F0D8; + margin-left:10px; -moz-border-radius:8px; border-radius:8px; } +.handle { position:absolute; cursor:pointer; width:50px; height:20px; line-height:20px; + border:3px solid; color:#278727; text-align:center; } +.downText { margin-top:2px; }