2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 16:46:35 +00:00

Slider for the dimmer

git-svn-id: https://svn.fhem.de/fhem/trunk@1472 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-04-22 10:26:04 +00:00
parent 650a2db82a
commit 5a0e7478f9
10 changed files with 134 additions and 30 deletions

View File

@ -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

View File

@ -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";

View File

@ -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";
}

View File

@ -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

View File

@ -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 "<form method=\"get\" action=\"$FW_ME$FW_subdir\">";
FW_pO FW_hidden("detail", $d);
FW_pO FW_hidden("dev.$cmd$d", $d);
FW_pO FW_submit("cmd.$cmd$d", $cmd) . "&nbsp;$d";
FW_pO FW_select("arg.$cmd$d",\@al, undef, $class,
FW_pO FW_submit("cmd.$cmd$d", $cmd, $class);
FW_pO "<div class=\"$class downText\">&nbsp;$d&nbsp;</div>";
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 "<script type=\"text/javascript\">" .
"FW_selChange('$selEl','$list','val.$cmd$d')</script>";
FW_pO "</form>";
}
@ -696,7 +705,8 @@ FW_doDetail($)
FW_pO "<table>";
foreach my $cmd (split(":", $webCmd)) {
FW_pO "<tr>";
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 "</tr>";
}
FW_pO "</table>";
@ -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/ /\&nbsp;/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 = "<select $jfn name=\"$n\" class=\"$class\">";
my ($n, $va, $def, $class, $jSelFn) = @_;
$jSelFn = ($jSelFn ? "onchange=\"$jSelFn\"" : "");
my $s = "<select $jSelFn name=\"$n\" class=\"$class\">";
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 ="<input type=\"submit\" name=\"$n\" value=\"$v\"/>";
my ($n, $v, $class) = @_;
$class = ($class ? "class=\"$class\"" : "");
my $s ="<input type=\"submit\" name=\"$n\" value=\"$v\" $class/>";
return $s;
}

View File

@ -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; }

View File

@ -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=
'<div class="slider"><div class="handle">'+min+'</div></div>'+
'<input type="hidden" name="'+name+'" value="'+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 **************/

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }