2017-12-17 15:38:12 -08:00
|
|
|
(function(){
|
|
|
|
|
2017-12-17 17:58:44 -08:00
|
|
|
document.querySelectorAll('[data-countdown-to]').forEach(function(el) {
|
2017-12-17 19:15:13 -08:00
|
|
|
var expires = +el.dataset.countdownTo
|
2017-12-17 15:38:12 -08:00
|
|
|
|
|
|
|
function update() {
|
|
|
|
var left = expires - (+new Date()/1000|0)
|
|
|
|
if (left > 0) el.innerHTML = 'in ' + formatDur(left)
|
|
|
|
else location.reload()
|
|
|
|
}
|
|
|
|
update()
|
|
|
|
setInterval(update, 1000)
|
|
|
|
})
|
|
|
|
|
|
|
|
function formatDur(x) {
|
|
|
|
var h=x/3600|0, m=x%3600/60|0, s=x%60
|
|
|
|
return ''+(h>0?h+':':'')+(m<10&&h>0?'0':'')+m+':'+(s<10?'0':'')+s
|
|
|
|
}
|
|
|
|
|
|
|
|
})()
|