Created
September 3, 2016 21:25
-
-
Save chtzvt/e670b5be65c4411fbf822ef393b26b2e to your computer and use it in GitHub Desktop.
Displays the latest Cheerlights color in your web browser
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
<head> | |
<!-- | |
Cheerlights for the Web. | |
Created by Charlton Trezevant (2016), MIT License | |
What is Cheerlights? See http://cheerlights.com | |
Live Demo: http://cheerlights.ctis.me | |
--> | |
<title>Cheerlights</title> | |
<script src="https://code.jquery.com/jquery-1.10.2.js"></script> | |
<script src="https://code.jquery.com/color/jquery.color-2.1.2.min.js"></script> | |
<style> | |
body { background-color: #ffffff } | |
</style> | |
</head> | |
<body> | |
<script> | |
function updateColor() { | |
var colors = { | |
url: 'http://api.thingspeak.com/channels/1417/field/2/last.json', | |
success: function(data) { | |
var latestColor = data.field2; | |
$('body').animate({ | |
backgroundColor: latestColor | |
}, 'slow'); | |
} | |
}; | |
$.ajax(colors); | |
} | |
$(document).ready(function() { | |
setInterval(updateColor, 2000); | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment