PageSourceSearch

https://www.intox.com/wp-content/plugins/customer-email-verificati…/assets/js/signup-script.js?ver=1790280543

js intox.com collected 2026-09-24 20:15:34 UTC 7,705 bytes, 189 lines download raw bytes

1jQuery(document).ready(function($) {
2    if (cev_ajax.enableEmailVerification) {
3        var otpVerified = false;
4
5        function displayError(message) {
6            var $form = $('#customer_login');
7            $form.prepend('<div class="woocommerce-error">' + message + '</div>');
8        }
9
10        function clearErrors() {
11            $('.woocommerce-error').remove();
12        }
13
14        // Set the value of email_verification hidden field to false
15        $('input[name="email_verification"]').val('false');
16        
17        // Add a class to the register button if email_verification is false
18        $('button[name="register"]').addClass('email_verification_popup');
19
20        // Handle the register button click event
21        $(document).on('click', '.email_verification_popup', function(e) {
22            if (!otpVerified && $(this).hasClass('email_verification_popup')) {
23                e.preventDefault();
24                clearErrors();
25                var $button = $(this);
26                $('.cev_loading_overlay').css('display', 'block');
27
28                var $form = $(this).closest('form');
29                var email = $form.find('#reg_email').val();
30                var password = $form.find('#reg_password').val();
31
32                if (!email) {
33                    displayError(cev_ajax.cev_email_validation);
34                    $('.cev_loading_overlay').css('display', 'none');
35                    return;
36                }
37                if (cev_ajax.password_setup_link_enabled == "no") {
38                    if (!password) {
39                        displayError(cev_ajax.cev_password_validation);
40                        $('.cev_loading_overlay').css('display', 'none');
41                        return;
42                    }
43                }
44                
45
46                // AJAX request to check if the email is already registered
47                $.ajax({
48                    url: cev_ajax.ajax_url,
49                    type: 'POST',
50                    data: $('.woocommerce-form-register').serialize() + '&action=check_email_exists&nonce=' + cev_ajax.nonce,
51                    success: function(response) {
52                        if (response.data.exists) {
53                            displayError(cev_ajax.cev_email_exists_validation);
54                            $('.cev_loading_overlay').css('display', 'none');
55                        } else if (response.data.not_valid) {
56                            displayError(cev_ajax.cev_valid_email_validation);
57                            $('.cev_loading_overlay').css('display', 'none');
58                        } else if (response.data.already_verify) {
59                            $form.find('button[name="register"]').removeClass('email_verification_popup');
60                            $form.find('input[name="email_verification"]').val('true');
61                            $form.find('button[name="register"]').trigger('click');
62                            $('.cev_loading_overlay').css('display', 'none');
63                        } else if (response.data.email) {
64                            $('#otp-popup').show();
65                            $('.cev_loading_overlay').css('display', 'none');
66                        } else if (response.data.validation == false ) {
67                            displayError(response.data.message);
68                            $('.cev_loading_overlay').css('display', 'none');
69                        } else {
70                            $('.cev_loading_overlay').css('display', 'none');
71                        }
72                    }
73                });
74            }
75        });
76
77        // OTP input handling
78        $('.otp-input').on('input', function() {
79            var $this = $(this);
80            var index = $this.index();
81          
82            if ($this.val().length === 1) {
83                if (index < $('.otp-input').length - 1) {
84                    $('.otp-input').eq(index + 1).focus();
85                } else {
86                    $('#verify-otp-button').trigger('click');
87                }
88            }
89        });
90
91        $('.otp-input').on('keydown', function(e) {
92            var $this = $(this);
93            var index = $this.index();
94
95            if (e.keyCode === 8 && $this.val().length === 0) {
96                if (index > 0) {
97                    $('.otp-input').eq(index - 1).focus();
98                }
99            }
100        });
101
102        $('.otp-input').on('keypress', function(e) {
103            var charCode = (e.which) ? e.which : e.keyCode;
104            if (charCode < 48 || charCode > 57) {
105                e.preventDefault();
106            }
107        });
108
109        $('#verify-otp-button').on('click', function(event) {
110            event.preventDefault(); // Prevents page reload
111           
112            function getOtpValue() {
113                var otp = '';
114                $('.otp-input').each(function() {
115                    otp += $(this).val();
116                });
117                return otp;
118            }
119
120            var $form = $('.email_verification_popup').closest('form');
121            var email = $form.find('#reg_email').val();
122            var otp = getOtpValue();
123           
124            // Verify OTP using AJAX
125            $.ajax({
126                url: cev_ajax.ajax_url,
127                type: 'POST',
128                data: {
129                    action: 'verify_otp',
130                    otp: otp,
131                    email: email,
132                    nonce: cev_ajax.nonce 
133                },
134                success: function(response) {
135                   
136                    if (response.success) {
137                        
138                        if (response.data.verified) {
139                            $('#otp-popup').hide();
140
141                            $('<p class="success-message">Your email is verified successfully.</p>').insertBefore($form);
142
143                            $form.find('button[name="register"]').removeClass('email_verification_popup');
144                            $form.find('input[name="email_verification"]').val('true');
145                            $form.find('button[name="register"]').trigger('click');
146                        } else {
147                            displayError(response.data.message);
148                        }
149                    } else {
150                        $('.error_mesg').text(response.data.message).css('display', 'block');
151                    }
152                },
153                error: function(xhr, status, error) {
154                    displayError('Error: ' + error);
155                }
156            });
157        });
158
159        $('.send_again_link').on('click', function() {
160            var $form = $('.woocommerce-form-register__submit').closest('form');
161            var email = $form.find('#reg_email').val();
162            $.ajax({
163                url: cev_ajax.ajax_url,
164                type: 'POST',
165                data: {
166                    action: 'resend_otp',
167                    email: email,
168                    nonce: cev_ajax.nonce 
169                },
170                success: function(response) {
171                    if (response.data.email) {
172                        $('.resend_sucsess').show();
173                        setTimeout(function() {
174                            $('.resend_sucsess').hide();
175                        }, 5000); // Hide after 5 seconds
176                    } else {
177                        console.log('No email found in response.data');
178                    }
179                },
180                error: function(xhr, status, error) {
181                    displayError('Error: ' + error);
182                }
183            });
184        });
185    }
186    $(document).on('click', '.back_btn', function(e) {
187        $('#otp-popup').hide();
188    });
189});

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.