Fix for issue #46 created an link behind the dimmer name which switches the dimmer
This commit is contained in:
parent
5f46a40cf5
commit
bc49a88775
|
|
@ -22,6 +22,18 @@ function changeSwitch(checkboxElem, idx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dimmer functions
|
||||||
|
function changeDimmer(checkboxElem, idx) {
|
||||||
|
var chkurl = "/api?type=devices&rid=" + idx;
|
||||||
|
requestAPI(flask_server + chkurl, function(d) {
|
||||||
|
_json = JSON.parse(d);
|
||||||
|
if (_json['result'][0]['Data'] != 'Off') {
|
||||||
|
requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=Off&level=0");
|
||||||
|
} else {
|
||||||
|
requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=On&level=0");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
// Switch functions
|
// Switch functions
|
||||||
function changePush(idx, action) {
|
function changePush(idx, action) {
|
||||||
if (action == 'on') {
|
if (action == 'on') {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,11 @@
|
||||||
<table class="table" style="width: auto;">
|
<table class="table" style="width: auto;">
|
||||||
{% for k, v in blockArray[count]["switches"].iteritems() %}
|
{% for k, v in blockArray[count]["switches"].iteritems() %}
|
||||||
<tr>
|
<tr>
|
||||||
|
{% if "dimmer" in v[1] or "rgb" in v[1] %}
|
||||||
|
<td style="border-top: none; vertical-align: middle;"><a id="dim_{{count}}" style="cursor: pointer;"><label style="cursor: pointer;" class=""> {{k}}</label></a></td>
|
||||||
|
{% else %}
|
||||||
<td style="border-top: none; vertical-align: middle;"><label class=""> {{k}}</label></td>
|
<td style="border-top: none; vertical-align: middle;"><label class=""> {{k}}</label></td>
|
||||||
|
{% endif %}
|
||||||
<td style="border-top: none;">
|
<td style="border-top: none;">
|
||||||
{% if "switch" in v[1] %}
|
{% if "switch" in v[1] %}
|
||||||
<input id="switch_{{v[0]}}_block_{{count}}" type="checkbox" checked data-size="mini">
|
<input id="switch_{{v[0]}}_block_{{count}}" type="checkbox" checked data-size="mini">
|
||||||
|
|
@ -127,6 +131,10 @@ $(document).ready(function() {
|
||||||
{% elif (v[1] == "setpoint") %}
|
{% elif (v[1] == "setpoint") %}
|
||||||
updateSetpoints_block_{{count}}.push("{{v[0]}}");
|
updateSetpoints_block_{{count}}.push("{{v[0]}}");
|
||||||
{% elif (v[1] == "dimmer" or v[1] == "rgb") %}
|
{% elif (v[1] == "dimmer" or v[1] == "rgb") %}
|
||||||
|
$('#dim_{{count}}').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
changeDimmer(this, {{v[0]}});
|
||||||
|
});
|
||||||
updateDimmers_block_{{count}}.push("{{v[0]}}");
|
updateDimmers_block_{{count}}.push("{{v[0]}}");
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue