PageSourceSearch

https://www.tricityrecordnm.com/wp-content/themes/ballantine-news-…/js/herald-recaptcha-v3.js?ver=1786834150

js tricityrecordnm.com collected 2026-09-29 06:15:45 UTC 3,901 bytes, 117 lines download raw bytes

1(function () {
2    'use strict';
3
4    var config = window.HeraldRecaptchaV3 || {};
5    var siteKey = config.siteKey || '';
6    var tokenField = config.tokenField || 'herald_recaptcha_v3_token';
7    var actionField = config.actionField || 'herald_recaptcha_v3_action';
8    var refreshMs = Number(config.refreshMs || 90000);
9    var busy = false;
10
11    if (!siteKey) {
12        return;
13    }
14
15    function getForms() {
16        return Array.prototype.slice.call(document.querySelectorAll('form.wpforms-form'));
17    }
18
19    function getFormId(form) {
20        var idInput = form.querySelector('input[name="wpforms[id]"]');
21        if (idInput && idInput.value) {
22            return String(idInput.value).replace(/[^0-9]/g, '');
23        }
24
25        var match = String(form.id || '').match(/wpforms-form-(\d+)/);
26        return match ? match[1] : '';
27    }
28
29    function ensureHidden(form, name) {
30        var input = form.querySelector('input[name="' + name + '"]');
31        if (!input) {
32            input = document.createElement('input');
33            input.type = 'hidden';
34            input.name = name;
35            form.appendChild(input);
36        }
37        return input;
38    }
39
40    function setSubmitState(form, disabled) {
41        form.querySelectorAll('button[type="submit"], input[type="submit"]').forEach(function (button) {
42            button.disabled = disabled;
43            button.setAttribute('aria-disabled', disabled ? 'true' : 'false');
44        });
45    }
46
47    function showError(form) {
48        if (form.querySelector('.herald-recaptcha-v3-error')) {
49            return;
50        }
51        var message = document.createElement('div');
52        message.className = 'wpforms-error-container herald-recaptcha-v3-error';
53        message.setAttribute('role', 'alert');
54        message.textContent = config.errorMessage || 'Spam protection could not be initialized. Please refresh the page and try again.';
55        form.insertBefore(message, form.firstChild);
56    }
57
58    function refreshTokens() {
59        var forms = getForms();
60        if (!forms.length || busy || !window.grecaptcha || typeof window.grecaptcha.execute !== 'function') {
61            return;
62        }
63
64        busy = true;
65        Promise.all(forms.map(function (form) {
66            var formId = getFormId(form);
67            if (!formId) {
68                return Promise.resolve();
69            }
70
71            var action = 'wpforms_' + formId;
72            setSubmitState(form, true);
73
74            return window.grecaptcha.execute(siteKey, { action: action }).then(function (token) {
75                ensureHidden(form, tokenField).value = token;
76                ensureHidden(form, actionField).value = action;
77                form.dataset.heraldRecaptchaReady = '1';
78                setSubmitState(form, false);
79            }).catch(function () {
80                form.dataset.heraldRecaptchaReady = '0';
81                setSubmitState(form, true);
82                showError(form);
83            });
84        })).finally(function () {
85            busy = false;
86        });
87    }
88
89    function initialize() {
90        getForms().forEach(function (form) {
91            if (!form.dataset.heraldRecaptchaReady) {
92                setSubmitState(form, true);
93            }
94        });
95
96        if (!window.grecaptcha || typeof window.grecaptcha.ready !== 'function') {
97            window.setTimeout(initialize, 250);
98            return;
99        }
100
101        window.grecaptcha.ready(function () {
102            refreshTokens();
103            window.setInterval(refreshTokens, refreshMs);
104        });
105
106        var observer = new MutationObserver(function () {
107            refreshTokens();
108        });
109        observer.observe(document.documentElement, { childList: true, subtree: true });
110    }
111
112    if (document.readyState === 'loading') {
113        document.addEventListener('DOMContentLoaded', initialize);
114    } else {
115        initialize();
116    }
117}());

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.