Added Selector switch feature #53
This commit is contained in:
parent
fe698a2f18
commit
8a298ec443
|
|
@ -1 +1 @@
|
|||
1.0.4
|
||||
1.0.5
|
||||
|
|
|
|||
|
|
@ -21,6 +21,21 @@ function changeSwitch(checkboxElem, idx) {
|
|||
requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=Off" );
|
||||
}
|
||||
}
|
||||
|
||||
// switchSelector
|
||||
function switchSelector(idx, lvl, bid) {
|
||||
url = '/api?type=devices&rid=' + idx;
|
||||
requestAPI(flask_server + url, function(d) {
|
||||
r = JSON.parse(d);
|
||||
last_active = r['result'][0]['Level'];
|
||||
if (last_active != 0) {
|
||||
last_active = last_active + 0;
|
||||
}
|
||||
$('#' + bid + last_active).removeClass('btn-primary');
|
||||
$('#' + bid + lvl).addClass('btn-primary');
|
||||
requestAPI(flask_server + '/api?type=command¶m=switchlight&idx=' + idx + '&switchcmd=Set%20Level&level=' + lvl + '&passcode=');
|
||||
});
|
||||
}
|
||||
// Dimmer functions
|
||||
function changeDimmer(checkboxElem, idx) {
|
||||
var chkurl = "/api?type=devices&rid=" + idx;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@
|
|||
</div>
|
||||
{% elif "setpoint_slider" in v[2] %}
|
||||
<input id="setpoint_slider{{v[1]}}_block_{{count}}" data-slider-id='stpnt_{{v[1]}}_block_{{count}}' type="text" state="on" data-slider-min="{{v[3]}}" data-slider-max="{{v[4]}}" data-slider-step="0.5" />
|
||||
{% elif "selector" in v[2] %}
|
||||
<div class="btn-toolbar">
|
||||
<div id="selector_body_{{v[1]}}_block_{{count}}" class="btn-group pull-right" style="width: 100%;"> </div>
|
||||
</div>
|
||||
{% elif "rgb" in v[2] %}
|
||||
<input id="dimmer_{{v[1]}}_block_{{count}}" data-slider-id='dim_{{v[1]}}_block_{{count}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
|
||||
<br><br>
|
||||
|
|
@ -132,6 +136,30 @@ $(document).ready(function() {
|
|||
e.preventDefault();
|
||||
changeScene({{v[1]}}, 'on');
|
||||
});
|
||||
{% elif (v[2] == "selector") %}
|
||||
url = '/api?type=devices&rid=' + {{v[1]}};
|
||||
requestAPI(flask_server + url, function(d) {
|
||||
r = JSON.parse(d);
|
||||
btns = r['result'][0]['LevelNames'].split('|');
|
||||
$.each(btns, function (i, lvlname) {
|
||||
activebtn = r['result'][0]['Level']
|
||||
if (i != '0') {
|
||||
i = i + '0';
|
||||
}
|
||||
if (activebtn == i) {
|
||||
btnClass = 'btn btn-primary btn-responsive';
|
||||
} else {
|
||||
btnClass = 'btn btn-responsive';
|
||||
}
|
||||
bid = 'selector_{{v[1]}}_block_{{count}}_index_';
|
||||
b = '<button id="' + bid + i + '" class="' + btnClass + '">' + lvlname + '</button>';
|
||||
$('#selector_body_{{v[1]}}_block_{{count}}').append(b);
|
||||
$('#' + bid + i).click(function(e) {
|
||||
e.preventDefault();
|
||||
switchSelector({{v[1]}}, i, bid);
|
||||
});
|
||||
});
|
||||
});
|
||||
{% elif (v[2] == "setpoint") %}
|
||||
updateSetpoints_block_{{count}}.push("{{v[1]}}");
|
||||
{% elif (v[2] == "setpoint_slider") %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue