PageSourceSearch

https://boca.guide/wp-content/plugins/ait-quick-comments/design/js/script.js?ver=1.0

js boca.guide collected 2026-10-09 04:23:04 UTC 9,489 bytes, 253 lines download raw bytes

1/* AIT Plugin Quick Comments */
2/* Main Script */
3jQuery(document).ready(function(){
4
5	jQuery('.quick-comments-container .quick-comments-toggle').on('click', function(){
6		var $container = jQuery('.quick-comments-container');
7		$container.find('.quick-comments-toggle').addClass('is-hidden');
8		$container.find('.quick-comments-form').show();
9		$container.addClass('form-shown');
10
11		if($container.find('.form-captcha img').length == 0){
12			jQuery.get(
13				jQuery('.quick-comments-container .quick-comments-form form').attr('action'),
14				{
15					'action': 'loadCaptcha',
16					'data': null
17				}
18			).done(function(xhr){
19				var data = JSON.parse(xhr);
20				var $container = jQuery('.quick-comments-container .quick-comments-form form');
21
22				$container.find('input[name="rand"]').val(data.rand);
23				// replace this with proper image
24				//$container.find('.form-captcha img').attr('src', data.url);
25				jQuery(data.html).insertBefore($container.find('input[name=captcha_check]'));
26
27				jQuery('.quick-comments-container').find('.form-value-overlay').hide();
28			});
29		}
30	});
31
32	jQuery('.quick-comments-container .quick-comments-form .form-header').on('click', function(){
33		var $container = jQuery('.quick-comments-container');
34		$container.find('.quick-comments-form').hide();
35		$container.find('.quick-comments-toggle').removeClass('is-hidden');
36		$container.removeClass('form-shown');
37	});
38
39	jQuery('.quick-comments-container .quick-comments-form .form-overflow').on('click', function(){
40		var $animationContainer = jQuery(this);
41		$animationContainer.fadeOut('fast');
42		$animationContainer.find('.form-notification').hide();
43	});
44
45	if(typeof jQuery.cookie("qc-comment_author") != "undefined"){
46		jQuery('.quick-comments-container .quick-comments-form form').find('input[name=comment_author]').val(jQuery.cookie("qc-comment_author"))
47	}
48	if(typeof jQuery.cookie("qc-comment_author_email") != "undefined"){
49		jQuery('.quick-comments-container .quick-comments-form form').find('input[name=comment_author_email]').val(jQuery.cookie("qc-comment_author_email"))
50	}
51
52	// load new captcha by ajax .. fix for caching plugins
53
54	/*jQuery.get(
55		jQuery('.quick-comments-container .quick-comments-form form').attr('action'),
56		{
57			'action': 'loadCaptcha',
58			'data': null
59		}
60	).done(function(xhr){
61		var data = JSON.parse(xhr);
62		var $container = jQuery('.quick-comments-container .quick-comments-form form');
63		var oldRand = $container.find('input[name="rand"]').val();
64		$container.find('input[name="rand"]').val(data.rand);
65		var oldHref = $container.find('.form-captcha img').attr('src');
66		if(oldHref){
67			$container.find('.form-captcha img').attr('src', oldHref.replace(oldRand, data.rand));
68		}
69	});*/
70
71	jQuery('.quick-comments-container .quick-comments-form form').submit(function(e){
72		var $animationContainer = jQuery('.quick-comments-container .quick-comments-form .form-overflow');
73		var $inputs = jQuery(this).find('input:not(:submit):not(:checkbox), textarea');
74		var $pmInput = jQuery(this).find('input[name=private_message]');
75		var $sbInput = jQuery(this).find('input[name=newsletter_subscribe]');
76		var $invalid = [];
77		var $ajaxData = {};
78
79		// display form overflow
80		$inputs.removeClass('invalid');
81		$animationContainer.fadeIn('fast');
82
83		$inputs.each(function(){
84			if(jQuery(this).val() != ""){
85				if(jQuery(this).attr('name') == "comment_author_email"){
86					var emailregex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
87					if(emailregex.test(jQuery(this).val())){
88						$ajaxData[jQuery(this).attr('name')] = jQuery(this).val();
89					} else {
90						$invalid.push(jQuery(this));
91					}
92				} else {
93					$ajaxData[jQuery(this).attr('name')] = jQuery(this).val();
94				}								
95			} else {
96				$invalid.push(jQuery(this));
97			}
98		});
99		$ajaxData['newsletter_subscribe'] = $sbInput.is(':checked') == true ? 1 : 0;
100
101        if ($sbInput.attr('type') == 'radio') {
102			// hotfix for radiobutton validation
103			if(jQuery(this).find('input[name=newsletter_subscribe]:checked').val() == null) {
104				$invalid.push(jQuery(this));
105			} else {
106				$ajaxData['newsletter_subscribe'] = jQuery(this).find('input[name=newsletter_subscribe]:checked').val();
107			}
108        } else {
109            $ajaxData['newsletter_subscribe'] = $sbInput.is(':checked') == true ? 1 : 0;
110        }
111		if($invalid.length > 0){
112			$animationContainer.find('.form-notification').hide();
113			var $displayedNotification = $animationContainer.find('.form-notification.form-validation-error');
114			$displayedNotification.show();
115
116			// display all invalids
117			jQuery.each($invalid, function(index, element){
118				element.addClass('invalid');
119			});
120
121			/*setTimeout(function(){
122				$animationContainer.fadeOut('fast');
123				$animationContainer.find('.form-notification').hide();
124			}, 3000);*/
125		} else {
126			$animationContainer.find('.form-notification').hide();
127			var $displayedNotification = $animationContainer.find('.form-notification.form-ajax-sending');
128			$displayedNotification.show();
129			// send it
130
131			if($pmInput.is(':checked')){
132				jQuery.post(
133					jQuery(this).attr('action'),
134					{
135						'action': 'sendPrivateQuestion',
136						'data': $ajaxData
137					}
138				).done(function(xhr){
139					$animationContainer.find('.form-notification').hide();
140					$displayedNotification = $animationContainer.find('.form-notification.form-ajax-success');
141					$displayedNotification.show();
142
143					// reset everything
144					$inputs.each(function(){
145						if(jQuery(this).attr('type') != "hidden"){
146							if(jQuery(this).attr('name') != 'comment_author' && jQuery(this).attr('name') != 'comment_author_email'){
147								if(jQuery(this).attr('name') == 'newsletter_subscribe') {
148									jQuery('#newsletter_subscribe_0').removeAttr('checked');
149									jQuery('#newsletter_subscribe_1').removeAttr('checked');
150								} else {
151									jQuery(this).val("");
152									jQuery(this).removeClass('invalid');
153								}
154							} else {
155								//store to seesion cookies
156								jQuery.cookie("qc-"+jQuery(this).attr('name'), jQuery(this).val());
157							}
158						}
159					});
160					$pmInput.removeAttr('checked');
161					// $sbInput.attr('checked', true);
162
163					if(jQuery('.quick-comments-container .form-captcha').length != 0){
164						jQuery.get(
165							jQuery('.quick-comments-container .quick-comments-form form').attr('action'),
166							{
167								'action': 'loadCaptcha',
168								'data': null
169							}
170						).done(function(xhr){
171							var data = JSON.parse(xhr);
172							var $container = jQuery('.quick-comments-container .quick-comments-form form');
173							var oldRand = $container.find('input[name="rand"]').val();
174							$container.find('input[name="rand"]').val(data.rand);
175							var oldHref = $container.find('.form-captcha img').attr('src');
176							if(oldHref){
177								$container.find('.form-captcha img').attr('src', oldHref.replace(oldRand, data.rand));
178							}
179						});
180					}
181				}).fail(function(xhr){
182					var data = JSON.parse(xhr.responseText);
183					$animationContainer.find('.form-notification').hide();
184					$displayedNotification = $animationContainer.find('.form-notification.'+data.msg);
185					$displayedNotification.show();
186
187					// dont reset everything // maybe new captcha
188				});
189			} else {
190				jQuery.post(
191					jQuery(this).attr('action'),
192					{
193						'action': 'storeQuestion',
194						'data': $ajaxData
195					}
196				).done(function(xhr){
197					$animationContainer.find('.form-notification').hide();
198					$displayedNotification = $animationContainer.find('.form-notification.form-ajax-success');
199					$displayedNotification.show();
200
201					// reset everything
202					$inputs.each(function(){
203						if(jQuery(this).attr('type') != "hidden"){
204							if(jQuery(this).attr('name') != 'comment_author' && jQuery(this).attr('name') != 'comment_author_email'){
205								if(jQuery(this).attr('name') == 'newsletter_subscribe') {
206									jQuery('#newsletter_subscribe_0').removeAttr('checked');
207									jQuery('#newsletter_subscribe_1').removeAttr('checked');
208								} else {
209									jQuery(this).val("");
210									jQuery(this).removeClass('invalid');
211								}
212							} else {
213								//store to seesion cookies
214								jQuery.cookie("qc-"+jQuery(this).attr('name'), jQuery(this).val());
215							}
216						}
217					});
218					$pmInput.removeAttr('checked');
219					// $sbInput.attr('checked', true);
220
221					if(jQuery('.quick-comments-container .form-captcha').length != 0){
222						jQuery.get(
223							jQuery('.quick-comments-container .quick-comments-form form').attr('action'),
224							{
225								'action': 'loadCaptcha',
226								'data': null
227							}
228						).done(function(xhr){
229							var data = JSON.parse(xhr);
230							var $container = jQuery('.quick-comments-container .quick-comments-form form');
231							var oldRand = $container.find('input[name="rand"]').val();
232							$container.find('input[name="rand"]').val(data.rand);
233							var oldHref = $container.find('.form-captcha img').attr('src');
234							if(oldHref){
235								$container.find('.form-captcha img').attr('src', oldHref.replace(oldRand, data.rand));
236							}
237						});
238					}
239				}).fail(function(xhr){
240					var data = JSON.parse(xhr.responseText);
241					$animationContainer.find('.form-notification').hide();
242					$displayedNotification = $animationContainer.find('.form-notification.'+data.msg);
243					$displayedNotification.show();
244
245					// dont reset everything // maybe new captcha
246				});
247			}
248		}
249
250		return false;		// always return false
251	});
252
253});

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.