1 2var ReCaptcha = (function () { 3 'use strict'; 4 5 function ReCaptcha() { 6 // enforces new 7 if (!(this instanceof ReCaptcha)) { 8 var self = new ReCaptcha(); 9 self.inited = false; 10 return self; 11 } 12 } 13 14 15 ReCaptcha.prototype.init = function ($forms, onSubmit) { 16 if(this.inited) { 17 return; 18 } 19 20 this.inited = true; 21 this.onSubmitCallback = onSubmit; 22 this.$forms = $forms; 23 } 24 25 ReCaptcha.prototype.inlineRecaptcha = function () { 26 return window.JavascriptHandler && (JavascriptHandler.Path == "/contact/" || JavascriptHandler.Path == "/subscribe/"); 27 } 28 29 ReCaptcha.prototype.initOnLoad = function () { 30 var self = this; 31 console.log('initOnLoad'); 32 if(!window.renderrecaptcha) { 33 window.renderrecaptcha = function(){ 34 if(recapchaKey == "") { 35 return; 36 } 37 var size = "invisible"; 38 if(self.inlineRecaptcha()) { 39 size = "normal" 40 } 41 _.each(self.$forms, function(el, key, list){ 42 var $form = $(el); 43 44 if($form.data('disable-recaptcha')) { 45 $form.submit(function(event){ 46 self.onSubmitCallback(event); 47 }); 48 return; 49 } 50 51 // A form can opt into the visible v2 checkbox regardless of path; 52 // without the attribute the path-based default above still applies. 53 var formSize = $form.data('recaptcha-visible') ? "normal" : size; 54 55 var recaptchaEl; 56 if($form.find(".recaptcha-placeholder").length > 0) { 57 recaptchaEl = $form.find(".recaptcha-placeholder").append('<div class="g-recaptcha--wrapper"><div class="g-recaptcha-manual"></div></div>'); 58 } else { 59 recaptchaEl = $form.append('<div class="g-recaptcha--wrapper"><div class="g-recaptcha-manual"></div></div>'); 60 console.log('recaptchaEl',recaptchaEl); 61 } 62 var recaptchaId = grecaptcha.render(recaptchaEl.find('.g-recaptcha-manual')[0], { 63 sitekey: recapchaKey, 64 callback: function(token){ 65 $form.attr('last-executed', new Date().getTime()); 66 $form.find("[type=submit]").removeClass('disabled'); 67 $form.submit(); 68 }, 69 'error-callback': function(e){ 70 $form.find("[type=submit]").removeClass('disabled'); 71 console.error(e); 72 }, 73 'expired-callback': function(e){ 74 $form.find("[type=submit]").removeClass('disabled'); 75 }, 76 badge: "bottomright", 77 size: formSize, 78 hl: globalLang 79 }); 80 $form.data('recapcha-id', recaptchaId); 81 }); 82 }; 83 } 84 } 85 86 ReCaptcha.prototype.JSUrl = function () { 87 var render = 'explicit'; 88 if(recapchaV3Key != "") { 89 render = recapchaV3Key; 90 } 91 this.initOnLoad(); 92 return 'https://www.recaptcha.net/recaptcha/api.js?onload=renderrecaptcha&render='+render; 93 } 94 95 ReCaptcha.prototype.onSubmit = function (event) { 96 event.preventDefault(); 97 98 var $form = $(event.target); 99 window.ReCaptcha.validate($form, event); 100 101 return false; 102 } 103 104 ReCaptcha.prototype.validate = function ($form, event) { 105 var self = this; 106 var now = new Date().getTime(); 107 if(recapchaKey != "" && 108 ($form.find('[name="g-recaptcha-response"]').length == 0 || 109 $form.find('[name="g-recaptcha-response"]').val() == "" || 110 $form.attr('last-executed').length == 0 || 111 now - parseInt($form.attr('last-executed')) > 3000 112 ) 113 ) { 114 $form.find('.form-progress').removeClass('d-none'); 115 $form.find("[type=submit]").addClass('disabled').attr('disabled', 'disabled'); 116 // hack to reenable submission 117 setTimeout(function () { 118 $form.find("[type=submit]").removeClass('disabled'); 119 $form.find("[type=submit]").removeAttr('disabled'); 120 $form.find('.form-progress').addClass('d-none'); 121 }, 10000); 122 123 grecaptcha.ready(function(){ 124 console.log("reset"); 125 grecaptcha.reset($form.data('recapcha-id')); 126 // disabled v3 127 if(recapchaV3Key && false) { 128 129 // v3 first 130 grecaptcha.execute(recapchaV3Key, {action: window.location.pathname.replace(/[^A-Za-z\/_]/g, "")}).then(function(token) { 131 $('[name="g-recaptcha-v3-response"]').remove(); 132 133 _.each(self.$forms, function (element, index) { 134 var $form = $(element); 135 $("<input>").attr("type", "hidden").attr("name", "g-recaptcha-v3-response").val(token).appendTo($form); 136 }); 137 138 // v2 now 139 grecaptcha.execute($form.data('recapcha-id')); 140 }, function(){ 141 grecaptcha.execute($form.data('recapcha-id')); 142 $form.find("[type=submit]").removeClass('disabled'); 143 $form.find('.form-progress').addClass('d-none'); 144 }); 145 } else { 146 try { 147 grecaptcha.execute($form.data('recapcha-id')); 148 } catch (error) { 149 console.error('Error executing reCAPTCHA:', error); 150 } 151 // $form.find("[type=submit]").removeClass('disabled'); 152 // $form.find('.form-progress').addClass('d-none'); 153 } 154 }); 155 156 } else { 157 this.onSubmitCallback(event); 158 } 159 } 160 161 return ReCaptcha; 162}())();
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.