PageSourceSearch

https://www.sqlservercentral.com/wp-content/plugins/google-captcha/js/script.js?ver=1.39

js sqlservercentral.com collected 2026-10-01 09:12:25 UTC 8,299 bytes, 268 lines download raw bytes

1( function( $, gglcptch ) {
2	gglcptch = gglcptch || {};
3
4	gglcptch.prepare = function() {
5		/*
6		 * display reCaptcha for plugin`s block
7		 */
8		$( '.gglcptch_v1, .gglcptch_v2, .gglcptch_invisible' ).each( function() {
9			var container = $( this ).find( '.gglcptch_recaptcha' );
10			if (
11				container.is( ':empty' ) &&
12				( gglcptch.vars.visibility || $( this ).is( ':visible' ) === $( this ).is( ':not(:hidden)' ) )
13			) {
14				var containerId = container.attr( 'id' );
15				gglcptch.display( containerId );
16			}
17		} );
18
19		/*
20		 * display reCaptcha for others blocks
21		 * this part is neccessary because
22		 * we have disabled the connection to Google reCaptcha API from other plugins
23		 * via plugin`s php-functionality
24		 */
25		if ( 'v2' == gglcptch.options.version || 'invisible' == gglcptch.options.version ) {
26			$( '.g-recaptcha' ).each( function() {
27				/* reCAPTCHA will be generated into the empty block only */
28				if ( $( this ).html() === '' && $( this ).text() === '' ) {
29
30					/* get element`s ID */
31					var container = $( this ).attr( 'id' );
32
33					if ( typeof container == 'undefined' ) {
34						container = get_id();
35						$( this ).attr( 'id', container );
36					}
37
38					/* get reCapatcha parameters */
39					var sitekey  = $( this ).attr( 'data-sitekey' ),
40						theme    = $( this ).attr( 'data-theme' ),
41						lang     = $( this ).attr( 'data-lang' ),
42						size     = $( this ).attr( 'data-size' ),
43						type     = $( this ).attr( 'data-type' ),
44						tabindex = $( this ).attr( 'data-tabindex' ),
45						callback = $( this ).attr( 'data-callback' ),
46						ex_call  = $( this ).attr( 'data-expired-callback' ),
47						stoken   = $( this ).attr( 'data-stoken' ),
48						params   = [];
49
50					params['sitekey'] = sitekey ? sitekey : gglcptch.options.sitekey;
51					if ( !! theme ) {
52						params['theme'] = theme;
53					}
54					if ( !! lang ) {
55						params['lang'] = lang;
56					}
57					if ( !! size ) {
58						params['size'] = size;
59					}
60					if ( !! type ) {
61						params['type'] = type;
62					}
63					if ( !! tabindex ) {
64						params['tabindex'] = tabindex;
65					}
66					if ( !! callback ) {
67						params['callback'] = callback;
68					}
69					if ( !! ex_call ) {
70						params['expired-callback'] = ex_call;
71					}
72					if ( !! stoken ) {
73						params['stoken'] = stoken;
74					}
75
76					gglcptch.display( container, false, params );
77				}
78			} );
79
80			/*
81			 * count the number of reCAPTCHA blocks in the form
82			 */
83			$( 'form' ).each( function() {
84				if ( $( this ).contents().find( 'iframe[title="recaptcha widget"]' ).length > 1 && ! $( this ).children( '.gglcptch_dublicate_error' ).length ) {
85					$( this ).prepend( '<div class="gglcptch_dublicate_error error" style="color: red;">' + gglcptch.options.error + '</div><br />\n' );
86				}
87			} );
88		}
89	};
90
91	gglcptch.display = function( container, v1_add_to_last_element, params ) {
92		if ( typeof( container ) == 'undefined' || container == '' || typeof( gglcptch.options ) == 'undefined' ) {
93			return;
94		}
95
96		function storeEvents( el ) {
97			var target = el,
98				events = $._data( el.get( 0 ), 'events' );
99			/* restoring events */
100			if ( typeof events != 'undefined' ) {
101				var storedEvents = {};
102				$.extend( true, storedEvents, events );
103				target.off();
104				target.data( 'storedEvents', storedEvents );
105			}
106			/* storing and removing onclick action */
107			if ( 'undefined' != typeof target.attr( 'onclick' ) ) {
108				target.attr( 'gglcptch-onclick', target.attr( 'onclick') );
109				target.removeAttr( 'onclick' );
110			}
111		}
112
113		function restoreEvents( el ) {
114			var target = el,
115				events = target.data( 'storedEvents' );
116			/* restoring events */
117			if ( typeof events != 'undefined' ) {
118				for ( var event in events ) {
119					for ( var i = 0; i < events[event].length; i++ ) {
120						target.on( event, events[event][i] );
121					}
122				}
123			}
124			/* reset stored events */
125			target.removeData( 'storedEvents' );
126			/* restoring onclick action */
127			if ( 'undefined' != typeof target.attr( 'gglcptch-onclick' ) ) {
128				target.attr( 'onclick', target.attr( 'gglcptch-onclick' ) );
129				target.removeAttr( 'gglcptch-onclick' );
130			}
131		}
132
133		function storeOnSubmit( form, gglcptch_index ) {
134			form.on( 'submit', function( e ) {
135				if ( '' == form.find( '.g-recaptcha-response' ).val() ) {
136					e.preventDefault();
137					e.stopImmediatePropagation();
138					targetObject = $( e.target || e.srcElement || e.targetObject );
139					targetEvent = e.type;
140					grecaptcha.execute( gglcptch_index );
141				}
142			} ).find( 'input:submit, button' ).on( 'click', function( e ) {
143				if ( '' == form.find( '.g-recaptcha-response' ).val() ) {
144					e.preventDefault();
145					e.stopImmediatePropagation();
146					targetObject = $( e.target || e.srcElement || e.targetObject );
147					targetEvent = e.type;
148					grecaptcha.execute( gglcptch_index );
149				}
150			} );
151		}
152
153		var gglcptch_version = gglcptch.options.version;
154		v1_add_to_last_element = v1_add_to_last_element || false;
155
156		if ( 'v1' == gglcptch_version ) {
157			if ( Recaptcha.widget == null || v1_add_to_last_element == true ) {
158				Recaptcha.create( gglcptch.options.sitekey, container, { 'theme' : gglcptch.options.theme } );
159			}
160		}
161
162		if ( 'v2' == gglcptch_version ) {
163				if ( $( '#' + container ).parent().width() <= 300 ) {
164					var size = 'compact';
165				} else {
166					var size = 'normal';
167				}
168			var parameters = params ? params : { 'sitekey' : gglcptch.options.sitekey, 'theme' : gglcptch.options.theme, 'size' : size },
169				gglcptch_index = grecaptcha.render( container, parameters );
170			$( '#' + container ).data( 'gglcptch_index', gglcptch_index );
171		}
172
173		if ( 'invisible' == gglcptch_version ) {
174			var block = $( '#' + container ),
175				form = block.closest( 'form' ),
176				parameters = params ? params : { 'sitekey' : gglcptch.options.sitekey, 'size' : 'invisible', 'tabindex' : 9999 },
177				targetObject = false,
178				targetEvent = false;
179
180			if ( form.length ) {
181				storeEvents( form );
182				form.find( 'button, input:submit' ).each( function() {
183					storeEvents( $( this ) );
184				} );
185
186				/* Callback function works only in frontend */
187				if ( ! $( 'body' ).hasClass( 'wp-admin' ) ) {
188					parameters['callback'] = function( token ) {
189						form.off();
190						restoreEvents( form );
191						form.find( 'button, input:submit' ).off().each( function() {
192							restoreEvents( $( this ) );
193						} );
194						if ( targetObject && targetEvent ) {
195							targetObject.trigger( targetEvent );
196						}
197						form.find( 'button, input:submit' ).each( function() {
198							storeEvents( $( this ) );
199						} );
200						storeEvents( form );
201						storeOnSubmit( form, gglcptch_index );
202						grecaptcha.reset( gglcptch_index );
203					};
204				}
205
206				var gglcptch_index = grecaptcha.render( container, parameters );
207				block.data( { 'gglcptch_index' : gglcptch_index } );
208
209				if ( ! $( 'body' ).hasClass( 'wp-admin' ) ) {
210					storeOnSubmit( form, gglcptch_index );
211				}
212			}
213		}
214	};
215
216	$( document ).ready( function() {
217		var tryCounter = 0,
218			/* launching timer so that the function keeps trying to display the reCAPTCHA again and again until google js api is loaded */
219			gglcptch_timer = setInterval( function() {
220				if ( typeof Recaptcha != "undefined" || typeof grecaptcha != "undefined" ) {
221					try {
222						gglcptch.prepare();
223					} catch ( e ) {
224						console.log( 'Unexpected error occurred: ', e );
225					}
226					clearInterval( gglcptch_timer );
227				}
228				tryCounter++;
229				/* Stop trying after 10 times */
230				if ( tryCounter >= 10 ) {
231					clearInterval( gglcptch_timer );
232				}
233			}, 1000 );
234
235		function gglcptch_prepare() {
236			if ( typeof Recaptcha != "undefined" || typeof grecaptcha != "undefined" ) {
237				try {
238					gglcptch.prepare();
239				} catch ( err ) {
240					console.log( err );
241				}
242			}
243		}
244
245		$( window ).on( 'load', gglcptch_prepare );
246
247		$( '.woocommerce' ).on( 'click', '.woocommerce-tabs', gglcptch_prepare );
248
249		$( '#recaptcha_widget_div' ).on( 'input paste change', '#recaptcha_response_field', cleanError );
250	} );
251
252	function cleanError() {
253		$error = $( this ).parents( '#recaptcha_widget_div' ).next( '#gglcptch_error' );
254		if ( $error.length ) {
255			$error.remove();
256		}
257	}
258
259	function get_id() {
260		var id = 'gglcptch_recaptcha_' + Math.floor( Math.random() * 1000 );
261		if ( $( '#' + id ).length ) {
262			id = get_id();
263		} else {
264			return id;
265		}
266	}
267
268} )( jQuery, gglcptch );

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.