PageSourceSearch

https://cubaexplorer.com/wp-content/themes/cubaexplorer/assets/js/scripts/form.js?ver=1784816817

js cubaexplorer.com collected 2026-09-26 05:18:20 UTC 9,208 bytes, 255 lines download raw bytes

1_form = function($) {
2	
3	var public = {
4		newsletter_form_ajax: null,
5		newsletter_form_ajax_ans: null,
6		authentication_form_ajax: null,
7		authentication_form_ajax_ans: null,
8
9		unserialize: function (data) {
10			var r = {};
11			for (var i in data) {
12				var field = data[i];
13				r[field.name] = field.value;
14			}
15
16			return r;
17		}
18	};
19
20	var private = {
21		ajaxError: false,
22
23		init: function () {
24			$(document).ready(function () {
25				if (!$.validator.methods.ajax_user_error) {
26		            $.validator.addMethod('ajax_user_error', function (value, element) {
27	                    return (value == 'false');
28	                });
29		        }
30
31		        if (!$.validator.methods.ajax_password_error) {
32		            $.validator.addMethod('ajax_password_error', function (value, element) {
33	                    return (value == 'false');
34	                });
35		        }
36
37		        if (!$.validator.methods.ajax_error) {
38		            $.validator.addMethod('ajax_error', function (value, element) {
39	                    return (value == 'false');
40	                });
41		        }
42
43                $('#sign [name="username"]').change(function () {
44                	$('#sign [name="ajax_user_error"]').val('false');
45                	$('#sign [name="ajax_user_error"]').valid();
46                	$('#sign [name="ajax_error"]').val('false');
47                	$('#sign [name="ajax_error"]').valid();
48                })
49
50                $('#sign [name="password"]').change(function () {
51                	$('#sign [name="ajax_password_error"]').val('false');
52                	$('#sign [name="ajax_password_error"]').valid();
53                	$('#sign [name="ajax_error"]').val('false');
54                	$('#sign [name="ajax_error"]').valid();
55                })
56
57                // Reload page to refresh
58                setTimeout(function () {
59                	location.reload(); // 20 hours
60                }, 22*3600*1000);
61
62				private.form.authentication();
63				private.form.newsletter();
64				private.validate.messages();
65				private.components();
66		    })
67		},
68
69		components: function () {
70	        $('.dropdown-toggle').dropdown({
71	        	flip: false
72	        })
73		},
74
75		validate: {
76			messages: function () {
77				$.extend(jQuery.validator.messages, {
78				    required: "This field is required",
79					email: "Incorrect email format",
80		            email_google: "Incorrect email format",
81				    minlength: jQuery.validator.format("At least {0} characters."),
82				    /*remote: "Please fix this field.",
83				    url: "Please enter a valid URL.",
84				    date: "Please enter a valid date.",
85				    dateISO: "Please enter a valid date (ISO).",
86				    number: "Please enter a valid number.",
87				    digits: "Please enter only digits.",
88				    creditcard: "Please enter a valid credit card number.",
89				    equalTo: "Please enter the same value again.",
90				    accept: "Please enter a value with a valid extension.",
91				    maxlength: jQuery.validator.format("Please enter no more than {0} characters."),
92				    rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
93				    range: jQuery.validator.format("Please enter a value between {0} and {1}."),
94				    max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
95				    min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
96				*/});
97			}
98		},
99
100		form: {
101			authentication: function () {
102				$('form#sign').validate({
103					ignore: '.ignore'
104				});
105
106		        $('#sign [name="username"]').rules('add', {
107	                required: true,
108	                minlength: 3,
109	                messages: {
110	                    required: $('#sign [name="username"]').attr('data-error-msg-required'),
111	                    minlength: $('#sign [name="username"]').attr('data-error-msg-minlength')
112	                }
113	            });
114
115		        $('#sign [name="password"]').rules('add', {
116	                required: true,
117	                minlength: 5,
118	                messages: {
119	                    required: $('#sign [name="password"]').attr('data-error-msg-required'),
120	                    minlength: $('#sign [name="password"]').attr('data-error-msg-minlength')
121	                }
122	            });
123
124		        $('#sign [name="ajax_user_error"]').rules('add', {
125	                ajax_user_error: true
126	            });
127
128		        $('#sign [name="ajax_password_error"]').rules('add', {
129	                ajax_password_error: true
130	            });
131
132		        $('#sign [name="ajax_error"]').rules('add', {
133	                ajax_error: true
134	            });
135
136		        $('form#sign').submit(function (e) {
137		        	e.preventDefault();
138
139		            if ($('form#sign').valid()) {
140		            	$('.user-menu > a').click();
141		            	if ($.isFunction(public.authentication_form_ajax)) {
142		            		var data = public.authentication_form_ajax.call(this, $('form#contact').serializeArray());
143		            		gui.loader.show();
144		            		$.ajax({
145		            			type: "POST",
146		            			url: "/front-ajax",
147		            			data: {
148                    				action: 'login_check',
149		            				data: JSON.stringify(data),
150		            				nonce: $('#sign [name="nonce"]').val()
151		            			},
152		            		}).done(public.authentication_form_ajax_ans);
153		            	}
154		            }
155		        });
156			},
157
158			newsletter: function () {
159				$('form#contact').validate({
160		            rules: {
161		                /*'fullname': {
162		                    required: true,
163		                    minlength: 3
164		                },*/
165		                'email': {
166		                    email_google: true
167		                }
168		            },
169		            errorClass: "help-block error"
170		        });
171
172		        $('form#contact').submit(function (e) {
173		        	e.preventDefault();
174
175		            if ($('form#contact').valid()) {
176		            	// Call Ajax
177		            	if ($.isFunction(public.newsletter_form_ajax)) {
178		            		gui.loader.show('body');
179
180							grecaptcha.ready(function () {
181								grecaptcha.execute(google_recaptcha_site_key, { action: 'newsletter_recaptcha' })
182								.then(function (token) {
183									$('#contact #g-recaptcha-response').val(token);
184									$('.grecaptcha-badge').removeClass('animate__bounceOutRight');
185									$('.grecaptcha-badge').addClass('animate__animated animate__bounceInRight');
186									$('.grecaptcha-badge').css('opacity', '1');
187									setTimeout(function () {
188										$('.grecaptcha-badge').addClass('animate__bounceOutRight');
189									}, 5000);
190
191									// Site
192				                    var separate = document.domain.split('.');
193				                    separate.shift();
194				                    var currentDomain = separate.join('.');
195				            		
196				                	// Before submit
197				                	$.ajax(
198				                	{
199				                		type : 'POST',
200				                		url  : '/front-ajax',
201				                		data : {
202											action	    : 'contact_forms',
203											lang: lang,
204											form_type  : 'subscriber_form',
205											nonce      : subscriptionNonce,
206											first_name : $('#contact input[name="fullname"]').val(),
207											email      : $('#contact input[name="email"]').val(),
208											fulldomain : document.domain,
209											domain     : currentDomain,
210											recaptcha_response: $('#contact [name="g-recaptcha-response"]').val()
211				                		}
212				                	
213				               		// After submit	
214				                	}).done(function(reply) {
215				                		gui.loader.hide();
216
217				                		if (reply == "success") {
218					                		$('form#contact').trigger('reset');
219					                		$('.step-1').removeClass("show");
220					                		$('.step-2').addClass("show");
221					                	} else {
222						                	gui.alertify.alert({
223						                            label: 'OK',
224						                            custom_class: 'btn-outline v-middle'
225						                        },
226						                        '',
227						                        'We are having problems handling your request right now. Please try again or if the issue persists contact us.'
228						                    );
229					                	}
230				                	}).error(function () {
231						            	gui.loader.hide();
232
233					                	gui.alertify.alert({
234					                            label: 'OK',
235					                            custom_class: 'btn-outline v-middle'
236					                        },
237					                        '',
238					                        'We are having problems handling your request right now. Please try again or if the issue persists contact us.'
239					                    );					                    
240						            });
241								})
242							});
243		                }
244		            }
245		        });
246			}
247		}
248	};
249
250	private.init();
251
252	return public;
253}
254
255form = new _form(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.