1/* 2 * Plugin: Google reCAPTCHA in WP comments 3 * Path: /js 4 * File: recaptcha.js 5 * Since: 0.0.2 6 */ 7 8/* 9 * Module: Recaptcha functions for init form and verify responses 10 * Version: 9.1.1 11 * Description: This module changes the HTML structure of the form when it's displayed for prevent automatic sending, then it verifies the user's response and when 12 * the user's response is correct it rewrites the HTML structure of the form. 13 */ 14// Global var for storing the form attributes until the verification process is completed and correct. 15var attrsa = {}; 16 17// Write/rewrite form HTML structure and block/unblock send button. 18function griwpcChangeButton ( value, address ) { 19 20 var a, 21 form = GriwpcTools.getForm(), 22 ele = GriwpcTools.getButton( form ), 23 groupElem; 24 25 if ( ( ele === undefined ) || ( form === undefined ) ) 26 return; 27 28 ele = jQuery( ele ); 29 form = jQuery( form ); 30 31 if ( value === null ) { 32 33 // ID compatibility themes 34 if ( ele.length > 0 ) 35 ele.attr( 'disabled', '' ); 36 37 // Forcing blocked mode to all button, anchor, input, span type=submit HTML elements, even without ID 38 groupElem = form.find( '[type=submit]' ); 39 if ( groupElem.length > 0 ) 40 groupElem.attr( 'disabled', '' ); 41 42 a = form[0].attributes; 43 jQuery.each ( a, function (i, v ) { 44 if ( v != undefined ) 45 attrsa[ v.name ] = v.value; 46 }); 47 jQuery.each ( attrsa, function (i, v ) { 48 if ( ( i != 'id' ) && ( i != 'class' ) ) 49 form.removeAttr( i ); 50 }); 51 52 if ( 1 === parseInt( griwpco.allowCreditMode ) ) { 53 jQuery( '.google-recaptcha-container' ).append ( '<span class="plugin-credits" style="font-size:0.62rem" ><a target="_blank" href="' + griwpco.home_link_address + '" title="' + griwpco.home_link_title + '" rel="nofollow" >' + griwpco.home_link_text + '</a></span>' ); 54 } 55 56 } 57 if ( value === true ) { 58 59 // ID compatibility themes 60 if ( ele.length > 0 ) 61 ele.removeAttr ('disabled'); 62 63 // Forcing blocked mode to all button, anchor, input, span type=submit HTML elements, even without ID 64 groupElem = form.find( '[type=submit]' ); 65 if ( groupElem.length > 0 ) 66 groupElem.removeAttr ('disabled'); 67 68 jQuery.each ( attrsa, function (i, v ) { 69 form.attr( i, v ); 70 }); 71 72 form.append( '<input type="hidden" name="griwpcva" value="' + address + '">' ); 73 74 } 75 76} 77 78var griwpcProcessAjaxResponse = function( ajaxResponse ) { 79 if ( ( ajaxResponse.status === 200 ) && ( ajaxResponse.readyState === 4 ) && ( ajaxResponse.statusText === "OK" ) ) { 80 let processed = JSON.parse( ajaxResponse.response ); 81 if ( processed.data.result === 'OK' ) 82 griwpcChangeButton ( true, processed.data.address ); 83 else 84 console.log ( 'Error verifying reCAPTCHA: ', processed ); 85 } else { 86 console.log ( 'Error AJAX Call: ', ajaxResponse ); 87 } 88 89} 90 91var griwpcVerifyCallback = function( griwpcr ) { 92 GriwpcAjax.post ( griwpco.ajax_url, { 'action' : 'griwpc_verify_recaptcha', 'resp' : griwpcr }, griwpcProcessAjaxResponse, true ); 93} 94 95 96// Global onload Method 97var griwpcOnloadCallback = function() { 98 griwpco.recaptcha_elem = grecaptcha.render( griwpco.recaptcha_id, { 99 'sitekey' : griwpco.recaptcha_skey, 100 'theme' : griwpco.recaptcha_theme, 101 'type' : griwpco.recaptcha_type, 102 'size' : griwpco.recaptcha_size, 103 'tabindex' : 0, 104 'callback' : griwpcVerifyCallback 105 }); 106}; 107(function ($) { griwpcChangeButton ( null, null); })(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.