1document.addEventListener('DOMContentLoaded', function () { 2 3 const cookieSettings = document.getElementById('variantsModalCookie'); 4 const openSettings = document.getElementById('wms-open-settings'); 5 const acceptAllBtn = document.getElementById('wms-accept-all'); 6 const acceptEssentialBtn = document.getElementById('wms-accept-essential'); 7 const banner = document.getElementById('cookieBanner'); 8 const saveSettings = document.getElementById('save-settings'); 9 10 document.querySelectorAll(".closeCookie").forEach(function (button) { 11 button.addEventListener("click", function () { 12 this.closest('.modalCookie').classList.remove('active'); 13 }); 14 }); 15 16 saveSettings?.addEventListener('click', () => { 17 const categories = []; 18 document.querySelectorAll('input[name="categories[]"]:checked').forEach(cb => { 19 categories.push(cb.value); 20 }); 21 submitConsent(categories); 22 }); 23 24 // === ÐÑÑÑÑое ÑоглаÑие: ÐÑинÑÑÑ Ð²Ñе === 25 acceptAllBtn?.addEventListener('click', () => { 26 submitConsent(['ANALYTICS', 'MARKETING']); 27 }); 28 29 // === ÐÑÑÑÑое ÑоглаÑие: ТолÑко Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñе === 30 acceptEssentialBtn?.addEventListener('click', () => { 31 submitConsent([]); 32 }); 33 34 openSettings?.addEventListener('click', openCookieSettings); 35 36 function submitConsent(selectedCategories = []) { 37 const categories = ['ESSENTIAL', ...selectedCategories]; 38 39 BX.ajax.runComponentAction('wms:cookie-agreement', 'saveSettings', { 40 mode: 'class', 41 data: { 42 categories: categories, 43 sessid: BX.bitrix_sessid() 44 } 45 }).then(function (response) { 46 if (response.data && response.data.status === 'ok') { 47 // УÑпеÑно ÑÐ¾Ñ Ñанено 48 document.cookie = 'wms_cookie_agreed=Y; path=/; max-age=' + (365 * 24 * 60 * 60); 49 document.cookie = 'wms_cookie_categories=' + encodeURIComponent(categories.join(',')) + '; path=/; max-age=' + (365 * 24 * 60 * 60); 50 closeCookieSettings(); 51 window.location.reload(); 52 } else { 53 // ÐÑибка на ÑÑовне бизнеÑ-логики 54 const errorMsg = response.data?.errors?.[0]?.message || 'ÐеизвеÑÑÐ½Ð°Ñ Ð¾Ñибка'; 55 console.error('ÐÑибка ÑÐ¾Ñ ÑÐ°Ð½ÐµÐ½Ð¸Ñ ÑоглаÑиÑ:', errorMsg); 56 alert('Ðе ÑдалоÑÑ ÑÐ¾Ñ ÑаниÑÑ Ð½Ð°ÑÑÑойки: ' + errorMsg); 57 } 58 }).catch(function (error) { 59 // ÐÑибка ÑеÑи или ÑеÑвеÑа 60 console.error('AJAX оÑибка:', error); 61 alert('ÐÑоизоÑла оÑибка пÑи подклÑÑении. ÐопÑобÑйÑе Ñнова.'); 62 }); 63 } 64 65 function closeCookieSettings() { 66 if (banner) banner.classList.remove('active'); 67 if (cookieSettings) cookieSettings.classList.remove('active'); 68 } 69 70 function openCookieSettings() { 71 loadCurrentSettings(); 72 const wmsModal = new bootstrap.Modal(cookieSettings); 73 wmsModal.show(); 74 } 75 76 function loadCurrentSettings() { 77 BX.ajax.runComponentAction('wms:cookie-agreement', 'loadSettings', { 78 mode: 'class' 79 }).then(function (response) { 80 const data = response.data || ['ESSENTIAL']; 81 const analyticsCb = document.getElementById('analytics'); 82 const marketingCb = document.getElementById('marketing'); 83 84 if (analyticsCb) analyticsCb.checked = data.includes('ANALYTICS'); 85 if (marketingCb) marketingCb.checked = data.includes('MARKETING'); 86 }).catch(function (response) { 87 console.error('Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ Ð½Ð°ÑÑÑойки cookie', response); 88 }); 89 } 90});
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.