| 1 |
document.addEventListener("DOMContentLoaded",(function(){document.querySelectorAll(".wp-block-gutenify-countdown-timer").forEach((function(t){const e=t.getAttribute("data-timestamp"),n=t.getAttribute("data-end-action")||"hide",r=t.getAttribute("data-hide-selector")||".gutenify-countdown-timer-hide",o=t.getAttribute("data-redirect-url")||"",a=t.getAttribute("data-type")||"fixed",i=t.getAttribute("data-post-id")||"",d=parseInt(t.getAttribute("data-evergreen-hours")||"0",10),u=parseInt(t.getAttribute("data-evergreen-minutes")||"0",10),s="true"===t.getAttribute("data-evergreen-restart");let c;if("evergreen"===a){const t="liger_countdown_timer_start_"+i+"_"+d+"_"+u;let e=localStorage.getItem(t);if(s&&e){const n=1e3*(3600*d+60*u);Date.now()>parseInt(e,10)+n&&(e=null,localStorage.removeItem(t))}e||(e=Date.now(),localStorage.setItem(t,e));const n=1e3*(3600*d+60*u);c=parseInt(e,10)+n}else{if(!e)return;c=1e3*e}const l=new Date(c),g=t.querySelector(".days"),f=t.querySelector(".hours"),m=t.querySelector(".minutes"),h=t.querySelector(".seconds");function S(){const t=function(){const t=l.getTime()-Date.now();return{total:t,days:Math.floor(t/864e5),hours:Math.floor(t/36e5%24),minutes:Math.floor(t/1e3/60%60),seconds:Math.floor(t/1e3%60)}}();if(t.total<=0)return g.innerHTML="00",f.innerHTML="00",m.innerHTML="00",h.innerHTML="00",clearInterval(y),void("redirect"===n&&o?/^https?:\/\//i.test(o)&&(window.location.href=o):"hide"===n&&r&&/^[.#\[]/.test(r)&&document.querySelectorAll(r).forEach((function(t){t.style.display="none"})));g.innerHTML=String(t.days).padStart(2,"0"),f.innerHTML=String(t.hours).padStart(2,"0"),m.innerHTML=String(t.minutes).padStart(2,"0"),h.innerHTML=String(t.seconds).padStart(2,"0")}S();var y=setInterval(S,1e3);document.addEventListener("visibilitychange",(function(){document.hidden||S()}))}))})); |