diff --git a/static/index.html b/static/index.html index 106b2ef..455da48 100644 --- a/static/index.html +++ b/static/index.html @@ -203,15 +203,22 @@ }; light.element.onclick=function(light){ return function(){ - client.publish(light.mqtt_path + "/toggle", "true"); + var toggle_request = new XMLHttpRequest(); + toggle_request.open("POST", "/light/" + light.id + "/on/toggle", true); + toggle_request.send(JSON.stringify(true)); }; }(light); }; - //document.getElementById("up").onclick = function(){ - // for (i = 1; i <= 8; i++) { - // client.publish("devices/light_904649/light_" + i + "/on/set", 'true'); - // }; - //}; + document.getElementById("up").onclick = function(lights){ + return function ( lights ) { + for ( i in lights ) { + light = lights[i]; + var toggle_request = new XMLHttpRequest(); + toggle_request.open("POST", "/light/" + light.id + "/on/set", true); + toggle_request.send(JSON.stringify(true)); + }; + }; + }(lights); }; client.connect({