Skip to content

Instantly share code, notes, and snippets.

@dasl-
Created April 14, 2017 20:45
Show Gist options
  • Save dasl-/9510e12f17c441d5cc89e31e1a630d38 to your computer and use it in GitHub Desktop.
Save dasl-/9510e12f17c441d5cc89e31e1a630d38 to your computer and use it in GitHub Desktop.
function dimLight(light) {
var $light = $(".api_light_dim[data-light-id='" + light + "']");
var value = Math.floor(Math.random() * (255 - 0)) + 0;
$light.val(value);
$light.trigger("change");
}
window.setInterval(function(){
var light = Math.floor(Math.random() * (7 - 1)) + 1;
dimLight(light);
},300);
function changeColor(light) {
var hex = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'];
var color = "#";
for (var i = 0; i < 6; i++) {
var index = Math.floor(Math.random() * (15 - 0)) + 0;
color += hex[index];
}
var $light = $(".api_light_color[data-light-id='" + light + "']");
$light.val(color);
$light.trigger("input");
}
window.setInterval(function(){
var light = Math.floor(Math.random() * (7 - 1)) + 1;
changeColor(light);
},400);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment