PageSourceSearch

https://domrasteni.ru/local/templates/domrasteni/assets/privacy-choice.js?v=20260928-1

js domrasteni.ru collected 2026-10-05 00:04:37 UTC 3,784 bytes, 23 lines download raw bytes

1(function(){
2'use strict';
3var VERSION='2026-09-28-v1',KEY='dr_privacy_choice',DAYS=180;
4var panel=document.getElementById('dr-privacy-panel'); if(!panel)return;
5var status=document.getElementById('dr-privacy-status'), loaded=false, busy=false, epoch=0, lastFocus=null;
6window.drOnReady=function(fn){if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',fn);else fn();};
7function read(){try{var v=JSON.parse(localStorage.getItem(KEY));return v&&v.version===VERSION&&Date.now()-v.at<DAYS*86400000&&['analytics','necessary'].indexOf(v.choice)>=0?v:null;}catch(e){return null;}}
8function remember(choice){var v={version:VERSION,choice:choice,at:Date.now()};try{localStorage.setItem(KEY,JSON.stringify(v));}catch(e){}return v;}
9function show(){lastFocus=document.activeElement;panel.hidden=false;var v=read();status.textContent=v?(v.choice==='analytics'?'Сейчас аналитика разрешена.':'Сейчас разрешены только необходимые функции.'):'';}
10function hide(){panel.hidden=true;if(lastFocus&&lastFocus.focus)lastFocus.focus();}
11function activate(){if(loaded)return;loaded=true;var list=Array.prototype.slice.call(document.querySelectorAll('script[data-dr-analytics]'));list.forEach(function(old){var s=document.createElement('script');s.type='text/javascript';var src=old.getAttribute('data-dr-src');if(src){s.src=src;s.async=false;}else{s.text=old.textContent.replace(/document\.addEventListener\(\s*(['"])DOMContentLoaded\1\s*,/g,'window.drOnReady(');}old.parentNode.insertBefore(s,old.nextSibling);});}
12function cleanAnalyticsCookies(){document.cookie.split(';').forEach(function(row){var name=row.split('=')[0].trim();if(!/^_ym_/.test(name))return;[null,location.hostname,'.'+location.hostname].forEach(function(domain){document.cookie=name+'=; Max-Age=0; Path=/; SameSite=Lax'+(domain?'; Domain='+domain:'')+'; Secure';});});}
13function reject(){epoch++;busy=false;document.getElementById('dr-privacy-accept').disabled=false;remember('necessary');cleanAnalyticsCookies();hide();if(loaded)location.reload();}
14function accept(){if(busy)return;busy=true;var requestEpoch=++epoch;status.textContent='Сохраняем ваш выбор…';var btn=document.getElementById('dr-privacy-accept');btn.disabled=true;
15function fail(){if(requestEpoch!==epoch)return;busy=false;btn.disabled=false;status.textContent='Не удалось сохранить согласие. Аналитика не включена. Можно повторить или оставить только необходимые функции.';}
16if(!window.BX||!BX.ajax||!BX.bitrix_sessid){fail();return;}
17BX.ajax({url:'/bitrix/components/bitrix/main.userconsent.request/ajax.php',method:'POST',dataType:'json',timeout:10,data:{action:'saveConsent',id:panel.getAttribute('data-agreement'),sec:panel.getAttribute('data-security'),sessid:BX.bitrix_sessid(),url:location.origin+location.pathname},onsuccess:function(data){if(requestEpoch!==epoch)return;if(!data||data.error){fail();return;}busy=false;btn.disabled=false;remember('analytics');hide();activate();},onfailure:fail});}
18document.getElementById('dr-privacy-accept').addEventListener('click',accept);
19document.getElementById('dr-privacy-reject').addEventListener('click',reject);
20document.addEventListener('click',function(e){var t=e.target.closest('[data-dr-privacy-settings]');if(t){e.preventDefault();show();document.getElementById('dr-privacy-reject').focus();}});
21window.addEventListener('storage',function(e){if(e.key!==KEY)return;var v=read();if(loaded&&(!v||v.choice!=='analytics'))location.reload();else if(v&&v.choice==='analytics'){hide();activate();}else if(!v)show();});
22var saved=read();if(saved){hide();if(saved.choice==='analytics')activate();}else show();
23})();

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.