PageSourceSearch

https://ncrdo.ru/local/templates/ncrdo_visually/components/bitrix/…/script.js?17537926365571

js ncrdo.ru collected 2026-09-28 12:11:52 UTC 5,571 bytes, 118 lines download raw bytes

1function getNextDayOfTheWeek() {
2    var d = new Date();
3    d.setHours(23, 59, 59);
4    d.setDate(d.getDate() + (((1 + 6 - d.getDay()) % 7) || 7));
5    return d;
6}
7// Функция склонения числительных
8function declensionNum(num, words) {
9    return words[(num % 100 > 4 && num % 100 < 20) ? 2 : [2, 0, 1, 1, 1, 2][num % 10 < 5 ? num % 10 : 5]];
10};
11document.addEventListener('DOMContentLoaded', () => {
12    const arrBannerRange = document.querySelectorAll('.category_unique_banner_fon');
13    arrBannerRange.forEach((el, index) => {
14
15        var dateStart = el.querySelector('.category_unique_banner_contaner').dataset.start;
16        var dateEnd = el.querySelector('.category_unique_banner_contaner').dataset.end;
17        var dateType = el.querySelector('.category_unique_banner_contaner').dataset.type;
18        var dateBlock = el.querySelector('.category_unique_banner_contaner').dataset.idblock;
19
20        //таймер до конца активности
21        if (dateType == "timer3") {
22
23            // Установите конечную дату
24            const deadline = new Date(dateEnd);
25            const startline = new Date(dateStart);
26
27            // Найдите элементы DOM
28            const elDays = el.querySelector('.days');
29            const elHours = el.querySelector('.hours');
30            const elMinutes = el.querySelector('.minutes');
31            const elSeconds = el.querySelector('.seconds');
32
33            // Функция обновления таймера
34            const updateTimer = () => {
35                const now = new Date();
36
37                if (startline < now) {
38                    const diff = Math.max(0, deadline - now);
39
40                    const days = Math.floor(diff / (1000 * 60 * 60 * 24));
41                    const hours = Math.floor((diff / (1000 * 60 * 60)) % 24);
42                    const minutes = Math.floor((diff / (1000 * 60)) % 60);
43                    const seconds = Math.floor((diff / 1000) % 60);
44                    const daystitle = declensionNum(days, ['день', 'дня', 'дней']);
45
46                    elDays.innerHTML = String(days) + " " + daystitle;
47                    elHours.textContent = String(hours).padStart(2, '0');
48                    elMinutes.textContent = String(minutes).padStart(2, '0');
49                    elSeconds.textContent = String(seconds).padStart(2, '0');
50
51                    if (diff === 0) {
52                        clearInterval(timerId);
53                    }
54                }
55                //если время вышло и по какой-то причине элемент выводится, удаляем баннер с неактивным таймером
56                else
57                    document.querySelector('#'.dateBlock).innerHTML = "";
58
59            };
60            // Запустите таймер
61            updateTimer();
62            const timerId = setInterval(updateTimer, 1000);
63        }
64
65        //таймер до полуночи ВС-ПН
66        if (dateType == "timer2") {
67
68            // Установите конечную дату
69            let deadlineTimer2 = new Date(dateEnd).getTime();
70            const startlineTimer2 = new Date(dateStart).getTime();
71            const nextMonday = getNextDayOfTheWeek().getTime();
72
73            if (nextMonday < deadlineTimer2) deadlineTimer2 = nextMonday;
74
75            // Найдите элементы DOM
76            const elDaysTimer2 = el.querySelector('.days');
77            const elHoursTimer2 = el.querySelector('.hours');
78            const elMinutesTimer2 = el.querySelector('.minutes');
79            const elSecondsTimer2 = el.querySelector('.seconds');
80
81            // Функция обновления таймера
82            const updateTimerTimer2 = () => {
83                const nowTimer2 = new Date().getTime();
84
85                if (nowTimer2 <= deadlineTimer2 && nowTimer2 >= startlineTimer2) {
86
87                    const diffTimer2 = deadlineTimer2 - nowTimer2;
88
89                    const daysTimer2 = Math.floor(diffTimer2 / (1000 * 60 * 60 * 24));
90                    const hoursTimer2 = Math.floor((diffTimer2 / (1000 * 60 * 60)) % 24);
91                    const minutesTimer2 = Math.floor((diffTimer2 / (1000 * 60)) % 60);
92                    const secondsTimer2 = Math.floor((diffTimer2 / 1000) % 60);
93                    const daystitleTimer2 = declensionNum(days, ['день', 'дня', 'дней']);
94
95                    elDaysTimer2.innerHTML =  String(daysTimer2) + " " + daystitleTimer2;
96                    elHoursTimer2.textContent = String(hoursTimer2).padStart(2, '0');
97                    elMinutesTimer2.textContent = String(minutesTimer2).padStart(2, '0');
98                    elSecondsTimer2.textContent = String(secondsTimer2).padStart(2, '0');
99
100                    if (diffTimer2 === 0) {
101                        clearInterval(timerIdTimer2);
102                    }
103                }
104                //если время вышло и по какой-то причине элемент выводится, удаляем баннер с неактивным таймером
105                else
106                    document.querySelector('#'.dateBlock).innerHTML = "";
107
108            };
109
110            // Запустите таймер
111            updateTimerTimer2();
112            const timerIdTimer2 = setInterval(updateTimerTimer2, 1000);
113
114        }
115
116    });
117
118});

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.