1/*globals $, Page_ClientValidate, grecaptcha */ 2(function (window) { 3 function overrideStyleForGoogleRecaptchaBadgeZIndex() { 4 $("<style type='text/css'> .grecaptcha-badge{ z-index: 999999 !important } </style>").appendTo("head"); 5 } 6 window.ReCaptchaUtil = window.ReCaptchaUtil || {}; 7 window.ReCaptchaUtil.overrideStyleForGoogleRecaptchaBadgeZIndex = overrideStyleForGoogleRecaptchaBadgeZIndex; 8})(window); 9 10function ReCaptcha(container, reCaptchaType, reCaptchaSiteKey, callback) { 11 var reCaptchaTimeout = 60000; 12 var self = this; 13 self.id = container.attr('id'); 14 self.timeoutId = null; 15 self.reCaptchaType = reCaptchaType; 16 self.reCaptchaSiteKey = reCaptchaSiteKey; 17 18 function setReCaptchaTimeout() { 19 var wrappers = container.find('.recaptcha-wrapper'); 20 var $wrapper = $(wrappers[0]); 21 22 $wrapper.closest(".form-group").find(".error-message").hide(); 23 self.timeoutId = setTimeout(function () { 24 grecaptcha.reset(self.widgetId); 25 26 var dialogHtml = '<div class="modal fade in" role="dialog" aria-hidden="true"><div class="modal-dialog modal-m"><div class="modal-content">'; 27 dialogHtml += '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title">Session expired</h4></div>'; 28 dialogHtml += '<div class="modal-body">Please verify recaptcha to renew your session.</div>'; 29 dialogHtml += '<div class="modal-footer" style="text-align:left;"><button type="button" class="btn btn-primary" data-dismiss="modal">OK</button></div>'; 30 dialogHtml += '</div></div></div>'; 31 var $dialog = $(dialogHtml); 32 $dialog.modal("show"); 33 $dialog.on("hidden.bs.modal", function (e) { 34 $(e.currentTarget).remove(); 35 }); 36 37 }, reCaptchaTimeout); 38 } 39 40 self.clearReCaptchaTimeout = function() { 41 if (self.timeoutId !== null) { 42 clearTimeout(self.timeoutId); 43 self.timeoutId = null; 44 } 45 }; 46 47 self.resetReCaptcha = function() { 48 grecaptcha.reset(self.widgetId); 49 }; 50 51 self.setRecaptchaAriaLabel = function(containerSelector, intervalId) { 52 var textarea = $(containerSelector).find(".g-recaptcha-response"); 53 if (textarea.length > 0) { 54 if (!$(textarea).attr("aria-label")) { 55 $(textarea).attr("aria-label", "Google Captcha"); 56 } 57 if (intervalId) { 58 clearInterval(intervalId); 59 } 60 } 61 }; 62 63 self.initRecaptchaAriaLabel = function(containerSelector) { 64 self.setRecaptchaAriaLabel(containerSelector, undefined); 65 var intervalId = setInterval(function () { 66 self.setRecaptchaAriaLabel(containerSelector, intervalId); 67 }, 50); 68 }; 69 70 self.initInvisibleRecaptcha = function() { 71 window.ReCaptchaUtil.overrideStyleForGoogleRecaptchaBadgeZIndex(); 72 var invisibleId = self.id + '-invisible-recaptcha'; 73 $("<div id='" + invisibleId + "'></div>").insertAfter(container); 74 var widgetId = grecaptcha.render(invisibleId, 75 { 76 sitekey: self.reCaptchaSiteKey, 77 callback: callback, 78 size: "invisible" 79 }); 80 var containerSelector = "div#" + invisibleId; 81 self.initRecaptchaAriaLabel(containerSelector); 82 return widgetId; 83 }; 84 85 self.initCheckboxRecaptcha = function() { 86 var wrappers = container.find('.recaptcha-wrapper'); 87 var $wrapper = $(wrappers[0]); 88 var widgetId = grecaptcha.render($wrapper.prop("id"), 89 { 90 sitekey: self.reCaptchaSiteKey, 91 callback: setReCaptchaTimeout 92 }); 93 $wrapper.attr("widget-id", widgetId); 94 var containerSelector = ".recaptcha-wrapper[widget-id='" + widgetId + "']"; 95 self.initRecaptchaAriaLabel(containerSelector); 96 return widgetId; 97 }; 98
99 function init() { 100 if (self.reCaptchaType === "invisible") { 101 return self.initInvisibleRecaptcha(); 102 } 103 return self.initCheckboxRecaptcha(); 104 } 105 106 self.widgetId = init(); 107 108 return self; 109}
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.