Skip to content

Instantly share code, notes, and snippets.

@Paratron
Created February 12, 2013 09:14
Show Gist options
  • Save Paratron/4761128 to your computer and use it in GitHub Desktop.
Save Paratron/4761128 to your computer and use it in GitHub Desktop.
/**
* 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