meraproject/lib/js/flip-clock/examples/test.html

47 lines
1.2 KiB
HTML
Raw Permalink Normal View History

<html>
<head>
<link rel="stylesheet" href="../compiled/flipclock.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../compiled/flipclock.js"></script>
</head>
<body>
<div class="clock" style="margin:2em;"></div>
<script type="text/javascript">
var clock;
$(document).ready(function() {
// Set dates.
var futureDate = new Date("October 9, 2014 12:02 PM EDT");
var currentDate = new Date();
// Calculate the difference in seconds between the future and current date
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
// Calculate day difference and apply class to .clock for extra digit styling.
function dayDiff(first, second) {
return (second-first)/(1000*60*60*24);
}
if (dayDiff(currentDate, futureDate) < 100) {
$('.clock').addClass('twoDayDigits');
} else {
$('.clock').addClass('threeDayDigits');
}
if(diff < 0) {
diff = 0;
}
// Instantiate a coutdown FlipClock
clock = $('.clock').FlipClock(diff, {
clockFace: 'DailyCounter',
countdown: true
});
});
</script>
</body>
</html>