Last active
August 29, 2015 14:02
-
-
Save Flygenring/f96418595d5ac0f5fa5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var id = window.setTimeout(function() {}, 0); | |
while(id--) { | |
window.clearTimeout(id); | |
}; | |
var delay = 1000, // delay in ms | |
correction_24 = 255 / 24, | |
correction_60 = 255 / 60; | |
refreshData = function() { | |
var d = new Date() | |
var h = d.getHours(); | |
var m = d.getMinutes(); | |
var s = d.getSeconds(); | |
if(h < 10) {h = '0' + h}; | |
if(m < 10) {m = '0' + m}; | |
if(s < 10) {s = '0' + s}; | |
hex_h = ('0' + Math.round(h * correction_24).toString(16)).slice(-2); | |
hex_m = ('0' + Math.round(m * correction_60).toString(16)).slice(-2); | |
hex_s = ('0' + Math.round(s * correction_60).toString(16)).slice(-2); | |
var color = '#' + hex_h + hex_m + hex_s; | |
$("div.background").css("background-color", color); | |
$("p#hex").html('#' + h + m + s + '<br><small><small><small>(really ' + color + ')</small></small></small>'); | |
setTimeout(refreshData, delay); | |
}; | |
refreshData(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make #HexClock (http://www.jacopocolo.com/hexclock ) go full spectrum.