server/assets/production/scripts/countdown.js

1 line
No EOL
885 B
JavaScript

const countdown=document.getElementById("countdown"),counter=document.getElementById("counter"),daysContainer=document.getElementById("days"),hoursContainer=document.getElementById("hours"),minutesContainer=document.getElementById("minutes"),secondsContainer=document.getElementById("seconds");let shown=!1;function render(){let e=new Date,n=openDate-e;var t=6e4,o=36e5,r=864e5,d=Math.floor(n/r),a=Math.floor(n%r/o),l=Math.floor(n%o/t),s=Math.floor(n%t/1e3);d=String(d).length>=2?d:"0"+d,a=String(a).length>=2?a:"0"+a,l=String(l).length>=2?l:"0"+l,s=String(s).length>=2?s:"0"+s,openDate<=e&&enableReload?(console.log("FINISHED!"),window.location="/"):(daysContainer.textContent=d,hoursContainer.textContent=a,minutesContainer.textContent=l,secondsContainer.textContent=s),shown||setTimeout(()=>{countdown.style.opacity=1,shown=!0},300)}enableReload=!0,render(),setInterval(render,1e3);