1(function() { 2 "use strict"; 3 4 function getTimeRemaining(endtime) { 5 const total = Date.parse(endtime) - Date.parse(new Date()); 6 const seconds = Math.floor((total / 1000) % 60); 7 const minutes = Math.floor((total / 1000 / 60) % 60); 8 const hours = Math.floor((total / (1000 * 60 * 60)) % 24); 9 const days = Math.floor(total / (1000 * 60 * 60 * 24)); 10 11 return { 12 total, 13 days, 14 hours, 15 minutes, 16 seconds 17 }; 18 } 19 20 function initializeClock(elem, endtime) { 21 const clock = document.querySelector(elem) 22 const daysSpan = clock.querySelector('[data-days]') 23 const hoursSpan = clock.querySelector('[data-hours]') 24 const minutesSpan = clock.querySelector('[data-minutes]') 25 const secondsSpan = clock.querySelector('[data-seconds]') 26 27 function updateClock() { 28 const t = getTimeRemaining(endtime) 29 30 daysSpan.innerHTML = t.days 31 hoursSpan.innerHTML = ('0' + t.hours).slice(-2) 32 minutesSpan.innerHTML = ('0' + t.minutes).slice(-2) 33 secondsSpan.innerHTML = ('0' + t.seconds).slice(-2) 34 35 if (t.total <= 0) { 36 clearInterval(timeinterval) 37 } 38 } 39 40 updateClock() 41 const timeinterval = setInterval(updateClock, 1000) 42 } 43 44 // Fetch secure public configuration from backend 45 fetch('/api/config/public') 46 .then(res => res.json()) 47 .then(config => { 48 // Initialize countdown with dynamic target date 49 if (config.countdownTarget) { 50 const deadline = new Date(config.countdownTarget); 51 const countdownEl = document.querySelector('.countdown'); 52 if (countdownEl) { 53 initializeClock('.countdown', deadline); 54 } 55 } else { 56 const countdownEl = document.querySelector('.countdown'); 57 if (countdownEl) { 58 let time = countdownEl.getAttribute('data-date'); 59 const deadline = new Date(time); 60 initializeClock('.countdown', deadline); 61 } 62 } 63 64 // Dynamically update all Telegram links on the page 65 if (config.telegramLink) { 66 document.querySelectorAll('a[href*="t.me/"], a[href*="telegram.me/"], a[href*="/go/web-button"]').forEach(el => { 67 el.href = config.telegramLink; 68 }); 69 } 70 }) 71 .catch(err => { 72 console.error("Erreur lors du chargement de la config pour le compteur:", err); 73 // Fallback to static HTML attribute 74 const countdownEl = document.querySelector('.countdown'); 75 if (countdownEl) { 76 let time = countdownEl.getAttribute('data-date'); 77 const deadline = new Date(time); 78 initializeClock('.countdown', deadline); 79 } 80 }); 81 82})()
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.