Created
April 26, 2014 07:20
-
-
Save sebgod/11313905 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-GB" xml:lang="en-GB"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<title>Binary Clock in Unicode</title> | |
<style type='text/css'> | |
body { | |
margin: 0; | |
background-color: #000000; | |
width: 100%; | |
height: 100%; | |
} | |
.led-clock { | |
margin: 0; | |
padding: 0; | |
line-height: 15px; | |
} | |
.led-clock-pink { | |
color: #ff00dd; | |
text-shadow: 1px 1px #FF0011; | |
} | |
</style> | |
<script type='text/javascript'> | |
function pad6(number) { | |
var length = 6; | |
var bin = ("00000" + number.toString(2)).slice(-1 * length); | |
var utf16 = new ArrayBuffer(length * 2); | |
var utf16View = new Uint16Array(utf16); | |
for (var i = 0; i < length; ++i) { | |
utf16View[i] = 9898 + (bin.charAt(i) - '0'); | |
} | |
return String.fromCharCode.apply(null, utf16View); | |
} | |
function createBinaryClockDisplay(elementId) { | |
var displayElement = document.getElementById(elementId); | |
displayElement.className += ' led-clock-pink'; | |
var hourElement = document.createTextNode("hours"); | |
var minutesElement = document.createTextNode("minute"); | |
var secondsElement = document.createTextNode("second"); | |
displayElement.appendChild(hourElement); | |
displayElement.appendChild(document.createElement("br")) | |
displayElement.appendChild(minutesElement) | |
displayElement.appendChild(document.createElement("br")) | |
displayElement.appendChild(secondsElement); | |
var updateDisplay = function () { | |
var time = new Date(); | |
hourElement.textContent = pad6(time.getHours()); | |
minutesElement.textContent = pad6(time.getMinutes()); | |
secondsElement.textContent = pad6(time.getSeconds()); | |
}; | |
updateDisplay(); | |
var binTimeTimer = setInterval(updateDisplay, 1000); | |
} | |
window.onload = function () { | |
createBinaryClockDisplay("binaryClockDisplay"); | |
} | |
</script> | |
</head> | |
<body> | |
<span id="binaryClockDisplay" class="led-clock"></span> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment