PageSourceSearch

https://www.millenairecaen2025.com/modules/custom/gip_countdown/assets/js/countdown.js?tfck6s

js millenairecaen2025.com collected 2026-10-08 08:26:44 UTC 2,284 bytes, 73 lines download raw bytes

1/* JS */
2
3const countdown_done_class = 'countdown-done';
4
5(function (Drupal) {
6
7    Drupal.behaviors.gipCountdown = {
8        attach: function (context, settings) {
9            once('countdown-js', '.countdown-js', context).forEach(function (element) { 
10                
11                const targetDate = settings.gipCountdown.timestamp * 1000;
12
13                // Update the countdown every second
14                if(!settings.gipCountdown.countdownDone) 
15                    setInterval(updateCountdown, 1000, element, targetDate);
16            });
17        }
18    };
19
20})(Drupal);
21
22
23/**
24 * Countdown function
25 */
26function updateCountdown(element, targetDate) {
27
28    // its already done
29    if (element.classList.contains(countdown_done_class)) return;
30
31    // get Date
32    const currentDate = new Date().getTime();
33    const timeRemaining = targetDate - currentDate;
34    
35    // get elements
36    const elementDays = element.querySelector('.days');
37    const elementHours = element.querySelector('.hours');
38    const elementMinutes = element.querySelector('.minutes');
39    const elementSeconds = element.querySelector('.seconds');
40
41    // set times
42    if (timeRemaining <= 0) {
43        if(elementDays) elementDays.textContent = '00';
44        if(elementHours) elementHours.textContent = '00';
45        if(elementMinutes) elementMinutes.textContent = '00';
46        if(elementSeconds) elementSeconds.textContent = '00';
47        
48        countdownDone(element);
49
50    } else {
51        const days = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
52        const hours = Math.floor((timeRemaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
53        const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
54        const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
55
56        if(elementDays) elementDays.textContent = days * -1;
57        if(elementHours) elementHours.textContent = padZeroes(hours);
58        if(elementMinutes) elementMinutes.textContent = padZeroes(minutes);
59        if(elementSeconds) elementSeconds.textContent = padZeroes(seconds);
60    }
61}
62
63
64/**
65 * Countdown is done
66 */
67function countdownDone(element) {
68    element.classList.add(countdown_done_class);
69}
70
71function padZeroes(number) {
72    return number.toString().padStart(2, '0');
73}

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.