diff --git a/VERSION.md b/VERSION.md index ee90284..90a27f9 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -1.0.4 +1.0.5 diff --git a/static/js/domoboard.js b/static/js/domoboard.js index 37f050b..4233c39 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -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; diff --git a/templates/switches.html b/templates/switches.html index 36a5b22..efc9c1a 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -45,6 +45,10 @@ {% elif "setpoint_slider" in v[2] %} + {% elif "selector" in v[2] %} +
+
+
{% elif "rgb" in v[2] %}  

@@ -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 = ''; + $('#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") %}