var intervalId1 = "";
var intervalId2 = "";
var intervalTime = 1000;
$(document).ready(function() {
intervalId1 = setInterval("start_clock1()", intervalTime);
intervalId2 = setInterval("start_clock2()",intervalTime);
});
var on = "<img src='http://codepen.myxotod.de/binary-clock/dot_on.jpg' alt='' />";
var off = "<img src='http://codepen.myxotod.de/binary-clock/dot_off.jpg' alt='' />";
function start_clock1() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
var zero = off+off+off+off;
var one = off+off+off+on;
var two = off+off+on+off;
var three = off+off+on+on;
var four = off+on+off+off;
var five = off+on+off+on;
var six = off+on+on+off;
var seven = off+on+on+on;
var eigth = on+off+off+off;
var nine = on+off+off+on;
switch (currentHours) {
case 0:
$('#hour_left').html(zero);
$('#hour_right').html(zero);
break;
case 1:
$('#hour_left').html(zero);
$('#hour_right').html(one);
break;
case 2:
$('#hour_left').html(zero);
$('#hour_right').html(two);
break;
case 3:
$('#hour_left').html(zero);
$('#hour_right').html(three);
break;
case 4:
$('#hour_left').html(zero);
$('#hour_right').html(four);
break;
case 5:
$('#hour_left').html(zero);
$('#hour_right').html(five);
break;
case 6:
$('#hour_left').html(zero);
$('#hour_right').html(six);
break;
case 7:
$('#hour_left').html(zero);
$('#hour_right').html(seven);
break;
case 8:
$('#hour_left').html(zero);
$('#hour_right').html(eigth);
break;
case 9:
$('#hour_left').html(zero);
$('#hour_right').html(nine);
break;
case 10:
$('#hour_left').html(one);
$('#hour_right').html(zero);
break;
case 11:
$('#hour_left').html(one);
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.