PageSourceSearch

https://engagenrv.org/application/js/hive-antispam-grecaptcha-checkbox.js?_v=2.70.24.0

js engagenrv.org collected 2026-09-30 11:57:26 UTC 5,948 bytes, 154 lines download raw bytes

1(function (global, $) {
2    'use strict';
3
4    var debug = false;
5
6    var HiveAntiSpam;
7    var grecaptchas = global.grecaptchas = global.grecaptchas || [];
8
9    // Defer render work until the Google API is available
10    var recaptchaReadyQueue = global.__hiveRecaptchaReadyQueue = global.__hiveRecaptchaReadyQueue || [];
11
12    function enqueueRecaptchaCallback(callback) {
13        if (typeof callback !== 'function') {
14            return;
15        }
16
17        if (typeof grecaptcha !== 'undefined') {
18            if (typeof grecaptcha.ready === 'function') {
19                grecaptcha.ready(callback);
20            } else {
21                callback();
22            }
23            return;
24        }
25
26        recaptchaReadyQueue.push(callback);
27    }
28
29    function flushRecaptchaQueue() {
30        if (typeof grecaptcha === 'undefined') {
31            return;
32        }
33
34        var callbacks = recaptchaReadyQueue.splice(0, recaptchaReadyQueue.length);
35        var hasReady = typeof grecaptcha.ready === 'function';
36
37        callbacks.forEach(function (cb) {
38            if (typeof cb === 'function') {
39                if (hasReady) {
40                    grecaptcha.ready(cb);
41                } else {
42                    cb();
43                }
44            }
45        });
46    }
47
48    global.__hiveFlushRecaptchaQueue = flushRecaptchaQueue;
49
50    HiveAntiSpam = {
51        onLoad: function () {
52            debug && console.info('initialize checkbox recaptchas');
53
54            // Queue execution so grecaptcha.render is only called once the API is ready
55            enqueueRecaptchaCallback(function () {
56                if (!$ || typeof $.fn === 'undefined') {
57                    console.error('HiveAntiSpam reCAPTCHA checkbox initialised before jQuery was available.');
58                    return;
59                }
60
61                $.each($('.grecaptcha-checkbox'), function () {
62                    var object = $(this);
63                    if(typeof object.attr('id')  !== 'undefined' && !object.is(':hidden'))
64                    {
65                        var g = grecaptchas.slice();
66                        var skip = false;
67                        $.each(g, function(i,o) {
68                            if(o.el_id == object.attr('id')) {
69                                skip = true;
70                                return false;
71                            }
72                        });
73
74                        if(skip){
75                            return true;
76                        }
77
78                        // Guard against grecaptcha.render throwing when the API is misconfigured
79                        try {
80                            var grecaptcha_widget_id = grecaptcha.render(object.attr('id'), {
81                                'sitekey' : object.data('sitekey'),
82                                'theme' : object.data('theme'),
83                                'callback' : function(token) {
84                                    debug && console.info('Callback after processing ['+ object.attr('id') +']: ' + token);
85                                    object.parents('form').find('[name=g-recaptcha-response]').val(token);
86                                }
87                            });
88                        } catch (error) {
89                            console.error('Error rendering reCAPTCHA for element ' + object.attr('id') + ':', error);
90                            // Log to Sentry if available - provides debugging context for edge cases
91                            if (window.Sentry && window.Sentry.captureException) {
92                                window.Sentry.captureException(error, {
93                                    extra: {
94                                        elementId: object.attr('id'),
95                                        sitekey: object.data('sitekey') ? 'present' : 'missing'
96                                    }
97                                });
98                            }
99                            return true; // Continue to next element - don't break entire page
100                        }
101
102                        if(typeof grecaptcha_widget_id !== 'undefined'){
103                            grecaptchas.push({
104                                'type': 'checkbox',
105                                'el_id': object.attr('id'),
106                                'grecaptcha_id': grecaptcha_widget_id
107                            });
108                        }
109                    }
110                });
111            });
112
113            $('.grecaptcha-checkbox')
114                .parents('.jl_magic_tabs_divider')
115                .off('jl_magic_tabs_show', onLoadRecaptchaCallback)
116                .on('jl_magic_tabs_show', onLoadRecaptchaCallback);
117        },
118        onChallengeClose : function () {},
119        onChallengeOpen : function () {},
120        evaluateRequest : function (form) {
121            return true;
122        },
123        reset: function (form) {
124            var el_id = "";
125            if (form && typeof form.find === 'function') {
126                el_id = form.find('.grecaptcha-checkbox').attr('id') || "";
127            }
128            if (!$ || typeof $.fn === 'undefined') {
129                console.warn('HiveAntiSpam reCAPTCHA reset skipped because jQuery is unavailable.');
130                return;
131            }
132            /* reset all captchas */
133            if (grecaptchas && grecaptchas.length)
134            {
135                $.each(grecaptchas, function (i,o) {
136                    if( o.grecaptcha_id > -1 || (el_id != "" && o.el_id == el_id)) {
137                        grecaptcha.reset(o.grecaptcha_id);
138                    }
139                });
140            }
141        },
142        initListeners : function () {},
143    };
144
145    global.HiveAntiSpam = HiveAntiSpam;
146
147}(this, this.jQuery));
148
149var onLoadRecaptchaCallback = function () {
150    if (typeof window.__hiveFlushRecaptchaQueue === 'function') {
151        window.__hiveFlushRecaptchaQueue();
152    }
153    HiveAntiSpam.onLoad();
154};

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.