1//'recaptchaSite' variable must be present globally. recommended to set on MasterPages 2 3function addRecaptchaOnPageLoad() { 4 var hiddenField = document.getElementById("RecaptchaToken"); 5 if (hiddenField) { 6 loadScript('application/javascript', 'https://www.google.com/recaptcha/api.js?onload=initializeRecaptcha&render=' + recaptchaSite); 7 } 8} 9 10 11function loadScript(type, src) { 12 let scriptElem = document.createElement('script'); 13 scriptElem.type = type; 14 scriptElem.src = src; 15 document.head.appendChild(scriptElem); 16} 17 18function initializeRecaptcha() { 19 var hiddenField = document.getElementById("RecaptchaToken"); 20 function revalidateCaptcha(delayMs) { 21 setTimeout(function () { 22 grecaptcha.execute(recaptchaSite, { action: 'submit' }).then(function (token) { 23 hiddenField.value = token; 24 25 //Recaptcha token has a two minute time out, and we cannot generate the token before the form submission. Thus we re-generate the token every other minute. 26 revalidateCaptcha((1000 * 60 * 2) - 5); 27 }); 28 }, delayMs); 29 } 30 31 revalidateCaptcha(0); 32} 33 34//document ready in plain javascript 35if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { 36 //call on next available tick 37 setTimeout(addRecaptchaOnPageLoad, 1); 38} else { 39 document.addEventListener("DOMContentLoaded", function () { 40 addRecaptchaOnPageLoad(); 41 }); 42}
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.