Skip to content

Instantly share code, notes, and snippets.

@starzonmyarmz
Created November 7, 2011 16:50
Show Gist options
  • 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