1/** 2 * @file 3 * Attaches behaviors for the zipang captcha refresh module. 4 */ 5 6(function ($) { 7 "use strict"; 8 9 /** 10 * Attaches jQuery validate behavior to forms. 11 * 12 * @type {Drupal~behavior} 13 * 14 * @prop {Drupal~behaviorAttach} attach 15 * Attaches the outline behavior to the right context. 16 */ 17 Drupal.behaviors.CaptchaRefresh = { 18 attach: function (context) { 19 $('.reload-captcha', context).not('.processed').bind('click', function () { 20 $(this).addClass('processed'); 21 const $form = $(this).parents('form'); 22 // Send post query for getting new captcha data. 23 const date = new Date(); 24 const baseUrl = document.location.origin; 25 const url = baseUrl.replace(/\/$/g, '') + '/' + $(this).attr('href').replace(/^\//g, '') + '?' + date.getTime(); 26 // Adding loader. 27 $('.captcha').addClass('captcha--loading'); 28 $.get( 29 url, 30 {}, 31 function (response) { 32 if (response.status === 1) { 33 $('.captcha', $form).find('img').attr('src', response.data.url); 34 $('input[name=captcha_sid]', $form).val(response.data.sid); 35 $('input[name=captcha_token]', $form).val(response.data.token); 36 $('.captcha').removeClass('captcha--loading'); 37 } 38 else { 39 alert(response.message); 40 } 41 }, 42 'json' 43 ); 44 return false; 45 }); 46 } 47 }; 48})(jQuery);
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.