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.