Skip to content

Instantly share code, notes, and snippets.

@hfhchan
Last active September 29, 2018 08:35
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 hfhchan/87c15984aafd87cf605e4e2ae44bc5a5 to your computer and use it in GitHub Desktop.
Save hfhchan/87c15984aafd87cf605e4e2ae44bc5a5 to your computer and use it in GitHub Desktop.
Flashing Countdown Timer
target = new Date(2018, 8, 29, 17, 30, 0);
document.body.style.textAlign='center';document.body.style.color = 'green';document.body.style.font='bold 280px/1.1 Roboto,sans-serif';show=true;
window.setInterval(() => {
minsLeft = (target-(new Date())) / 60000;
document.body.innerHTML = `${Math.floor(minsLeft)} minutes left`;
if (minsLeft < 10) {
document.body.style.color = 'red';
show=!show;
}
document.body.style.display = show? 'block' : 'none'
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment