PageSourceSearch

https://ckan.org/static/js/captcha.js

js ckan.org collected 2026-09-24 08:24:00 UTC 1,476 bytes, 45 lines download raw bytes

1var recaptchaWidgets = {};
2
3function renderRecaptchas(sitekey) {
4    // Find all forms that contain a button with class 'captcha-submit'
5    $('form').has('.captcha-submit').each(function() {
6        var formId = $(this).attr('id');
7        if (!formId) {
8            // Skip forms without an ID
9            return;
10        }
11        var containerId = 'recaptcha-container-' + formId;
12        // If the container does not exist, create it at the end of the form
13        if ($('#' + containerId).length === 0) {
14            $(this).append('<div id="' + containerId + '"></div>');
15        }
16        recaptchaWidgets[formId] = grecaptcha.render(containerId, {
17            'sitekey': sitekey,
18            'size': 'invisible',
19            'callback': function(token) {
20                onSubmit(token, formId);
21            }
22        });
23    });
24}
25
26$('.captcha-submit').on('click', function (event) {
27    event.preventDefault();
28    var formId = $(this).attr('data-form-id');
29    var form = '#' + formId;
30    if ($(form)[0].checkValidity() == true) {
31        grecaptcha.execute(recaptchaWidgets[formId]);
32    } else { 
33        $(form).find('input[type="submit"]').click();
34    }
35});
36
37function onSubmit(token, formId) {
38    var form = $('#' + formId);
39    form.append("<input type='hidden' name='g-recaptcha-response' value='" + token + "' />");
40    form.find('input[type="submit"]').click();
41}
42
43function onRecaptchaLoadCallback() {
44    renderRecaptchas(window.RECAPTCHA_SITE_KEY);
45}

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.