PageSourceSearch

https://obrixlabs.com/wp-content/plugins/case-user/style/js/user-form.js?ver=1.0.0

js obrixlabs.com collected 2026-10-07 00:30:41 UTC 7,802 bytes, 273 lines download raw bytes

1jQuery(document).ready(function($) {
2
3	"use strict";
4	/* enter key / input. */
5    $(document).find('.pxl-user-form-login .login-group').on('keypress', 'input', function(e) {
6		var keycode = (e.keyCode ? e.keyCode : e.which);
7
8		if (keycode == '13') {
9			pxl_user_login($(this));
10		}
11	});
12	/* event login key press */
13    $(document).find('.pxl-user-form-login .login-group').on('keypress', 'input', function(e) {
14		wl_alert( $(this), '', 'hide' );
15	});
16	/* login click. */
17	$(document).find('.pxl-user-form').on('click', '.button-login', function( e ) {
18		e.preventDefault();
19		pxl_user_login($(this));
20	});
21
22	/* register login */
23    $(document).find('.pxl-user-form-register').on('click', '.btn-up-register', function( e ) {
24		e.preventDefault();
25		pxl_user_register( $(this) );
26	});
27	/* event press key register login */
28    $(document).find('.pxl-user-form-register').on('keypress', 'input', function( e ) {
29		wl_alert( $(this), '', 'hide' );
30	});
31	/* enter for register */
32    $(document).find('.pxl-user-form').on('keypress', 'input', function(e) {
33		var keycode = (e.keyCode ? e.keyCode : e.which);
34		if (keycode == '13') {
35			pxl_user_register($(this));
36		}
37	});
38
39	/**
40	 * Register
41	 *
42	 * validate field, get field values, run register ajax
43	 **/
44	function pxl_user_register( e ) {
45
46		/* form element. */
47		var _form = e.parents('.pxl-user-form-register');
48
49		/* input object elements */
50		var input_user 			= _form.find('input#res_user');
51		var input_pass 			= _form.find('input#res_pass1');
52		var input_passconfirm 	= _form.find('input#res_pass2');
53		var input_email 		= _form.find('input#res_email');
54
55		var register_data = register_validation( input_user, input_pass, input_passconfirm, input_email );
56
57		/* ajax. */
58		if( register_data !== false ) {
59			/* disabled all elements. */
60			pxl_user_disabled(_form);
61			$.post(caseuser.ajax, {
62				'action'		: 'form_ajax_register',
63				'data'			: register_data,
64				'_ajax_nonce' 	: caseuser.nonce
65
66			}, function (response) {
67
68				/* if error. */
69				if (response.error == true) {
70					/* alert if user null. */
71					if ( response.user_null != undefined )
72						wl_alert( input_user, response.user_null );
73					/* alert if pass null. */
74					if ( response.pass_null != undefined )
75						wl_alert( input_pass, response.pass_null );
76					/* alert if email null */
77					if ( response.email_null != undefined )
78						wl_alert( input_email, response.email_null );
79					/* pass confirm */
80					if ( response.passconfirm != undefined )
81						wl_alert( input_passconfirm, response.passconfirm );
82					/* valid user name */
83					if ( response.user_invalid != undefined )
84						wl_alert( input_user, response.user_invalid );
85					/* user name exists */
86					if ( response.user_exists != undefined )
87						wl_alert( input_user, response.user_exists );
88					/* email registered */
89					if ( response.email_exists != undefined )
90						wl_alert( input_email, response.email_exists );
91				} else {
92					location.reload();
93				}
94			});
95			/* enable all elements. */
96			pxl_user_enable(_form);
97		}
98	}
99
100	/**
101	 * For validation fields
102	 * if all field is valid, return all fields value
103	 *
104	 * @param object input_user
105	 * @param object input_pass
106	 * @param object input_passconfirm
107	 * @param object input_email
108	 */
109	function register_validation( input_user, input_pass, input_passconfirm, input_email ) {
110		var is_form_valid = true;
111		/* get input val */
112		var input_user_val 		  = input_user.val().trim();
113		var input_pass_val 		  = input_pass.val().trim();
114		var input_passconfirm_val = input_passconfirm.val().trim();
115		var input_email_val 	  = input_email.val().trim();
116
117		if ( input_user_val == '' ) {
118			wl_alert( input_user, input_user.data('validate') );
119			is_form_valid = false;
120		} else if ( 4 > input_user_val.length ) {
121			wl_alert( input_user, input_user.data('user-length') );
122			is_form_valid = false;
123		}
124
125		if ( input_pass_val == '' ) {
126			wl_alert( input_pass, input_pass.data('validate') );
127			is_form_valid = false;
128		} else 		if ( 5 > input_pass_val.length ) {
129			wl_alert( input_pass, input_pass.data('pass-length') );
130			is_form_valid = false;
131		} else if ( input_pass_val != input_passconfirm_val ) {
132			wl_alert( input_passconfirm, input_passconfirm.data('pass-confirm') );
133			is_form_valid = false;
134		}
135
136		if ( input_email_val == '' ) {
137			wl_alert( input_email, input_email.data('validate') );
138			is_form_valid = false;
139		} else if( validateEmail(input_email_val) === false ) {
140			wl_alert( input_email, input_email.data('email-format') );
141			is_form_valid = false;
142		}
143
144		if( is_form_valid === true ) {
145			var register_data = {};
146			/* get register data. */
147			register_data.user 			= input_user_val;
148			register_data.pass 			= input_pass_val;
149			register_data.email 		= input_email_val;
150			register_data.passconfirm 	= input_passconfirm_val;
151			return register_data;
152		} else {
153			return false;
154		}
155	}
156
157	/**
158	 * login.
159	 * 
160	 * validate field, get field values, run ajax.
161	 * 
162	 * @author CaseThemes Team
163	 */
164	function pxl_user_login(e) {
165
166		var login_data = {};
167
168		/* form element. */
169		var _form = e.parents('.pxl-user-form');
170
171		/* input element. */
172		var input_user = _form.find('input.user_name');
173		var input_pass = _form.find('input.password');
174
175		/* get input val. */
176		var input_user_val = input_user.val();
177		var input_pass_val = input_pass.val();
178
179		/* validate user name. */
180		if (input_user_val == '')
181			wl_alert( input_user, input_user.data('validate') );
182
183		/* validate password. */
184		if (input_pass_val == '')
185			wl_alert( input_pass, input_pass.data('validate') );
186
187		/* get login data. */
188		login_data.user 		= input_user_val;
189		login_data.pass 		= input_pass_val;
190		login_data.rememberme 	= _form.find('input.rememberme').val();
191
192		/* id user & pass exists. */
193		if (login_data.user && login_data.pass) {
194			
195			/* disabled all elements. */
196			pxl_user_disabled(_form);
197
198			/* ajax. */
199			$.post(caseuser.ajax, {
200				'action' 		: 'pxl_user_login',
201				'data' 	 		: login_data,
202				'_ajax_nonce' 	: caseuser.nonce
203			}, function(response) {
204				/* if error. */
205				if (response.error == true) {
206					/* validate user. */
207					if (response.user != undefined) {
208						wl_alert( input_user, response.user );
209					}
210					/* validate pass. */
211					if (response.pass != undefined) {
212						wl_alert( input_pass, response.pass );
213					}
214
215				} else {
216					location.reload();
217				}
218				
219				/* enable all elements. */
220				pxl_user_enable(_form);
221			});
222		}
223	}
224
225	/**
226	 * Disabled all input, button, select.
227	 */
228	function pxl_user_disabled(_form) {
229		_form.find('input, button, select').each(function() {
230			$(this).prop('disabled', true);
231		});
232	}
233
234	/**
235	 * enable all input, button, select.
236	 */
237	function pxl_user_enable(_form) {
238		_form.find('input, button, select').each(function() {
239			$(this).prop('disabled', false);
240		});
241	}
242
243	/**
244	 * For validate email format
245	 */
246	function validateEmail(email) {
247		var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
248		return re.test(email);
249	}
250
251	/* For alert in Wellow site */
252	function wl_alert( obj, message, mode ) {
253
254		mode = (mode) ? mode : 'show';
255		if( mode == 'show' ) {
256
257			if( obj.next().hasClass('wpcf7-not-valid-tip') === false ) {
258				obj.after( '<span role="alert" class="wpcf7-not-valid-tip" style="display:none">' + message + '</span>' );
259				obj.next().fadeIn('slow');
260			} else {
261				if( obj.parent().find('.wpcf7-not-valid-tip').length > 0 ) {
262					obj.parent().find('.wpcf7-not-valid-tip').remove();
263					obj.after( '<span role="alert" class="wpcf7-not-valid-tip" style="display:none">' + message + '</span>' );
264					obj.next().fadeIn('slow');
265				}
266			}
267		} else {
268			if( obj.parent().find('.wpcf7-not-valid-tip').length > 0 ) {
269				obj.parent().find('.wpcf7-not-valid-tip').fadeOut('slow');
270			}
271		}
272	}
273});

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.