PageSourceSearch

https://my.namss.org/Scripts/quattro.captcha.js

js namss.org collected 2026-09-26 02:37:17 UTC 3,201 bytes, 96 lines download raw bytes

1//JS related to Captcha integration. TODO: extract google reCAPTCHA from quattro.common.js and move it here.
2
3//If window.page already exists, reuse it.If not, create an empty object { } and assign it.
4window.page = window.page || {};
5
6page.loadHCaptcha = function (scriptSrc, siteKey, containerId, tokenClientId) {
7    
8    function renderWidget() {
9        
10        const container = document.getElementById(containerId);
11        if (!container) {
12            //console.warn('hCaptcha container not found:', containerId);
13            return;
14        }
15
16        // If an iframe is already rendered inside, skip
17        if (container.querySelector('iframe')) {
18            return;
19        }
20
21        // Clear any previous widget (the same div is shared by recaptcha and hcaptcha)
22        container.innerHTML = '';
23        container.style.display = 'block';
24
25        try {
26            const widgetId = hcaptcha.render(containerId, {
27                sitekey: siteKey,
28                size: 'normal',
29                callback: function (token) {
30                    document.getElementById(tokenClientId).value = token;
31                },
32                'error-callback': function (errors) {
33                    console.error('hCaptcha verification failed', errors);
34                }
35            });
36            sessionStorage.setItem('hcaptchaWidgetId_' + containerId, widgetId);
37        }
38        catch (ex) {
39            console.error('Error initializing hCaptcha for', containerId, ex);
40        }
41    }
42
43    // If API loaded, mark loaded and render immediately
44    if (window.hcaptcha) {
45        renderWidget();
46        return;
47    }
48
49    // Define onload callback only once
50    if (!window.onHCaptchaLoad) {
51        window.onHCaptchaLoad = function () {
52            if (!window.hcaptcha) {
53                console.error('hCaptcha API did not load as expected.');
54                return;
55            }
56            renderWidget();
57        };
58    }
59    const existingScript = document.querySelector(`script[src^="${scriptSrc}"]`);
60    if (!existingScript) {
61        const sep = scriptSrc.includes('?') ? '&' : '?';
62        const script = document.createElement('script');
63        script.src = `${scriptSrc}${sep}onload=onHCaptchaLoad`;
64        script.async = true;
65        script.defer = true;
66        script.onerror = function () {
67            console.error('Failed to load hCaptcha script:', script.src);
68        };
69        document.head.appendChild(script);
70    }
71};
72page.resetHCaptcha = function (containerId) {
73    
74    // Ensure hCaptcha is available
75    if (typeof hcaptcha === 'undefined') {
76        console.warn('hCaptcha is not available. Cannot reset.');
77        return;
78    }
79
80    // Retrieve widget ID from sessionStorage
81    const widgetId = sessionStorage.getItem('hcaptchaWidgetId_' + containerId);
82
83    if (!widgetId) {
84        console.warn(`No widgetId found for container: ${containerId}`);
85        return;
86    }
87
88    try {
89        hcaptcha.reset(widgetId);
90    }
91    catch (e) {
92        console.error(`Failed to reset hCaptcha widget for container: ${containerId}`, e);
93    }
94};
95
96

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.