1document.addEventListener('DOMContentLoaded', () => { 2 const modal = document.getElementById('popup-mobile-beeline-modal'); 3 4 if (!modal) { 5 return; 6 } 7 8 if (window.location.pathname !== '/test_mobile' && window.location.pathname !== '/test_mobile/') { 9 return; 10 } 11 12 const triggers = document.querySelectorAll('a.popup-mobile-beeline'); 13 const closeButton = modal.querySelector('.popup-mobile-beeline-modal__close'); 14 const iframe = modal.querySelector('.popup-mobile-beeline-modal__iframe'); 15 const fallbackTimeout = 10000; 16 let scrollTop = 0; 17 let isIframeLoaded = false; 18 let fallbackTimer = null; 19 let activeFallbackUrl = ''; 20 let isFallbackRedirecting = false; 21 22 const lockPageScroll = () => { 23 scrollTop = window.scrollY || window.pageYOffset || 0; 24 document.body.classList.add('popup-mobile-beeline-open'); 25 document.body.style.top = `-${scrollTop}px`; 26 }; 27 28 const unlockPageScroll = () => { 29 document.body.classList.remove('popup-mobile-beeline-open'); 30 document.body.style.top = ''; 31 window.scrollTo(0, scrollTop); 32 }; 33 34 const clearFallbackTimer = () => { 35 if (fallbackTimer) { 36 window.clearTimeout(fallbackTimer); 37 fallbackTimer = null; 38 } 39 }; 40 41 const openModal = () => { 42 modal.classList.add('is-open'); 43 modal.setAttribute('aria-hidden', 'false'); 44 lockPageScroll(); 45 }; 46 47 const closeModal = () => { 48 clearFallbackTimer(); 49 modal.classList.remove('is-open'); 50 modal.setAttribute('aria-hidden', 'true'); 51 unlockPageScroll(); 52 }; 53 54 const redirectToFallback = () => { 55 if (!activeFallbackUrl || isFallbackRedirecting) { 56 return; 57 } 58 59 isFallbackRedirecting = true; 60 closeModal(); 61 window.location.href = activeFallbackUrl; 62 }; 63 64 if (iframe) { 65 iframe.addEventListener('load', () => { 66 isIframeLoaded = true; 67 clearFallbackTimer(); 68 }); 69 70 iframe.addEventListener('error', () => { 71 redirectToFallback(); 72 }); 73 } 74 75 triggers.forEach((trigger) => { 76 trigger.addEventListener('click', (event) => { 77 event.preventDefault(); 78 79 activeFallbackUrl = trigger.getAttribute('href') || ''; 80 isFallbackRedirecting = false; 81 82 openModal(); 83 84 if (isIframeLoaded) { 85 clearFallbackTimer(); 86 return; 87 } 88 89 clearFallbackTimer(); 90 fallbackTimer = window.setTimeout(() => { 91 if (!isIframeLoaded) { 92 redirectToFallback(); 93 } 94 }, fallbackTimeout); 95 }); 96 }); 97 98 if (closeButton) { 99 closeButton.addEventListener('click', closeModal); 100 } 101}); 102 103 104
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.