Last active
April 22, 2016 08:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeGroupState() { | |
// Get the button and the slider | |
var button = document.getElementById(event.target.id); | |
var slider = document.getElementById("slider"+event.target.id); | |
var state; | |
state = changeButtonState(button); | |
var brightness; | |
if (state) { | |
brightness = 254; | |
} else { | |
brightness = 0; | |
} | |
$(("#"+slider.id)).slider('setValue', brightness); | |
// Generate URL | |
var url = ip+"/hue/group?id="+button.id+"&state="+state | |
put(url); | |
} | |
/* Put data on the bridge */ | |
function put(url, data) { | |
$.ajax({ | |
type: "POST", | |
url: url, | |
data: data, | |
contentType: "application/json; charset=utf-8", | |
crossDomain: true, | |
dataType: "json", | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment