1(function(){ 2 'use strict'; 3 // ÐадеÑжка показа опÑоÑа в ÑекÑÐ½Ð´Ð°Ñ Ñ Ð½Ð°Ñала визиÑа. 4 var showDelaySeconds=90; 5 var link; 6 var opening=false; 7 var focusedBeforePopup=null; 8 var visitKey='exit_survey_visit_started'; 9 var shownKey='exit_survey_shown'; 10 var convertedKey='exit_survey_converted'; 11 var completedCookie='exit_survey_completed'; 12 var startedAt=Date.now(); 13 var reachedGoals={}; 14 15 function sessionGet(key){ 16 try{return window.sessionStorage.getItem(key);}catch(e){return null;} 17 } 18 function sessionSet(key,value){ 19 try{window.sessionStorage.setItem(key,value);}catch(e){} 20 } 21 function reachGoal(root,goal){ 22 var counter=parseInt(root.getAttribute('data-counter'),10); 23 var key='exit_survey_goal_'+goal; 24 if(!counter||!goal||typeof window.ym!=='function'||reachedGoals[key]||sessionGet(key)){return;} 25 window.ym(counter,'reachGoal',goal); 26 reachedGoals[key]=true; 27 sessionSet(key,'1'); 28 } 29 function cookieGet(key){ 30 var parts=document.cookie.split(';'); 31 for(var i=0;i<parts.length;i++){ 32 var part=parts[i].replace(/^\s+/,''); 33 if(part.indexOf(key+'=')===0){return part.substring(key.length+1);} 34 } 35 return ''; 36 } 37 function cookieSet(key,value,days){ 38 document.cookie=key+'='+value+';max-age='+(days*86400)+';path=/;SameSite=Lax'+(location.protocol==='https:'?';Secure':''); 39 } 40 function excluded(){ 41 return /\/(popup|basket|checkout|payment)(\/|\.|$)/.test(location.pathname)||/[?&]sent(?:[=&]|$)/.test(location.search); 42 } 43 function canShow(){ 44 return link&&!opening&&!document.querySelector('.exit-survey')&&!excluded()&&!(window.jQuery&&window.jQuery.fancybox&&window.jQuery.fancybox.isOpen)&&!sessionGet(shownKey)&&!sessionGet(convertedKey)&&!cookieGet('nf_popup')&&!cookieGet(completedCookie)&&Date.now()-startedAt>=showDelaySeconds*1000; 45 } 46 function openSurvey(){ 47 if(!canShow()){return;} 48 opening=true; 49 focusedBeforePopup=document.activeElement; 50 link.click(); 51 } 52 function markShown(root){ 53 opening=false; 54 sessionSet(shownKey,'1'); 55 cookieSet('nf_popup','1',7); 56 reachGoal(root,'notfound1'); 57 } 58 function scrolledEnough(){ 59 var height=document.documentElement.scrollHeight||1; 60 return window.pageYOffset>0&&((window.pageYOffset+window.innerHeight)/height)>=0.1; 61 } 62 function checkMobile(){ 63 if(window.matchMedia&&window.matchMedia('(pointer: coarse)').matches&&scrolledEnough()){ 64 openSurvey(); 65 } 66 } 67 function rootOf(element){ 68 while(element&&element!==document){ 69 if(element.classList&&element.classList.contains('exit-survey')){return element;} 70 element=element.parentNode; 71 } 72 return null; 73 } 74 function setError(form,message){ 75 var error=form.querySelector('[data-exit-error]'); 76 if(error){error.textContent=message||'';} 77 } 78 function setStep(root,name){ 79 var steps=root.querySelectorAll('[data-exit-step]'); 80 for(var i=0;i<steps.length;i++){ 81 steps[i].hidden=steps[i].getAttribute('data-exit-step')!==name; 82 } 83 var progress=root.querySelector('.exit-survey__progress span'); 84 if(progress){progress.style.width=name==='reason'?'48%':'100%';} 85 if(window.jQuery&&window.jQuery.fancybox&&window.jQuery.fancybox.update){ 86 setTimeout(function(){window.jQuery.fancybox.update();},20); 87 } 88 } 89 function updateChoiceValidity(form){ 90 var groups=form.querySelectorAll('[data-exit-choice-group]'); 91 for(var i=0;i<groups.length;i++){ 92 var first=groups[i].querySelector('input'); 93 if(first){first.setCustomValidity(groups[i].getAttribute('data-required')==='1'&&!groups[i].querySelector('input:checked')?'ÐÑбеÑиÑе Ñ Ð¾ÑÑ Ð±Ñ Ð¾Ð´Ð¸Ð½ ваÑианÑ.':'');} 94 } 95 } 96 function validateForm(form){ 97 updateChoiceValidity(form); 98 if(form.checkValidity&&!form.checkValidity()){ 99 if(form.reportValidity){form.reportValidity();} 100 return false; 101 } 102 return true; 103 } 104 function mount(root){ 105 if(!root||root.getAttribute('data-exit-mounted')==='1'){return;} 106 root.setAttribute('data-exit-mounted','1'); 107 var pageUrl=root.querySelector('input[name=page_url]'); 108 if(pageUrl){pageUrl.value=location.href;} 109 var close=root.querySelector('.exit-survey__close'); 110 if(close){setTimeout(function(){close.focus();},50);} 111 if(window.jQuery&&window.jQuery.fn.mask){ 112 window.jQuery(root).find('input[name=phone]').mask('+7 (999) 999-99-99'); 113 } 114 var forms=root.querySelectorAll('form'); 115 for(var i=0;i<forms.length;i++){updateChoiceValidity(forms[i]);} 116 } 117 function request(form,done){ 118 var xhr=new XMLHttpRequest(); 119 var finished=false; 120 function finish(ok,result){ 121 if(finished){return;} 122 finished=true; 123 done(ok,result); 124 } 125 xhr.open('POST',form.action,true); 126 xhr.setRequestHeader('X-Requested-With','XMLHttpRequest'); 127 xhr.onreadystatechange=function(){ 128 if(xhr.readyState!==4){return;} 129 var result; 130 try{result=JSON.parse(xhr.responseText);}catch(e){result=null;} 131 if(!result||!result.ok){ 132 finish(false,result&&result.error?result.error:'Ðе ÑдалоÑÑ Ð¾ÑпÑавиÑÑ Ð´Ð°Ð½Ð½Ñе. ÐопÑобÑйÑе еÑÑ Ñаз.'); 133 return; 134 } 135 finish(true,result); 136 }; 137 xhr.onerror=function(){finish(false,'ÐÐµÑ ÑоединениÑ. ÐопÑобÑйÑе еÑÑ Ñаз.');}; 138 xhr.send(new FormData(form)); 139 } 140 function closeSurvey(root){ 141 if(window.jQuery&&window.jQuery.fancybox){ 142 var node=root; 143 while(node&&node!==document){ 144 if(node.classList&&node.classList.contains('fancybox-wrap')){ 145 window.jQuery.fancybox.close(); 146 return; 147 } 148 node=node.parentNode; 149 } 150 } 151 if(history.length>1){history.back();}else{location.assign('/');} 152 } 153 function onReasonSubmit(form,root){ 154 if(!validateForm(form)){return;} 155 var submit=form.querySelector('[type=submit]'); 156 submit.disabled=true; 157 setError(form,''); 158 request(form,function(ok,result){ 159 if(!ok){setError(form,result);submit.disabled=false;return;} 160 cookieSet(completedCookie,'1',30); 161 reachGoal(root,'notfound2'); 162 if(result.next==='lead'){ 163 root.querySelector('[data-exit-followup-title]').textContent=result.title||'СпаÑибо за обÑаÑнÑÑ ÑвÑзÑ'; 164 root.querySelector('[data-exit-followup-text]').textContent=result.text||'ÐÑÑавÑÑе конÑакÑнÑе даннÑе, ÑÑÐ¾Ð±Ñ Ð¼Ñ Ð¼Ð¾Ð³Ð»Ð¸ ÑвÑзаÑÑÑÑ Ñ Ð²Ð°Ð¼Ð¸.'; 165 setStep(root,'lead'); 166 var contact=root.querySelector('[data-exit-form=lead] input:not([type=hidden]):not([name=surname]),[data-exit-form=lead] textarea,[data-exit-form=lead] select'); 167 if(contact){setTimeout(function(){contact.focus();},50);} 168 }else{ 169 root.querySelector('[data-exit-done-text]').textContent='ÐÐ°Ñ Ð¾ÑÐ²ÐµÑ ÑÐ¾Ñ ÑанÑн. СпаÑибо за обÑаÑнÑÑ ÑвÑзÑ.'; 170 setStep(root,'done'); 171 } 172 }); 173 } 174 function onLeadSubmit(form,root){ 175 if(!validateForm(form)){return;} 176 var submit=form.querySelector('[type=submit]'); 177 submit.disabled=true; 178 setError(form,''); 179 request(form,function(ok,result){ 180 if(!ok){setError(form,result);submit.disabled=false;return;} 181 root.querySelector('[data-exit-done-text]').textContent='ÐÑ Ð¿Ð¾Ð»ÑÑили Ð²Ð°Ñ ÐºÐ¾Ð½ÑÐ°ÐºÑ Ð¸ ÑвÑжемÑÑ Ñ Ð²Ð°Ð¼Ð¸.'; 182 setStep(root,'done'); 183 if(result.phone_present){reachGoal(root,root.getAttribute('data-goal'));} 184 }); 185 } 186 function bindEvents(){ 187 document.addEventListener('change',function(event){ 188 if(!event.target){return;} 189 var root=rootOf(event.target); 190 if(!root){return;} 191 var form=event.target.form; 192 if(!form){return;} 193 updateChoiceValidity(form); 194 setError(form,''); 195 var cards=root.querySelectorAll('.exit-survey__reason'); 196 for(var i=0;i<cards.length;i++){ 197 var checked=cards[i].querySelector('input:checked'); 198 cards[i].classList.toggle('is-selected',!!checked); 199 } 200 if(event.target.name==='exit_reason'&&event.target.value==='ÐÑÑÐ³Ð°Ñ Ð¿ÑиÑина'&&root.querySelector('.exit-survey__comment')){ 201 root.querySelector('[data-exit-clarify]').click(); 202 } 203 }); 204 document.addEventListener('click',function(event){ 205 var root=rootOf(event.target); 206 if(!root){return;} 207 var action=event.target; 208 while(action&&action!==root&&!action.hasAttribute('data-exit-clarify')&&!action.hasAttribute('data-exit-close')){action=action.parentNode;} 209 if(!action||action===root){return;} 210 if(action.hasAttribute('data-exit-clarify')){ 211 var comment=root.querySelector('.exit-survey__comment'); 212 if(comment){ 213 comment.hidden=false; 214 root.querySelector('.exit-survey__clarify').hidden=true; 215 comment.querySelector('textarea,input').focus(); 216 } 217 }else{ 218 closeSurvey(root); 219 } 220 }); 221 document.addEventListener('submit',function(event){ 222 var form=event.target; 223 var root=rootOf(form); 224 if(!root){return;} 225 event.preventDefault(); 226 if(form.getAttribute('data-exit-form')==='reason'){onReasonSubmit(form,root);} 227 if(form.getAttribute('data-exit-form')==='lead'){onLeadSubmit(form,root);} 228 }); 229 }
230 function init(){ 231 var previous=parseInt(sessionGet(visitKey),10); 232 if(previous&&previous<=Date.now()){startedAt=previous;} 233 else{sessionSet(visitKey,String(startedAt));} 234 if(/[?&]sent(?:[=&]|$)/.test(location.search)){sessionSet(convertedKey,'1');} 235 bindEvents(); 236 link=document.getElementById('nf_link'); 237 if(link&&window.jQuery&&window.jQuery.fn.fancybox){ 238 window.jQuery(link).fancybox({ 239 type:'ajax', 240 wrapCSS:'exit-survey-wrap', 241 helpers:{title:null,overlay:{css:{background:'rgba(10,24,19,.67)',backdropFilter:'blur(5px)'}}}, 242 padding:0, 243 width:620, 244 maxWidth:620, 245 minWidth:0, 246 autoSize:true, 247 fitToView:true, 248 closeBtn:false, 249 afterShow:function(){ 250 var survey=document.querySelector('.fancybox-inner .exit-survey'); 251 if(survey){ 252 document.body.classList.add('exit-survey-open'); 253 window.jQuery(survey).closest('.fancybox-wrap').addClass('exit-survey-wrap'); 254 window.jQuery('.fancybox-overlay').addClass('exit-survey-overlay'); 255 markShown(survey);mount(survey); 256 setTimeout(function(){window.jQuery.fancybox.update();},20); 257 } 258 else{opening=false;} 259 }, 260 afterClose:function(){ 261 opening=false; 262 document.body.classList.remove('exit-survey-open'); 263 window.jQuery('.fancybox-overlay').removeClass('exit-survey-overlay'); 264 if(focusedBeforePopup&&document.contains(focusedBeforePopup)){focusedBeforePopup.focus();} 265 } 266 }); 267 document.addEventListener('mouseout',function(event){ 268 if(event.clientY<=0&&!event.relatedTarget){openSurvey();} 269 }); 270 window.addEventListener('scroll',checkMobile); 271 setTimeout(checkMobile,Math.max(0,showDelaySeconds*1000-(Date.now()-startedAt))); 272 } 273 var visibleSurveys=document.querySelectorAll('.exit-survey'); 274 for(var i=0;i<visibleSurveys.length;i++){ 275 if(visibleSurveys[i].getClientRects().length){markShown(visibleSurveys[i]);} 276 mount(visibleSurveys[i]); 277 } 278 } 279 window.ExitSurvey={mount:mount,setConverted:function(){sessionSet(convertedKey,'1');}}; 280 if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init);}else{init();} 281})();
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.