Created
February 22, 2019 15:36
-
-
Save thebecwar/acbccb3455441a764f0da4f2c07d52ee to your computer and use it in GitHub Desktop.
Stone counter
This file contains hidden or 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
var gagStarted = new Date('2019-02-21T15:00:00+05:00'); | |
function setupTimer() { | |
var timerSpan = document.createElement('span'); | |
timerSpan.setAttribute('id', 'gag-time-content'); | |
timerSpan.innerText = 'It has been 0 days, 0 hours, 0 minutes and 0 seconds since Roger Stone last violated his gag order'; | |
var parent = document.getElementById('gag-timer'); | |
if (parent) { | |
parent.appendChild(timerSpan); | |
} | |
} | |
function updateTimer() { | |
var element = document.getElementById('gag-time-content'); | |
if (element) { | |
var now = new Date(); | |
var seconds = (now.getTime() - gagStarted.getTime()) / 1000; | |
var days = Math.floor(seconds / 86400); | |
seconds = seconds - (days * 86400); | |
var hours = Math.floor(seconds / 3600); | |
seconds = seconds - (hours * 3600); | |
var minutes = Math.floor(seconds / 60); | |
seconds = Math.floor(seconds - (minutes * 60)); | |
var content = 'It has been ' + days + ' days ' + hours + ' hours ' + minutes + ' minutes and ' + seconds + ' seconds since Roger Stone last violated his gag order.'; | |
element.innerText = content; | |
} | |
} | |
window.onload = function() { | |
setupTimer(); | |
setInterval(updateTimer, 1000); | |
}; |
This file contains hidden or 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
<!-- Insert this wherever you want the timer to be --> | |
<div id='gag-timer' /> | |
<!-- put this in <head> --> | |
<script type='text/javascript' src='counter.js'></script> | |
<!-- or you can copy and paste the JS into the block --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The counter's text can be styled with the css selector
#gag-time-content