Created
February 12, 2013 09:14
-
-
Save Paratron/4761128 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
/** | |
* Short Countdown | |
* =============== | |
* This is my try of a short JavaScript Countdown. | |
* Line breaks and identation added for better reading. | |
* Line 2 could be boiled down to: | |
* e = +new d()+36E5; | |
* But the way it is right now makes it much easier to tweak the duration. | |
* | |
* Character count with whitespace trimmed: 178. | |
* | |
* @author: Christian Engel <@paratron> | |
*/ | |
!function(d,k,r,e,l){ | |
e = +new d()+3.6*k*k; | |
setInterval(function(){ | |
r = -(+new d() - e); | |
console.log([864E4,36E5,6E4,k].map(function(t){ | |
return [l = ~~(r/t), r -= l*t][0]; | |
}).join(':')); | |
}, k) | |
}(Date,1E3); | |
/** | |
* Trimmed version | |
*/ | |
!function(d,k,r,e,l){e=+new d+3.6*k*k;setInterval(function(){r=-(+new d-e);console.log([864E4,36E5,6E4,k].map(function(t){return[l=~~(r/t),r-=l*t][0]}).join(":"))},k)}(Date,1E3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment