PluginProbe
Gutenify – Visual Site Builder Blocks & Starter Templates / trunk
Gutenify – Visual Site Builder Blocks & Starter Templates vtrunk
1.7.0 1.6.6 1.6.5 1.6.4 trunk 0.0.1 0.0.2 0.0.3 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 All 72 releases
gutenify / core / dist / blocks / countdown-timer / scripts / script.js

script.js in Gutenify – Visual Site Builder Blocks & Starter Templates trunk, at core/dist/blocks/countdown-timer/scripts/script.js

1 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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()}))}))}));