PageSourceSearch

https://www.lesscars.it/wp-content/plugins/sw-ajax-login/assets/js/ajax-auth-script.js?ver=1.6.0

js lesscars.it collected 2026-10-08 02:14:27 UTC 28,272 bytes, 970 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3
4InitializeAjaxLoginForms();
5
6/**
7 * 
8 * Facebook Login
9 *
10 */
11
12 //trigger Facebook login
13
14$('body').on('click', '.fb-login-button', function() {
15		FBLogin();
16		return	false;
17	});
18
19function inizializzaLoginFacebook() {
20
21    if ($('.fb-login-button').length) {
22        $.ajaxSetup({ cache: true });
23        $.getScript('https://connect.facebook.net/'+ajax_auth_object.locale+'/sdk.js', function(){
24          FB.init({
25            appId      : ajax_auth_object.facebook_id,
26            cookie     : true,
27            xfbml      : true,
28            version    : 'v3.2'
29          });     
30        });
31    }
32}
33
34// This is called with the results from from FB.getLoginStatus().
35function statusChangeCallback(response) {
36
37  if (response.status === 'connected') {
38      // Logged into your app and Facebook.
39      // we need to hide FB login button
40      $('#fblogin').hide();
41      //fetch data from facebook
42      getUserInfo();
43  } else if (response.status === 'not_authorized') {
44      // The person is logged into Facebook, but not your app.
45      $('#status').html('Please log into this app.');
46  } else {
47      // The person is not logged into Facebook, so we're not sure if
48      // they are logged into this app or not.
49      $('#status').html('Please log into facebook');
50  }
51}
52
53// This function is called when someone finishes with the Login
54// Button.  See the onlogin handler attached to it in the sample code below.
55function checkLoginState() {
56    FB.getLoginStatus(function(response) {
57      statusChangeCallback(response);
58    });
59}
60
61function FBLogin() {
62
63	 showToast(ajax_auth_object.loadingmessage,'<div class="swal-loading-css-big-relative"></div>',false);
64      FB.login(function(response) {
65         if (response.authResponse) 
66         {
67             getUserInfo(); //Get User Information.
68          } else
69          {
70           showToast(ajax_auth_object.facebook_error_1,'<i class="fa fa-exclamation"></i>',true);
71          }
72       },{scope: 'public_profile,email'});
73}
74
75function FBLogout() {
76
77  	FB.logout(function(response) {
78         //$('#fblogin').show(); //showing login button again
79         //$('#fbstatus').hide(); //hiding the status
80    });
81}
82
83function getUserInfo() {
84
85    FB.api('/me', {fields: 'first_name,last_name,email,hometown,link,picture'}, function(response) {
86     
87
88      $.ajax({
89            type: "POST",
90            dataType: 'json',
91            data: response,
92            url: ajax_auth_object.ajaxurl + '?action=swal-fblogin',
93            success: function(data) {
94             if (data.loggedin == true) {
95					        showToast(data.message,'<i class="fa fa-check"></i>',true);
96                  document.location.href = ajax_auth_object.redirecturl;
97                  ClosePopup();
98                } else {
99                	showToast(data.message,'<i class="fa fa-exclamation"></i>',true);
100                }
101            }
102      });
103
104    });
105	
106}
107
108
109/**
110 * 
111 * Twitter Login
112 *
113 */
114
115 $('body').on('click', '.twitter-login-button', function(e) {
116
117 	e.preventDefault;
118 	
119		$.ajax({
120            type: "POST",
121            dataType: 'json',
122            data: response,
123            url: ajax_auth_object.ajaxurl + '?action=swal-twlogin',
124            success: function(data) {
125             if (data.loggedin == true) {
126					showToast(data.message,'<i class="fa fa-check"></i>',true);
127                    document.location.href = ajax_auth_object.redirecturl;
128                    ClosePopup();
129                } else {
130                	showToast(data.message,'<i class="fa fa-exclamation"></i>',true);
131                }
132            }
133      });
134		return	false;
135	});
136
137
138/**
139 * 
140 * Other non Ajax Login
141 * this is just to show a loader as the login process is fully in PHP
142 *
143 */
144 $('body').on('click', '.google-login-button, .linkedin-login-button, .instagram-login-button', function(e) {
145    showToast(ajax_auth_object.loadingmessage,'<div class="swal-loading-css-big-relative"></div>',false);
146  });
147
148
149/**
150 * 
151 * Initialize all the forms
152 *
153 */
154function InitializeAjaxLoginForms() {
155
156      InitializeAjaxLoginSubmit();
157      inizializzaLoginFacebook();
158      /*
159      if ($('.g-recaptcha').length) {
160          //grecaptcha.reset();
161            var sitekey = $('.g-recaptcha').data('sitekey');
162            var captchaWidgetId = grecaptcha.render( 'myCaptcha', {
163              'sitekey' : sitekey,
164              'theme' : ajax_auth_object.recaptchatheme,
165            });
166          }
167          */
168}
169
170
171 /**
172  * 
173  * Function to open Login Popup
174  *
175  */
176	$('.sw-open-login').click(function(e) {
177    if (!$('.wrapper-ajax-forms').length) {
178      return true;
179    }
180    e.preventDefault();
181    if ($('.swal_form_tabs').length) {
182          $('.swal_form_tabs a').removeClass('active');
183          $('.pop_login').addClass('active');
184        }
185
186      var collegamento = ajax_auth_object.ajaxurl + '?action=getLoginForms';
187      if ($('#popup-wrapper-ajax-auth #swal-login').length || $('#popup-wrapper-ajax-auth .wrapper-logout').length) {
188          
189          openpopupauth(collegamento,false);
190        }         
191    });
192
193 /**
194  * 
195  * Function to open Register Popup
196  *
197  */
198  $('.sw-open-register').click(function(e) {
199    if (!$('.wrapper-ajax-forms').length) {
200      return true;
201    }
202    e.preventDefault();
203    if ($('.swal_form_tabs').length) {
204          $('.swal_form_tabs a').removeClass('active');
205          $('#pop_signup').addClass('active');
206        }
207      var collegamento = ajax_auth_object.ajaxurl + '?action=getLoginForms';
208      if ($('#popup-wrapper-ajax-auth #swal-register').length || $('#popup-wrapper-ajax-auth .wrapper-logout').length) {
209          
210          OpenRegisterForm();
211          openpopupauth(collegamento,false);
212        }         
213    });
214
215 /**
216  * 
217  * Function to open Forgot Password Popup
218  *
219  */
220  $('.sw-open-forgot-password').click(function(e) {
221    if (!$('.wrapper-ajax-forms').length) {
222      return true;
223    }
224    e.preventDefault();
225    if ($('.swal_form_tabs').length) {
226          $('.swal_form_tabs a').removeClass('active');
227          $('.pop_login').addClass('active');
228        }
229      var collegamento = ajax_auth_object.ajaxurl + '?action=getLoginForms';
230      if ($('#popup-wrapper-ajax-auth #forgot_password').length || $('#popup-wrapper-ajax-auth .wrapper-logout').length) {
231          
232          OpenPasswordForm();
233          openpopupauth(collegamento,false);
234        }         
235    });
236
237
238 /**
239  * 
240  * Function to open Logout Popup
241  *
242  */  
243  $('.swal-logout-menu-item,.open_logout,.woocommerce-MyAccount-navigation-link--customer-logout').click(function(e) {
244      e.preventDefault();
245      var collegamento = ajax_auth_object.ajaxurl + '?action=getLoginForms';
246      
247          openpopupauth(collegamento,false); 
248         
249    });
250
251
252 /**
253  * 
254  * Avoid that popup closes if clicked inside it.
255  *
256  */
257		$('body').on('click', '#popup-wrapper-ajax-auth', function(e) {
258		   e.stopPropagation();
259		})
260
261/**
262* 
263* On click to the links shows the selected form and hides all the others
264*
265*/
266	$('body').on('click', '#sw-wrapper-ajax-login .pop_login, #sw-wrapper-ajax-login #pop_signup, #sw-wrapper-ajax-login #pop_forgot', function(e) {
267      e.preventDefault();
268      formToFadeOut = '';
269      formToFadeOut2 = '';
270        formtoFadeIn = '';
271        if ($('.swal_form_tabs').length) {
272            $('.swal_form_tabs a').removeClass('active');
273          }
274        
275        if ($(this).attr('class') == 'pop_login') {
276            if ($('.swal_form_tabs').length) {
277              $(this).addClass('active');
278            }  
279            formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
280            if ($('#sw-wrapper-ajax-login #wrapper-register').length) {
281              formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-register');
282            }
283            formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-login');
284        }
285        if ($(this).attr('id') == 'pop_signup') {
286            if ($('.swal_form_tabs').length) {
287              $(this).addClass('active');
288            } 
289            formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-login');
290            formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
291            formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-register');
292        }
293        if ($(this).attr('id') == 'pop_forgot') {
294            if ($('.swal_form_tabs').length) {
295              $('.pop_login').addClass('active');
296            } 
297            formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-login');
298
299            if ($('#sw-wrapper-ajax-login #wrapper-register').length) {
300              formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-register');
301            }
302            formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
303        }
304        if (formToFadeOut2) {
305          // Check if has to disable fade animation
306           if (ajax_auth_object.swal_disable_fade == 0) {
307              formToFadeOut2.fadeOut(300, function () {
308                formToFadeOut.fadeOut(300, function () {
309                    formtoFadeIn.fadeIn(300);
310                }); 
311              }); 
312           } else {
313                formToFadeOut2.hide();
314                formToFadeOut.hide();
315                formtoFadeIn.show();
316           }
317          
318        } else {
319          formToFadeOut.fadeOut(300, function () {
320                formtoFadeIn.fadeIn(300);
321            }); 
322        }
323        
324    });
325
326/**
327* 
328* Set up login form as default form when the popup has been closed.
329* It avoids to show the other forms instead of login when it's opened again.
330*/
331function OpenLoginForm() {
332  var formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-register');
333  var formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
334  var formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-login');
335  formToFadeOut.hide();
336  formToFadeOut2.hide();
337  formtoFadeIn.show();
338}
339
340function OpenRegisterForm() {
341  var formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-login');
342  var formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
343  var formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-register');
344  formToFadeOut.hide();
345  formToFadeOut2.hide();
346  formtoFadeIn.show();
347}
348function OpenPasswordForm() {
349  var formToFadeOut = $('#sw-wrapper-ajax-login #wrapper-login');
350  var formToFadeOut2 = $('#sw-wrapper-ajax-login #wrapper-register');
351  var formtoFadeIn = $('#sw-wrapper-ajax-login #wrapper-forgot_password');
352  formToFadeOut.hide();
353  formToFadeOut2.hide();
354  formtoFadeIn.show();
355}
356
357
358// Append the loader to the button or element with 'add-loader-onclick' on click.
359
360	$('body').on('click', '.add-loader-onclick', function() {
361			//$(this).attr("disabled", true).html("<span>"+txt_button_sending+"</span>");
362			$(this).append("<div class='loading-css'></div>");
363		});
364
365
366
367/**
368 * 
369 * Opens ajax modal popup
370 *
371 * @preload: true = preloads the page on the DOM but keeps it hidden
372 *
373 */
374function openpopupauth(pagina,preload) {
375		
376		var hide_class = '';
377
378    recaptcha_version = $('#swal_recaptcha_register_version').val();
379			
380		  // wrapper per il popop a pagina con larghezza definita
381		  var tipowrapper = '<div id="popup-wrapper-ajax-auth"'+hide_class+'><div class="swal-loading-css-big"></div></div>';
382		  var divwrappage = '#popup-wrapper-ajax-auth';
383					
384				showOverlayAuth(preload);
385
386				//variabili
387				var $maschera = $(".login_overlay");
388
389				//se nel DOM non è gia presente il div del popup lo aggiunge
390				if (!$(divwrappage).length) {
391					$maschera.append($(tipowrapper).hide().fadeIn(500));
392				}
393
394				var $wrappage = $(divwrappage);
395				
396				//se il form non è gia presente nella pagina web allora lo carica via ajax
397				if (!$('#sw-wrapper-ajax-login').length ) {
398				  $wrappage.load(pagina, function() {
399
400				  		InitializeAjaxLoginForms();
401
402					}).hide().fadeIn(500);
403				} else {
404
405              //InitializeAjaxLoginForms();
406              if (recaptcha_version == '0') {
407                          grecaptcha.reset();
408                      }
409
410				}
411				
412				return false;
413}
414
415
416
417$('body').on('click', '.close-popup, div.login_overlay', function(e) {
418			e.preventDefault();
419            hideOverlayAuth();
420        });
421
422//funzione chiudi popup
423function ClosePopup() {
424	 $('#popup-wrapper-ajax-auth').fadeOut('slow', function (){
425	 $(this).remove();
426  });
427}
428
429
430/**
431 * 
432 * Show & Hide overlay
433 *
434 */
435
436function showOverlayAuth(preload) {
437		// if overlay div is not already on the DOM then adds it
438		if (!$('.login_overlay').length) {
439        	$('body').prepend('<div class="login_overlay"></div>');
440    	}
441    	// if preload is true doesn't do overlay fadein
442    	if (!preload) {
443    		$('body').css('overflow','hidden')
444        	$('.login_overlay').hide().fadeIn(200);
445    	}
446    }
447
448function hideOverlayAuth() {
449        $('div.login_overlay').fadeOut(300, function() {
450                //$(this).remove();
451                $('body').css('overflow','auto');
452                OpenLoginForm();
453            });
454    }
455
456
457/**
458 * 
459 * Show Toast message
460 *
461 * @autofadeout: true = automatically fadeout the toast message after 2 seconds;
462 *
463 */
464function showToast(testo,icona,autofadeout) {
465
466	fadeout = '';
467
468	if (autofadeout) {
469		fadeout = ' fadeout';
470	}
471	if ($(".swal-toast").length) {
472		$(".swal-toast").html(icona+testo);
473		if (autofadeout) {
474			$(".swal-toast").delay(2000).fadeOut("slow", function() {
475			$(this).remove();
476			});
477		}
478	} else {
479		$('body').append($('<div class="swal-toast'+fadeout+'">'+icona+testo+'</div>').hide().fadeIn('normal'));
480		$('.fadeout').delay(2000).fadeOut("slow", function() {
481			$(this).remove();
482			});
483		}
484	}
485
486
487/**
488 * 
489 * Fadeout and remove Toast message
490 *
491 */
492function hideToast() {
493
494    $('.swal-toast').fadeOut("slow", function() {
495      $(this).remove();
496      });
497  }
498
499/**
500 * 
501 * Show message into a div
502 *
503 */
504function showMessage(text,selector) {
505
506  if ($(selector).length) {
507    $(selector).html(nl2br(text));
508    $(selector).hide().fadeIn('normal');
509    }
510  }
511
512/**
513 * 
514 * Escape line break
515 *
516 */
517function nl2br (str, is_xhtml) {     
518    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br/>' : '<br>';      
519    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');  
520}  
521
522/**
523 * 
524 * Remove a parameter from form data
525 *
526 */
527function RemoveParameterFromFormData( formData, name ) {
528      
529      var newdata = formData.replace( new RegExp( `&${name}=[^&]*|${name}=[^&]*&` ), '' );
530
531      return newdata;
532    }
533
534/**
535 *
536 * Show/Hide password
537 *
538 */
539$('body').on('click','.swal-toggle-password', function (e) {
540
541    $(this).toggleClass("fa-eye fa-eye-slash");
542    var input = $($(this).attr("toggle"));
543    if (input.attr("type") == "password") {
544      input.attr("type", "text");
545    } else {
546      input.attr("type", "password");
547    }
548});
549
550
551/**
552 * 
553 * Perform Logout
554 *
555 */
556$('body').on('click','#logout-button', function (e) {
557
558    e.preventDefault();
559
560    showToast(ajax_auth_object.logoutmessage,'<div class="swal-loading-css-big-relative"></div>',false);
561    document.location.href = ajax_auth_object.redirecturllogout;
562    ClosePopup();
563  
564});
565
566
567/**
568 * 
569 * Handle Ajax form submit
570 *
571 */
572function HandleAjaxFormSubmit(action,redirect,dataForm,token) {
573
574    var submit = $("form#swal-login button, form#swal-register button");
575
576        // disable button onsubmit to avoid double submision
577        submit.attr("disabled", "disabled").addClass('disabled');
578
579        var recaptcha_version = $('#swal_recaptcha_register_version').val();
580
581        // Compose dataForm with the extra fields
582        dataForm = dataForm + '&action='+action;
583
584        if (token != '') {
585          dataForm = dataForm +'&g-recaptcha-response='+token;
586        }
587
588        $.ajax({
589              type: 'POST',
590              dataType: 'json',
591              url: ajax_auth_object.ajaxurl,
592              data: dataForm,
593              success: function (data) {
594              
595                  if (data.loggedin == true) {
596                      showToast(data.message,'<i class="fa fa-check"></i>',true);
597                          if (redirect) {
598                              if (redirect == 'show_message') {
599                                  // show message
600                                  showMessage(ajax_auth_object.registermessage,'#swal_register_form_message');
601                                  $('#swal_wrapper_register_fields').fadeOut('normal');
602
603                                  // enable button
604                                  submit.removeAttr("disabled").removeClass('disabled');
605
606                              } else if (redirect == 'go_to_login') {
607                                  // show message
608                                  showMessage(ajax_auth_object.registermessage,'#swal_login_form_message');
609                                  // enable button
610                                  submit.removeAttr("disabled").removeClass('disabled');
611                                  OpenLoginForm();
612
613                              } else {
614                                  document.location = redirect;
615                                  ClosePopup();
616                              }
617                             
618                          } else {
619                              document.location = ajax_auth_object.redirecturl;
620                              ClosePopup();
621                          }
622                          
623                  } else {
624                      if (recaptcha_version == '0') {
625                          grecaptcha.reset();
626                      }
627                      if (data.message == '2fa_required') {
628                        
629                        // show 2fa field and hide username and password fields
630                        manage2faInputFields();
631                      } else {
632                          showToast(data.message,'<i class="fa fa-exclamation"></i>',true);
633                          
634                      }
635                      submit.removeAttr("disabled").removeClass('disabled');
636                      
637                  }
638              }
639        }); // close $.ajax
640        
641        return false;
642}
643
644
645/**
646 * 
647 * Perform AJAX login/register on form submit
648 *
649 */
650function InitializeAjaxLoginSubmit() {
651
652  	$('form#swal-login, form#swal-register').on('submit', function (e) {
653
654        e.preventDefault();
655
656          if (!$(this).valid()) return false;
657           
658
659        showToast(ajax_auth_object.loadingmessage,'<div class="swal-loading-css-big-relative"></div>',false);
660
661        action = '';
662        recaptcha_version = '';
663        token = '';
664        redirect = '';
665
666        // Remove the action parameter from data form, it will be added later
667        var dataForm = RemoveParameterFromFormData( $(this).serialize(), 'action' );
668
669        if ($(this).attr('id') == 'swal-login') {
670
671        		action = 'ajaxlogin';
672            redirect = $('form#swal-login #redirect_to').val();
673
674            // Submit for via Ajax
675            HandleAjaxFormSubmit(action,redirect,dataForm,token);
676            
677
678        } else if ($(this).attr('id') == 'swal-register') {
679
680      			action = 'ajaxregister';
681            recaptcha_version = $('#swal_recaptcha_register_version').val();
682            redirect = $('form#swal-register #swal_register_page_to_redirect').val();
683
684            // reCAPTCHA enabled
685            if (ajax_auth_object.enablerecaptcha == '1') {
686
687                if (recaptcha_version == '1') {
688
689                    // reCAPTCHA v3
690                    grecaptcha.ready(function() {
691                            grecaptcha.execute(ajax_auth_object.recaptchakey, {action: 'register'}).then(function(token) {
692
693                              // add token to the hidden field
694                              //$('#swal_recaptcha_register').val(token);
695
696                              // Submit form via Ajax
697                              HandleAjaxFormSubmit(action,redirect,dataForm,token);
698                              
699                            });
700                        });
701                } else if (recaptcha_version == '0') {
702
703                    // reCAPTCHA v2
704                    HandleAjaxFormSubmit(action,redirect,dataForm,token);
705                }
706            } else {
707            // reCAPTCHA not enabled
708
709                // Submit form via Ajax without reCAPTCHA control
710                HandleAjaxFormSubmit(action,redirect,dataForm,token);
711            }
712    		}  
713          
714    });
715
716	
717    /**
718     * 
719     * Perform AJAX forgot password on form submit
720     *
721     */
722  	$('form#forgot_password').on('submit', function(e){
723
724        e.preventDefault();
725
726    		if (!$(this).valid()) return false;
727
728        showToast(ajax_auth_object.loadingmessage,'<div class="swal-loading-css-big-relative"></div>',false);
729
730        $('p.status').fadeOut('normal');
731
732        var submit = $("#forgot_password button");
733
734        // disable button onsubmit to avoid double submision
735        submit.attr("disabled", "disabled").addClass('disabled');
736
737    		form = $(this);
738    		$.ajax({
739        			type: 'POST',
740                    dataType: 'json',
741                    url: ajax_auth_object.ajaxurl,
742        			data: { 
743        				'action': 'ajaxforgotpassword', 
744        				'user_login': $('#user_login').val(), 
745        				'security': $('#forgotsecurity').val(), 
746        			},
747        			success: function(data){					
748
749                  if (data.loggedin == true) {
750                      showToast(data.message,'<i class="fa fa-check"></i>',true);
751                    } else {
752                      showToast(data.message,'<i class="fa fa-exclamation"></i>',true);
753                    }
754                    submit.removeAttr("disabled").removeClass('disabled');
755        			}
756    		});
757    		
758    		return false;
759  	});
760
761
762    /**
763     * 
764     * Perform AJAX reset password
765     *
766     */
767    $("form#resetPasswordForm").on('submit', function(e){
768
769        e.preventDefault();
770
771        if (!$(this).valid()) return false;
772
773        showToast(ajax_auth_object.loadingmessage,'<div class="swal-loading-css-big-relative"></div>',false);
774
775        var submit = $("div#resetPassword #wp-submit"),
776          message = $("div#resetPassword #message");
777
778
779        // disable button onsubmit to avoid double submision
780        submit.attr("disabled", "disabled").addClass('disabled');
781        message.fadeOut(200);
782
783        $.ajax({
784          type: 'POST',
785                dataType: 'json',
786                url: ajax_auth_object.ajaxurl,
787          data: { 
788              'action': 'reset_pass', 
789              'resetsecurity': $('#resetsecurity').val(), 
790              'pass1': $('#pass1').val(), 
791              'pass2': $('#pass2').val(),
792              'user_key': $('#user_key').val(),
793              'user_login_reset': $('#user_login_reset').val(),
794          },
795          success: function(data){          
796     
797              submit.removeAttr("disabled").removeClass('disabled');
798
799              if (data.loggedin == true) {
800                  showToast(data.message,'<i class="fa fa-check"></i>',false);
801                  document.location.href = ajax_auth_object.redirecturllogin+'/?password=changed';
802              } else {
803                  //showToast(data.message,'<i class="fa fa-exclamation"></i>',true);
804                  $('html, body').stop().animate({
805                      scrollTop: $('[id="message"]').offset().top -100
806                    }, 500);
807                    // display return data only for errors
808                  message.html( data.message ).fadeIn('normal');
809                  hideToast();
810              }
811
812          },
813          error: function () {
814              showToast(ajax_auth_object.facebook_error_2,'<i class="fa fa-exclamation"></i>',true);
815              submit.removeAttr("disabled").removeClass('disabled');
816          }
817        });
818
819        return false;
820    });
821
822    
823
824    /**
825     * Password strength function
826     */
827    function checkPasswordStrength( $pass1,
828                                    $pass2,
829                                    $strengthResult,
830                                    $submitButton,
831                                    blacklistArray ) {
832        var pass1 = $pass1.val();
833        var pass2 = $pass2.val();
834     
835        // Reset the form & meter
836        $submitButton.attr( 'disabled', 'disabled' );
837            $strengthResult.removeClass( 'short bad good strong' );
838     
839        // Extend our blacklist array with those from the inputs & site data
840        blacklistArray = blacklistArray.concat( wp.passwordStrength.userInputBlacklist() )
841     
842        // Get the password strength
843        var strength = wp.passwordStrength.meter( pass1, blacklistArray, pass2 );
844     
845        // Add the strength meter results
846        switch ( strength ) {
847     
848            case 2:
849                $strengthResult.addClass( 'bad' ).html( pwsL10n.bad );
850                break;
851     
852            case 3:
853                $strengthResult.addClass( 'good' ).html( pwsL10n.good );
854                break;
855     
856            case 4:
857                $strengthResult.addClass( 'strong' ).html( pwsL10n.strong );
858                break;
859     
860            case 5:
861                $strengthResult.addClass( 'short' ).html( pwsL10n.mismatch );
862                break;
863     
864            default:
865                $strengthResult.addClass( 'short' ).html( pwsL10n.short );
866     
867        }
868     
869        // The meter function returns a result even if pass2 is empty,
870        // enable only the submit button if the password is strong and
871        // both passwords are filled up
872        if ( 4 === strength && '' !== pass2.trim() ) {
873            $submitButton.removeAttr( 'disabled' );
874        }
875     
876        return strength;
877    }
878    
879    /**
880     *
881     * Perform password check
882     *
883     */
884    $( 'body' ).on( 'keyup', 'input[name=pass1], input[name=pass2]',
885        function( event ) {
886            checkPasswordStrength(
887                $('input[name=pass1]'),         // First password field
888                $('input[name=pass2]'), // Second password field
889                $('#password-strength'),           // Strength meter
890                $('input[type=submit]'),           // Submit button
891                ['black', 'listed', 'word']        // Blacklisted words
892            );
893        });
894
895
896    /**
897     *
898     * Client side form validation
899     *
900     */
901      if (jQuery("#swal-register").length) 
902      		jQuery("#swal-register").validate({
903            rules:{
904        			   password2:{ equalTo:'#signonpassword'}	
905        		      }
906          });
907
908      if (jQuery("#resetPasswordForm").length) {
909          jQuery("#resetPasswordForm").validate({
910            rules:{
911                pass2:{ equalTo:'#pass1'} 
912                  }
913          });
914      }
915      else if (jQuery("#swal-login").length) 
916  		    jQuery("#swal-login").validate();
917
918    	if(jQuery('#forgot_password').length)
919    		  jQuery('#forgot_password').validate();
920
921} // close InitializeAjaxLoginSubmit function
922
923    
924
925  /**
926   * 
927   * reset login form. remove 2fa field and show username and password fielfds
928   *
929   */
930  function manage2faInputFields() {
931      
932      var field = '<label for="username">'+ajax_auth_object.swal_2fa_label+'</label><div><input type="text" id="swal_2fa_code" name="swal_2fa_code" class="required" autocomplete="off"/><a href="#" class="swal_reset_2fa"><i class="fa fa-arrow-left" aria-hidden="true"></i> '+ajax_auth_object.swal_2fa_back+'</a></div>';
933
934          if ($('.swal_2fa_wrapper').length ) {
935            $('.swal-login-fields').hide();
936            $('.swal_2fa_wrapper').append(field).hide().fadeIn(500);
937            hideToast();
938          }
939  }
940
941  /**
942   * 
943   * Hide username and password fields and show 2fa field
944   *
945   */
946
947    $('body').on('click','.swal_reset_2fa', function(e) {
948
949        e.preventDefault();
950
951        $('.swal_2fa_wrapper').empty();
952        $('#swal_2fa_code').attr('value', '');
953        $('#password').attr('value', ''); 
954        $('.swal-login-fields').fadeIn(500);
955    });
956
957
958
959});
960
961function InitializeRecaptcha() {
962
963  if (jQuery('.g-recaptcha').length) {
964            var sitekey = jQuery('.g-recaptcha').data('sitekey');
965            var captchaWidgetId = grecaptcha.render( 'myCaptcha', {
966              'sitekey' : sitekey,
967              'theme' : ajax_auth_object.recaptchatheme,
968            });
969          }
970}

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.