From 3e36752fc2a198cefeeb211056de73e8346948c1 Mon Sep 17 00:00:00 2001 From: squandor Date: Mon, 2 Jan 2017 22:23:34 +0100 Subject: [PATCH 1/3] changed default action for pushon button --- templates/switches.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/switches.html b/templates/switches.html index a4ebeae..bea5fcf 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -96,7 +96,8 @@ $(document).ready(function() { }); updateSwitches_block_{{count}}.push("{{v[0]}}"); {% elif (v[1] == "pushon") or (v[1] == "pushoff") %} - $('button[id="push_{{v[0]}}_block_{{count}}"]').click(function() { + $('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); changeSwitch(this, {{v[0]}}); }); {% elif (v[1] == "setpoint") %} From 4b532e00faee2b27fe09ece9e632f7dbd780891d Mon Sep 17 00:00:00 2001 From: squandor Date: Mon, 2 Jan 2017 22:40:30 +0100 Subject: [PATCH 2/3] added pushon and off to solve a little bug --- static/js/domoboard.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/static/js/domoboard.js b/static/js/domoboard.js index 0341b7b..51fdd52 100644 --- a/static/js/domoboard.js +++ b/static/js/domoboard.js @@ -22,6 +22,16 @@ function changeSwitch(checkboxElem, idx) { } } +// Switch functions +function changePush(idx, action) { + if (action == 'on') { + requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=On" ); + } else { + requestAPI(flask_server + "/api?type=command¶m=switchlight&idx=" + idx + "&switchcmd=Off" ); + } +} + + function refreshSwitches(updateSwitches, block) { $.each(updateSwitches, function (i, switchID) { var url = flask_server + "/api?type=devices&rid=" + switchID; From 1008c10be16a58e2a66202c86888ae113a4256b9 Mon Sep 17 00:00:00 2001 From: squandor Date: Mon, 2 Jan 2017 22:40:47 +0100 Subject: [PATCH 3/3] solved a little bug for the pushon and pushoff button --- templates/switches.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/templates/switches.html b/templates/switches.html index bea5fcf..635f67d 100644 --- a/templates/switches.html +++ b/templates/switches.html @@ -95,11 +95,16 @@ $(document).ready(function() { changeSwitch(this, {{v[0]}}); }); updateSwitches_block_{{count}}.push("{{v[0]}}"); - {% elif (v[1] == "pushon") or (v[1] == "pushoff") %} - $('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) { - e.preventDefault(); - changeSwitch(this, {{v[0]}}); - }); + {% elif (v[1] == "pushon") %} + $('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); + changePush({{v[0]}}, 'on'); + }); + {% elif (v[1] == "pushoff") %} + $('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) { + e.preventDefault(); + changePush({{v[0]}}, 'off'); + }); {% elif (v[1] == "setpoint") %} updateSetpoints_block_{{count}}.push("{{v[0]}}"); {% elif (v[1] == "dimmer" or v[1] == "rgb") %}