Skip to content

Instantly share code, notes, and snippets.

@veltman
Created January 3, 2014 18:59
Show Gist options
  • Save veltman/8244146 to your computer and use it in GitHub Desktop.
Save veltman/8244146 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Is it Match Day yet?</title>
<meta charset="utf-8">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
<style>
body {
font-size: 48px;
font-weight: bold;
text-align: center;
font-family: "Open Sans", Helvetica, Arial, Verdana, sans-serif;
color: #222;
}
div#top {
font-size: 1.5em;
}
div#time {
color: #222;
}
div#time span {
color: #666;
}
div#answer {
margin: 24px 0px;
font-size: 2em;
color: #c00;
}
div#answer.yes {
color: steelblue;
}
@media (max-width: 1080px) {
body {
font-size: 36px;
}
}
@media (max-width: 780px) {
body {
font-size: 26px;
}
}
</style>
</head>
<body>
<div class="container">
<div id="top">Is it match day yet?</div>
<div id="answer">NO</div>
<div id="time"><span id="days"></span> days, <span id="hours"></span> hours, <span id="minutes"></span> minutes, <span id="seconds"></span> seconds</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
<script>
var match = moment.utc([2014,0,14,20]);
var interval;
$days = $("#days");
$hours = $("#hours");
$minutes = $("#minutes");
$seconds = $("#seconds");
update();
interval = setInterval(update,1000);
function update() {
var current = moment.utc();
var diff = match.diff(current);
if (diff < 0) {
$("div#answer").html("YES").addClass("yes");
$("div#time").hide();
clearInterval(interval);
}
var days = Math.floor(diff/86400000);
var hours = Math.floor((diff % 86400000)/3600000);
var minutes = Math.floor((diff % 3600000)/60000);
var seconds = Math.floor((diff % 60000)/1000);
$days.html(days);
$hours.html(hours);
$minutes.html(minutes);
$seconds.html(seconds);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment