1export async function headerChoice(overlay, topImg, afterInit) { 2 const choiceTrigger = document.querySelector('.header__choice-inner') 3 const choiceList = document.querySelector('.header__choice-list') 4 const choiceCancel = document.querySelector('.header__choice-list .cancel') 5 const choiceBk = document.querySelectorAll('.header__choice-list ul li') 6 const choiceResult = document.querySelector('.header__choice-result') 7 const choiceBack = choiceResult.querySelector('.cancel') 8 9 // ÑлеменÑÑ ÑезÑлÑÑаÑа 10 const resultTitle = choiceResult.querySelector('.title') 11 const resultList = choiceResult.querySelector('ul') 12 const resultAll = choiceResult.querySelector('.all-bonuses') 13 14 if (choiceTrigger && choiceList && choiceResult && !afterInit) { 15 choiceTrigger.addEventListener('click', function () { 16 const isActive = choiceTrigger.classList.contains('active'); 17 if (!isActive) { 18 choiceTrigger.classList.add('active'); 19 choiceList.style.display = 'block'; 20 setTimeout(() => { 21 choiceList.style.opacity = '1'; 22 }, (50)); 23 if (window.matchMedia('(max-width: 767px)').matches) { 24 if (topImg) { 25 topImg.classList.add('fixed'); 26 } 27 document.querySelector('body').classList.toggle('no-scroll'); 28 document.querySelector('.header__bonus-icon').classList.add('hide') 29 overlay.style.display = 'block'; 30 choiceList.style.opacity = '1'; 31 setTimeout(() => { 32 overlay.style.opacity = '1'; 33 }, (50)); 34 } 35 } else { 36 choiceTrigger.classList.remove('active'); 37 choiceList.style.opacity = '0'; 38 setTimeout(() => { 39 choiceList.style.display = 'none'; 40 }, (200)) 41 if (window.matchMedia('(max-width: 767px)').matches) { 42 if (topImg) { 43 topImg.classList.remove('fixed'); 44 } 45 overlay.style.display = 'none'; 46 setTimeout(() => { 47 overlay.style.opacity = '0'; 48 }, (200)) 49 document.querySelector('.header__bonus-icon').classList.remove('hide') 50 } 51 } 52 }) 53 } 54 55 let isLoading = false; 56 57 choiceBk.forEach(link => { 58 59 link.addEventListener('click', async function () { 60 61 if (isLoading) return; 62 isLoading = true; 63 64 choiceResult.style.display = 'block'; 65 setTimeout(() => { choiceResult.style.opacity = '1'; }, 50); 66 67 const id = this.dataset.bkId; 68 const name = this.dataset.bkName; 69 if (!id) { 70 isLoading = false; 71 return; 72 } 73 74 resultTitle.innerHTML = `ÐонÑÑÑ ${name} <span>...</span>`; 75 resultList.innerHTML = '<li>ÐагÑÑзка...</li>'; 76 resultAll.href = '#'; 77 78 try { 79 const fd = new FormData(); 80 fd.append('action', 'wellbet_bonuses'); 81 fd.append('id', id); 82 fd.append('nonce', wbAjax.nonce); 83 84 const res = await fetch(wbAjax.url, { 85 method: 'POST', 86 body: fd, 87 headers: { 'X-Requested-With': 'XMLHttpRequest' } 88 }); 89 90 if (!res.ok) { 91 resultList.innerHTML = '<li>ÐÑибка ÑеÑвеÑа</li>'; 92 return; 93 } 94 95 let json = null; 96 try { 97 json = await res.json(); 98 } catch { 99 resultList.innerHTML = '<li>ÐÑибка оÑвеÑа</li>'; 100 return; 101 } 102 103 if (!json || !json.success || !json.data) { 104 resultList.innerHTML = '<li>ÐонÑÑÑ Ð½Ðµ найденÑ</li>'; 105 return; 106 } 107 108 const data = json.data; 109 const bonuses = Array.isArray(data.bonuses) ? data.bonuses : []; 110
111 resultTitle.innerHTML = `ÐонÑÑÑ ${data.bookmaker_name || name} <span>${bonuses.length}</span>`; 112 113 if (!bonuses.length) { 114 resultList.innerHTML = '<li>ÐонÑÑÑ Ð¾ÑÑÑÑÑÑвÑÑÑ</li>'; 115 } else { 116 resultList.innerHTML = bonuses 117 .map(b => `<li><a href="${b.link}" target="_blank" rel="nofollow noopener">${b.title}</a></li>`) 118 .join(''); 119 } 120 121 const allHref = data.bookmaker_link || '#'; 122 resultAll.href = allHref.startsWith('http') ? allHref : (location.origin + allHref); 123 124 } catch { 125 resultList.innerHTML = '<li>ÐÑибка ÑеÑи</li>'; 126 } finally { 127 isLoading = false; 128 } 129 }); 130 }); 131 132 if (choiceBack) { 133 choiceBack.addEventListener('click', function () { 134 choiceResult.style.opacity = '0'; 135 setTimeout(() => { 136 choiceResult.style.display = 'none'; 137 }, 200); 138 }); 139 } 140 141 function closeChoiceWindow() { 142 choiceTrigger?.classList.remove('active'); 143 topImg?.classList.remove('fixed'); 144 if (choiceList) { 145 choiceList.style.opacity = '0' 146 setTimeout(() => (choiceList.style.display = 'none'), 200); 147 } 148 if (overlay) { 149 overlay.style.opacity = '0' 150 setTimeout(() => (overlay.style.display = 'none'), 200); 151 } 152 document.body.classList.remove('no-scroll'); 153 document.querySelector('.header__bonus-icon').classList.remove('hide') 154 } 155 156 // пÑивÑзка ÑобÑÑÐ¸Ñ 157 if (choiceCancel) { 158 choiceCancel.addEventListener('click', closeChoiceWindow); 159 } 160 161 return { 162 choiceTrigger, 163 choiceList, 164 choiceResult, 165 closeChoiceWindow 166 }; 167}
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.