1let yaInitAttempts = 0; 2let yaAuthInstance = null; 3const YA_MAX_ATTEMPTS = 5; 4let yaIsScriptLoaded = false; 5 6function initYaID() { 7 const yaContainer = document.getElementById('ya-login-container'); 8 9 if (!yaContainer) { 10 if (yaInitAttempts < YA_MAX_ATTEMPTS) { 11 yaInitAttempts++; 12 setTimeout(initYaID, 200); 13 return; 14 } 15 return; 16 } 17 18 yaInitAttempts = 0; 19 20 if ('YaAuthSuggest' in window) { 21 if (yaAuthInstance) { 22 yaContainer.innerHTML = ''; 23 } 24 25 window.YaAuthSuggest.init( 26 { 27 client_id: "ec88a23bf8314924bbb26dd619d39d31", 28 response_type: "token", 29 redirect_uri: "https://oauth.yandex.ru/suggest/token" 30 }, 31 "https://oauth.yandex.ru", 32 { 33 view: "button", 34 parentId: "ya-login-container", 35 buttonSize: 's', 36 buttonView: 'main', 37 buttonTheme: 'light', 38 buttonBorderRadius: "15", 39 buttonIcon: 'ya', 40 } 41 ) 42 .then(({handler}) => { 43 yaAuthInstance = handler; 44 return handler(); 45 }) 46 .then(data => yaAuthSuccess(data)) 47 .catch(error => yaAuthError(error)); 48 } 49} 50 51function yaAuthSuccess(data) { 52 //console.log('Yandex Auth success:', data); 53 54 fetch(wplb_ya.ajaxurl, { 55 method: 'POST', 56 headers: { 57 'Content-Type': 'application/x-www-form-urlencoded', 58 }, 59 body: new URLSearchParams({ 60 action: 'social_auth_callback', 61 provider: 'ya', 62 token: data.access_token, 63 _wpnonce: wplb_ya.nonce 64 }) 65 }) 66 .then(response => response.json()) 67 .then(result => { 68 if (result.success) { 69 const yaElementorPopup = document.querySelector('.dialog-widget.dialog-lightbox-widget'); 70 if (yaElementorPopup) { 71 yaElementorPopup.querySelector('.dialog-close-button')?.click(); 72 } 73 setTimeout(() => { 74 window.location.reload(); 75 }, 500); 76 } else { 77 console.error('Auth error:', result.data.message); 78 alert('ÐÑибка авÑоÑизаÑии: ' + result.data.message); 79 } 80 }) 81 .catch(error => { 82 console.error('Auth error:', error); 83 alert('ÐÑибка авÑоÑизаÑии'); 84 }); 85} 86 87function yaAuthError(error) { 88 console.error('Yandex ID Error:', error); 89} 90 91function loadYaIDScript() { 92 setTimeout(initYaID, 100); 93} 94 95// СлÑÑаем ÑобÑÑÐ¸Ñ Elementor Ð´Ð»Ñ Ð¸Ð½Ð¸ÑиализаÑии в попапе 96jQuery(document).on('elementor/popup/show', function() { 97 yaInitAttempts = 0; 98 setTimeout(loadYaIDScript, 300); 99}); 100 101// ÐниÑиализиÑÑем пÑи загÑÑзке ÑÑÑаниÑÑ 102jQuery(document).ready(function() { 103 // ÐÑовеÑÑем, еÑÑÑ Ð»Ð¸ конÑÐµÐ¹Ð½ÐµÑ Ð½Ð° ÑÑÑаниÑе (не в попапе) 104 const yaContainer = document.getElementById('ya-login-container'); 105 if (yaContainer) { 106 loadYaIDScript(); 107 } 108});
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.