1let responseCaptchaNormal; 2let responseCaptchaCart; 3 4const recaptchaConfigs = [ 5 { 6 elementId: 'g-recaptcha-checkbox', 7 btnSelector: '.js-btn-submit-form-recaptcha', 8 responseCaptchaId: responseCaptchaNormal 9 }, 10 { 11 elementId: 'g-recaptcha-checkbox-cart-login', 12 btnSelector: '', 13 responseCaptchaId: responseCaptchaCart 14 }, 15]; 16 17const handleWhenBackRecaptcha = () => { 18 if (isAndroid()) { 19 if (window.history.state?.toConfirm) { 20 recaptchaConfigs.forEach(config => { 21 if (config.responseCaptchaId != undefined) { 22 grecaptcha.reset(config.responseCaptchaId); 23 } 24 toggleButtonStatus(config.btnSelector); 25 }); 26 } 27 } else { 28 window.addEventListener("pageshow", function (event) { 29 let historyTraversal = event.persisted || 30 performance.getEntriesByType("navigation")[0].type === 'back_forward'; 31 if (historyTraversal) { 32 recaptchaConfigs.forEach(config => { 33 if (config.responseCaptchaId != undefined) { 34 grecaptcha.reset(config.responseCaptchaId); 35 } 36 toggleButtonStatus(config.btnSelector); 37 }); 38 } 39 }); 40 } 41}; 42 43function onExpiredRecaptcha(btnSelector) { 44 toggleButtonStatus(btnSelector); 45} 46 47function onloadCallback() { 48 recaptchaConfigs.forEach(config => { 49 const recaptchaElement = document.getElementById(config.elementId); 50 51 if (recaptchaElement) { 52 // Check if the element already has a reCAPTCHA rendered 53 if (!recaptchaElement.hasAttribute('data-recaptcha-rendered')) { 54 config.responseCaptchaId = grecaptcha.render(config.elementId, { 55 'sitekey': RECAPTCHA_SITE_KEY, 56 'callback': (response) => { 57 document.getElementById(config.elementId).setAttribute('data-g-recaptcha-response', response); 58 onSubmitRecaptcha(config.btnSelector, config.elementId); 59 }, 60 'expired-callback': () => onExpiredRecaptcha(config.btnSelector), 61 'error-callback': () => { 62 $(`#${config.elementId}`).remove(); 63 toggleButtonStatus(config.btnSelector, false); 64 } 65 }); 66 67 // Mark the element as rendered 68 recaptchaElement.setAttribute('data-recaptcha-rendered', 'true'); 69 } 70 } 71 }); 72} 73 74function onSubmitRecaptcha(btnSelector, elementId) { 75 toggleButtonStatus(btnSelector, false); 76 $(`#${elementId}`).siblings('.error-verify-recaptcha').text(''); 77} 78 79function isRecaptchaCheckedByElementId(elementId) { 80 const config = recaptchaConfigs.find(config => config.elementId === elementId); 81 82 if (config && config.responseCaptchaId != undefined) { 83 return grecaptcha.getResponse(config.responseCaptchaId); 84 } 85 86 return false; 87} 88 89function resetRecaptchaByElementId(elementId) { 90 const config = recaptchaConfigs.find(config => config.elementId === elementId); 91 92 if (config && config.responseCaptchaId != undefined) { 93 grecaptcha.reset(config.responseCaptchaId); 94 } 95} 96 97$(function () { 98 recaptchaConfigs.forEach(config => { 99 toggleButtonStatus(config.btnSelector); 100 }); 101 handleWhenBackRecaptcha(); 102});
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.