1var recaptchaKey = '6LeG31cqAAAAAArw_ESNIngzsqGAbR8F3Wr8pFDP'; //reCAPTCHA site key goes here� 2var recaptchaLoaded = false; // Flag to track if the reCAPTCHA script is already loaded� 3// Function to execute after the reCAPTCHA script loads� 4function runAfterRecaptchaLoaded() {� 5 if (!recaptchaLoaded) {� 6 recaptchaLoaded = true;� 7 grecaptcha.ready(function() {� 8 grecaptcha.execute(recaptchaKey, {action: 'submit'}).then(function(token) {� 9 // Set the generated token to the #token_generate form input.� 10 var response = document.querySelectorAll("[id=token_generate]");� 11 for (var e = 0; e < response.length; e++) {� 12 var responseItem = response[e];� 13 responseItem.value = token;� 14 }� 15 });� 16 });� 17 }� 18}� 19// Function to load the reCAPTCHA script dynamically� 20function loadRecaptchaScript() {� 21 var script = document.createElement('script');� 22 script.src = 'https://www.google.com/recaptcha/api.js?render=' + recaptchaKey;� 23 script.async = true;� 24 script.defer = true;� 25 document.head.appendChild(script);� 26 script.onload = runAfterRecaptchaLoaded; // Execute runAfterRecaptchaLoaded once the script is loaded� 27}� 28// Function to check if the form is close to the viewport� 29function checkFormCloseToViewport() {� 30 var form = document.querySelector(".recaptcha-form"); // Replace "recaptcha-form" with the actual class of your form� 31 if (form) {� 32 var options = {� 33 root: null,� 34 rootMargin: '0px',� 35 threshold: 0.1 // Change this threshold value as needed� 36 };� 37 var observer = new IntersectionObserver(function(entries, observer) {� 38 entries.forEach(function(entry) {� 39 if (entry.intersectionRatio >= 0.1) { // Execute the code when the form is close to 10% visible� 40 observer.unobserve(entry.target); // Stop observing once the form is close to the viewport� 41 loadRecaptchaScript(); // Load the reCAPTCHA script after 5 seconds� 42 }� 43 });� 44 }, options);� 45 observer.observe(form);� 46 }� 47}� 48// Use the "DOMContentLoaded" event to start checking for the form visibility.� 49document.addEventListener('DOMContentLoaded', function() {� 50 setTimeout(loadRecaptchaScript, 5000); // Load the reCAPTCHA script after 5 seconds� 51 checkFormCloseToViewport(); // Start checking for the form visibility immediately� 52});
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.