Created
June 23, 2012 06:58
-
-
Save johnjelinek/2977199 to your computer and use it in GitHub Desktop.
countdown in coffeescript
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
counter = (futureDate) -> | |
today = new Date | |
count = Math.floor (futureDate - today) / 1000 | |
countdown = setInterval -> | |
$("#d").html Math.floor count / ( 60 * 60 * 24 ) | |
temp = count % ( 60 * 60 * 24 ) | |
$("#h").html Math.floor temp / ( 60 * 60 ) | |
temp = count % ( 60 * 60 ) | |
$("#m").html Math.floor temp / 60 | |
temp = count % 60 | |
$("#s").html temp | |
counter new Date today.getFullYear(), today.getMonth(), today.getDate() + 1 if count isnt 0 | |
count-- | |
, 1000 | |
today = new Date today | |
counter new Date today.getFullYear(), today.getMonth(), today.getDate() + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment