1document.addEventListener('DOMContentLoaded', function() { 2 function getCookie(name) { 3 const value = `; ${document.cookie}`; 4 const parts = value.split(`; ${name}=`); 5 if (parts.length === 2) return parts.pop().split(';').shift(); 6 return null; // Devuelve null si la cookie no existe 7 } 8 9 function initializeCountdown(countdownId, endDate, cookieExpire) { 10 const bannerElement = document.getElementById('orheadercountdown-banner-' + countdownId); 11 const timerElement = document.getElementById('orheadercountdown-timer-' + countdownId); 12 const closeButton = document.getElementById('orheadercountdown-close-' + countdownId); 13 14 const endDateTime = new Date(endDate).getTime(); 15 16 function updateCountdown() { 17 const now = new Date().getTime(); 18 const distance = endDateTime - now; 19 20 if (distance < 0) { 21 clearInterval(interval); 22 closeBanner(); 23 return; 24 } 25 26 const days = Math.floor(distance / (1000 * 60 * 60 * 24)); 27 const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 28 const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); 29 const seconds = Math.floor((distance % (1000 * 60)) / 1000); 30 31 timerElement.innerHTML = `${days} d ${hours} ${hours>1 ? 'hs': 'h'} ${minutes} m ${seconds} s`; 32 } 33 34 const interval = setInterval(updateCountdown, 1000); 35 36 function closeBanner() { 37 bannerElement.style.display = 'none'; 38 var expiresInSeconds = cookieExpire * 86400; 39 40 if (cookieExpire === 0) { 41 document.cookie = "orheadercountdown_closed_" + countdownId + "=true; path=/"; 42 } else { 43 document.cookie = "orheadercountdown_closed_" + countdownId + "=true; path=/; max-age=" + expiresInSeconds; 44 } 45 } 46 47 closeButton.addEventListener('click', closeBanner); 48 49 if (document.cookie.indexOf("orheadercountdown_closed_" + countdownId + "=true") !== -1) { 50 bannerElement.style.display = 'none'; 51 } 52 } 53 54 const countdownElements = document.querySelectorAll('.orheadercountdown-banner'); 55 56 const countdownDataArray = []; 57 58 countdownElements.forEach(function(element) { 59 const countdownData = { 60 id: element.getAttribute('data-id'), 61 fecha_fin: element.getAttribute('data-fecha-fin'), 62 cookie: element.getAttribute('data-cookie'), 63 countdown_enable: element.getAttribute('data-countdown-enable'), 64 }; 65 66 countdownDataArray.push(countdownData); 67 }); 68 69 countdownDataArray.forEach(function(countdown) { 70 const cookieExists = getCookie("orheadercountdown_closed_" + countdown.id); 71 const shouldShowBanner = !cookieExists || cookieExists !== 'true'; 72 73 if (countdown.countdown_enable === "true" && shouldShowBanner) { 74 initializeCountdown(countdown.id, countdown.fecha_fin, countdown.cookie); 75 } 76 }); 77});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.