1(function () { 2 function ready(fn) { 3 if (document.readyState !== 'loading') { 4 fn(); 5 } else { 6 document.addEventListener('DOMContentLoaded', fn); 7 } 8 } 9 10 ready(function () { 11 var wrap = document.querySelector('.lcs-header-login'); 12 if (!wrap || typeof tvAjax === 'undefined') return; 13 14 // "Sign up" link -> the real vendor signup page. header-megamenu.php ships this as href="#". 15 var signupLink = wrap.querySelector('.lcs-login-signup a'); 16 if (signupLink && tvAjax.signupUrl) { 17 signupLink.setAttribute('href', tvAjax.signupUrl); 18 } 19 20 var form = wrap.querySelector('.lcs-login-form'); 21 if (!form) return; 22 23 var userInput = form.querySelector('#lcs-login-username'); 24 var passInput = form.querySelector('#lcs-login-password'); 25 var submitBtn = form.querySelector('.lcs-login-submit'); 26 if (!userInput || !passInput || !submitBtn) return; 27 28 var btnDefaultText = submitBtn.textContent; 29 30 // header-megamenu.php has no message slot for this form â inject one. 31 var msgBox = document.createElement('p'); 32 msgBox.className = 'lcs-login-message'; 33 msgBox.setAttribute('role', 'alert'); 34 form.insertBefore(msgBox, submitBtn); 35 36 function showMessage(isError, text) { 37 msgBox.textContent = text; 38 msgBox.className = 39 'lcs-login-message ' + (isError ? 'lcs-login-message-error' : 'lcs-login-message-success'); 40 } 41 42 function clearMessage() { 43 msgBox.textContent = ''; 44 msgBox.className = 'lcs-login-message'; 45 } 46 47 form.addEventListener('submit', function (e) { 48 e.preventDefault(); 49 e.stopPropagation(); 50 if (submitBtn.disabled) return; 51 52 clearMessage(); 53 54 if (!userInput.value.trim() || !passInput.value) { 55 showMessage(true, 'Please enter your username/email and password.'); 56 return; 57 } 58 59 submitBtn.disabled = true; 60 submitBtn.textContent = 'Logging inâ¦'; 61 62 var data = new FormData(); 63 data.append('action', 'tv_login'); 64 data.append('tv_login_nonce', tvAjax.loginNonce); 65 data.append('tv_user', userInput.value.trim()); 66 data.append('tv_pass', passInput.value); 67 68 fetch(tvAjax.url, { 69 method: 'POST', 70 body: data, 71 credentials: 'same-origin', 72 }) 73 .then(function (r) { 74 return r.json(); 75 }) 76 .then(function (res) { 77 submitBtn.disabled = false; 78 submitBtn.textContent = btnDefaultText; 79 80 if (res.success) { 81 form.reset(); 82 clearMessage(); 83 window.location.href = res.data.redirect; 84 return; 85 } 86 showMessage(true, res.data.message); 87 }) 88 .catch(function () { 89 submitBtn.disabled = false; 90 submitBtn.textContent = btnDefaultText; 91 showMessage(true, 'Something went wrong. Please try again.'); 92 }); 93 }); 94 }); 95})();
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.