Skip to content

Instantly share code, notes, and snippets.

@starzonmyarmz
Created November 7, 2011 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starzonmyarmz/1345491 to your computer and use it in GitHub Desktop.
Save starzonmyarmz/1345491 to your computer and use it in GitHub Desktop.
// Countdown Clock
function countdown(action) {
function countItDown() {
var cd = $('#countdown');
if (cd.val() > 0) {
cd.val(cd.val() - 1);
setTimeout(countItDown, 1000);
} else {
clearTimeout();
}
}
// Starts Countdown
if (action === 'play') {
setTimeout(countItDown, 1000);
}
// Stops Countdown (manually triggered)
if (action === 'stop') {
clearTimeout();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment