PageSourceSearch

https://ganjkala.com/wp-content/plugins/digits/assets/js/main.js?ver=9.2.1

js ganjkala.com collected 2026-10-04 08:24:36 UTC 124,298 bytes, 3,437 lines download raw bytes

1function persianToEnglish(value) {
2    var newValue="";
3    for (var i=0;i<value.length;i++)
4    {
5        var ch=value.charCodeAt(i);
6        if (ch>=1776 && ch<=1785) // For Persian digits.
7        {
8            var newChar=ch-1728;
9            newValue=newValue+String.fromCharCode(newChar);
10        }
11        else if(ch>=1632 && ch<=1641) // For Arabic & Unix digits.
12        {
13            var newChar=ch-1584;
14            newValue=newValue+String.fromCharCode(newChar);
15        }
16        else
17            newValue=newValue+String.fromCharCode(ch);
18    }
19    return newValue;
20}
21//custom mersa
22    function custom_mersa_phone_prefix(countrycode, phone){
23        var phone_prefix = dig_mdet.digits_mersa_billing_phone_prefix;
24        switch(phone_prefix){
25            case 'cc':
26                phone = countrycode+phone;
27                break;
28            case 'ziro' :
29                phone = '0'+parseInt(phone);
30                break;
31            case 'none' :
32                phone = parseInt(phone);
33                break;
34        }
35        return phone;
36    }
37jQuery(function () {
38
39    var precode;
40    var secure_wrap = '<div class="digits-form_tab_wrapper"><div class="digits-form_tab_container"></div></div>';
41
42
43    var forgotPassChange = 0;
44    var dig_reg_wp_elem = jQuery("#dig_reg_wp_elem");
45    if (dig_reg_wp_elem.length) {
46        dig_reg_wp_elem = dig_reg_wp_elem.closest('form');
47        if (!dig_reg_wp_elem.hasClass("dokan-vendor-register")) {
48
49            if (dig_reg_wp_elem.find(".dig_wc_reg_form_end").length === 0) {
50                dig_reg_wp_elem.addClass('wp_reg');
51                dig_reg_wp_elem.find("#user_login").attr('id', 'user_uname');
52                jQuery(".digits_register").removeClass('wp_reg');
53            } else {
54                dig_reg_wp_elem.find(".dig_wp_bp_fields").remove();
55            }
56        }
57    }
58
59    var dig_login_wp_elem = jQuery("#dig_login_wp_elem");
60    if (dig_login_wp_elem.length) {
61        if (dig_mdet.login_mobile_accept > 0) {
62            dig_login_wp_elem = dig_login_wp_elem.closest('form');
63
64            if (dig_login_wp_elem.find(".loginuname").length === 0) {
65                dig_login_wp_elem.addClass('wp_login');
66                dig_login_wp_elem.find("input[type='text']").first().attr({'id': 'username', 'nan': 1});
67            } else {
68                dig_login_wp_elem.find(".dig_bb_wp_otp_field").remove();
69            }
70        }
71    }
72
73    var akCallback = -1;
74    var useWhatsApp = 0;
75
76    jQuery("#digit_emailaddress").closest("form").addClass("register");
77    jQuery("#wc_code_dig").closest("form").addClass("login");
78    jQuery("#digits_wc_code").closest("form").addClass("woocommerce-ResetPassword");
79
80    if (dig_log_obj.dig_dsb == 1) return;
81
82    var loader = jQuery(".dig_load_overlay");
83    var tokenCon;
84
85    function checkoutwc_comp() {
86        var cfw_login_modal = jQuery('#cfw_login_modal_form');
87        if (cfw_login_modal.length > 0) {
88            var cfw_username = cfw_login_modal.find('#cfw_login_username_field');
89            cfw_username.find('#cfw_login_username').attr({
90                'placeholder': dig_mdet.emailormobile,
91            }).addClass('digits_mobile_field');
92            cfw_username.find('label').text(dig_mdet.emailormobile);
93
94            cfw_login_modal.find('.loginViaContainer button,.digits-form_submit-btn').addClass('cfw-primary-btn');
95
96            var otp_container = cfw_login_modal.find('#dig_wc_log_otp_container');
97            if (otp_container.length > 0) {
98                otp_container.addClass('col-lg-12 cfw-text-input cfw-input-wrap cfw-label-is-floated');
99                otp_container.insertAfter(cfw_username);
100            }
101
102            if (dig_mdet.secure_forms) {
103                cfw_login_modal.find('#cfw_login_password_field').remove();
104                cfw_login_modal.find('#cfw-login-btn').remove();
105                cfw_login_modal.find('.cfw-login-modal-navigation').insertAfter(jQuery(cfw_login_modal.find('.digits-form_submit-btn')));
106
107                var last_cfw_submit_index = cfw_username.index() + 1
108                cfw_login_modal.children().slice(3, last_cfw_submit_index).wrapAll(secure_wrap);
109
110                cfw_username.find('#cfw_login_username').attr({
111                    'id': 'username',
112                });
113            }
114
115
116        }
117    }
118
119    function merge_billing_field() {
120        function dig_wc_merge_field(field_name) {
121            var bp_wc = jQuery("#" + field_name);
122            if (bp_wc.length > 0) {
123
124                var bp_wc_val = bp_wc.val();
125                var countrycode = dig_mdet.uccode.replace('+', '');
126                /*
127            // به خاطر تکرار شدن کد کشور در شماره صورتحساب ووکامرس کد کشور را از شماره مشتری حذف می کنم
128            //var phone_no = bp_wc_val.replace(dig_mdet.uccode+"0",'').replace(dig_mdet.uccode,'');
129            
130            //TODO: برای غیرفغال کردن کتابخانه تلفن کل شرط زیر را غیرفعال کن
131                if (bp_wc.data('countryCode')) {
132                    countrycode = bp_wc.data('countryCode');
133                } else {
134                    var phone_obj = libphonenumber.parsePhoneNumberFromString('+'+bp_wc_val.replace('+',''));
135*/
136                var phone_no = bp_wc_val;
137                if (bp_wc.attr('countryCode')) {
138                    countrycode = bp_wc.attr('countryCode');
139                    countrycode = countrycode.replace('+', '');
140                    if (bp_wc.attr('user_phone')) {
141                        phone_no = bp_wc.attr('user_phone');
142                    }
143                } else {
144                    var bp_wc_phone = bp_wc_val.replace('+', '');
145                    var phone_obj;
146                    if (!bp_wc_val.includes('+')) {
147                        if (bp_wc.attr('billing_country_code')) {
148                            var billingCountryCode = bp_wc.attr('billing_country_code');
149                            phone_obj = libphonenumber.parsePhoneNumberFromString('+' + billingCountryCode + bp_wc_phone);
150                        }
151                    }
152                    if (typeof phone_obj == "undefined") {
153                        phone_obj = libphonenumber.parsePhoneNumberFromString('+' + bp_wc_phone);
154                    }
155
156                    if (typeof phone_obj != "undefined") {
157                        countrycode = phone_obj.countryCallingCode;
158                        phone_no = phone_obj.nationalNumber;
159                    }
160                }
161
162                bp_wc.attr({
163                    'only-mob': 1,
164                    'f-mob': 1,
165                    'countryCode': countrycode,
166                    'value': phone_no,
167                    'mob': 1,
168                    "id": 'username',
169                    'data-dig-main': field_name,
170                }).addClass('mobile_field mobile_placeholder').parent().append('<input type="hidden" name="' + field_name + '" id="' + field_name + '" value="' + bp_wc_val + '" />');
171
172                if (field_name === "shipping_phone") {
173                    bp_wc.attr({'nan': 'digits_shipping_phone', 'name': 'digits_shipping_phone'});
174                }
175
176                return true;
177            }
178            return false;
179        }
180
181        var wc_phone_billing_merge = dig_wc_merge_field('billing_phone');
182        var wc_phone_shipping_merge = dig_wc_merge_field('shipping_phone');
183        if (wc_phone_billing_merge) {
184            checkoutwc_comp();
185        }
186    }
187
188    if(dig_mdet.enhance_wc_checkout_phonenumber == 1) {
189        merge_billing_field();
190    }
191
192
193    function loginuser(response) {
194        if (precode == response.code) {
195            return false;
196        }
197
198        var rememberMe = 0;
199        if (jQuery("#rememberme").length) {
200            rememberMe = jQuery("#rememberme:checked").length > 0;
201        }
202        precode = response.code;
203        jQuery.ajax({
204            type: 'post',
205            url: dig_mdet.ajax_url,
206            data: {
207                action: 'digits_login_user',
208                code: response.code,
209                csrf: response.state,
210                rememberMe: rememberMe,
211            },
212            success: function (res) {
213                if (isJSON(res)) {
214                    try {
215                        var parsedRes = (typeof res === 'object') ? res : JSON.parse(res);
216                        window.digits_last_login_response = parsedRes.data || parsedRes;
217                    } catch (e) {}
218                }
219                if (isJSON(res)) {
220
221                    if (!res.data.code) {
222                        res = res;
223                    } else {
224                        if (res.data.error_msg) {
225                            loader.hide();
226                            if (res.data.error_type) {
227                                showDigMessage(res.data.error_msg, res.data.error_type);
228                            } else {
229                                showDigErrorMessage(res.data.error_msg);
230                            }
231                            return;
232                        }
233
234                        if (res.redirect) {
235                            showDigLoginSuccessMessage();
236                            digits_redirect(res.redirect);
237                            return;
238                        }
239                        res = res.code;
240                    }
241                } else {
242                    res = res.trim();
243                }
244
245                loader.hide();
246                if (res == "1") {
247
248                    if (ihc_loginform == 10)
249                        document.location.href = "/";
250                    else {
251
252                        showDigLoginSuccessMessage();
253                        if (jQuery("#digits_redirect_page").length) {
254                            digits_redirect(jQuery("#digits_redirect_page").val());
255                        } else digits_redirect(dig_mdet.uri);
256                    }
257
258                } else if (res == -1) {
259                    showDigNoticeMessage(dig_mdet.pleasesignupbeforelogginin);
260                } else if (res == -9) {
261                    showDigErrorMessage(dig_mdet.invalidapicredentials);
262                } else {
263                    showDigErrorMessage(dig_mdet.invalidlogindetails);
264                }
265
266            }
267        });
268
269        return false;
270    }
271
272    function forgotihcCallback(response) {
273        showDigitsLoader(true);
274        if (response.status === "PARTIALLY_AUTHENTICATED") {
275
276            jQuery("#digits_impu_code").val(response.code);
277            jQuery("#digits_impu_csrf").val(response.csrf);
278
279            jQuery("#digits_password_ihc_cont").show().find("input").attr("required", "required");
280            jQuery("#digits_cpassword_ihc_cont").show().find("input").attr("required", "required");
281            forgotpassihc = 2;
282
283
284        }
285    }
286
287// login callback
288    function loginCallback(response) {
289        if (response.status === "PARTIALLY_AUTHENTICATED") {
290
291            showDigitsLoader(false);
292            loginuser(response);
293        } else if (response.status === "NOT_AUTHENTICATED") {
294            showDigitsLoader(true);
295        } else if (response.status === "BAD_PARAMS") {
296            showDigitsLoader(true);
297        }
298
299    }
300
301// phone form submission handler
302    function smsLogin() {
303
304    }
305
306    function phonenumber(data) {
307        var phoneno = /^\+?([0-9]{2})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{4})$/;
308        return !!(data.match(phoneno));
309    }
310
311    var reg_email = jQuery("#reg_email");
312    var mailsecond = jQuery(".dig_wc_mailsecond");
313    var mailSecondLabel = jQuery("#dig_secHolder");
314    var secondmailormobile = jQuery("#secondmailormobile");
315
316    var user_login = jQuery("#user_login");
317    if(jQuery('#your-profile').length > 0) {
318        user_login = null;
319    }
320
321    var otp_field;
322    var show_message = true;
323    var is_checkout = false;
324    var ew = 30;
325
326
327    jQuery('input[id="account_email"]').each(function (index) {
328        jQuery(this).parent().find('label').find('span').remove();
329    });
330
331
332    var dig_sortorder = dig_mdet.dig_sortorder;
333    var register = jQuery(".dig_wc_reg_form").closest(".register");
334    if (dig_sortorder.length) {
335        register.find("#reg_username").closest('.form-row').attr('id', 'dig_cs_username').addClass('dig-custom-field');
336        register.find("#reg_password").closest('.form-row').attr('id', 'dig_cs_password').addClass('dig-custom-field');
337
338        if (dig_mdet.mobile_accept > 0) {
339            register.find("#reg_email").parent().attr({
340                'id': 'dig_cs_mobilenumber',
341                'class': 'dig-custom-field woocommerce-FormRow--wide form-row form-row-wide'
342            });
343        } else {
344            register.find("#reg_email").parent().attr({
345                'id': 'dig_cs_email',
346                'class': 'dig-custom-field woocommerce-FormRow--wide form-row form-row-wide'
347            });
348        }
349
350        var sortorder = dig_sortorder.split(',');
351        var digits_register_inputs = register;
352
353
354        digits_register_inputs.each(function () {
355            jQuery(this).find('.dig-custom-field').sort(function (a, b) {
356                var ap = jQuery.inArray(a.id, sortorder);
357                var bp = jQuery.inArray(b.id, sortorder);
358                return (ap < bp) ? -1 : (ap > bp) ? 1 : 0;
359            }).prependTo(jQuery(this));
360        });
361
362
363    }
364
365
366    var c = jQuery(".ihc-form-create-edit");
367
368
369    if (c.length && dig_mdet.mobile_accept > 0) {
370        /*iump reg*/
371        var f = jQuery(".iump-register-form").find("#createuser");
372        var i_ccode = dig_mdet.uccode;
373
374
375        f.find("input[name='phone']").attr({
376            "data-dig-main": 1,
377            "reg": 2,
378            "data-skip-label": 1,
379            "id": "username",
380            "mob": 1,
381            "countryCode": i_ccode,
382            "nan": 1,
383            "f-mob": 1,
384        }).data('type', 2);
385
386
387        jQuery('<input type="hidden" id="dig_ihc_ea_code" name="code"/><input type="hidden" id="dig_ihc_ea_csrf" name="csrf"/><div id="dig_ihc_mobotp" class="iump-form-line-register iump-form-text" style="display:none;">' +
388            '<input value="" id="digits_otp_ihc" name="digit_otp" placeholder="' + dig_mdet.OTP + '" type="tel" style="padding-left:10px !important;">')
389            .insertBefore(f.find("input[type='submit']").closest('.iump-submit-form'));
390
391    }
392
393
394    var wcform = jQuery("#wc_dig_reg_form").closest("form");
395    var wc_checkout = jQuery(".woocommerce-form-login");
396    if (wcform.length) {
397        wcform.find('input[type="password"]').closest(".woocommerce-FormRow").remove();
398        wcform.find('input[name="login"]').remove();
399        wcform.find(".woocommerce-LostPassword").remove();
400        wcform.find('#rememberme').closest('label').remove();
401        wcform.find("#username").attr('mob', 1);
402
403        if (wc_checkout.length) {
404            wc_checkout.find('input[type="password"]').closest('.woocommerce-form-row').remove();
405            wc_checkout.find(".form-row-first").removeClass("form-row-first");
406            wc_checkout.find(".lost_password").remove();
407            wc_checkout.find('#rememberme').closest('label').remove();
408            wc_checkout.find('[name="login"]').remove();
409            wc_checkout.find("#username").attr('mob', 1);
410        }
411    }
412
413
414    var uc = jQuery("#dig_wc_check_page");
415    if (uc.length) {
416        uc = uc.parent();
417        var createAccounts = uc.find(".create-account");
418        createAccount = createAccounts.last();
419        if (createAccount.length) {
420            createAccount.find("#username").attr({'f-mob': 1, 'reg': 1, 'data-dig-mob': 1});
421            if (dig_mdet.mobile_accept == 2) {
422                createAccount.find("#username").attr({'data-dig-mob': 1, 'data-type': 2});
423            }
424            var wc_check_dig_fields = jQuery(".wc_check_dig_custfields");
425            wc_check_dig_fields.appendTo(createAccount);
426            if (createAccounts.length === 1) {
427                wc_check_dig_fields.addClass('create-account')
428            }
429        }
430    }
431    var dismissLoader = false;
432    var dig_billing_password = jQuery("#billing_account_password");
433
434
435//// Ultimate user
436    var um_register = jQuery(".um-register");
437    if (um_register.length) {
438        um_register.find('.um-field-mobile_number').find('input').attr({
439            'id': 'username',
440            'nan': '1',
441            'f-mob': 1
442        }).data('type', 2);
443    }
444    var um_login = jQuery(".um-login");
445    if (um_login.length) {
446        if (um_login.find('.um-field-mobile_number').length) {
447            um_login.find('.um-field-mobile_number').remove();
448            var um_username_field = um_login.find('.um-field-username');
449            um_username_field.find('label').attr('for', 'username').text(dig_mdet.emailormobile);
450            um_username_field.find('input').attr({'id': 'username', 'nan': 1});
451            um_login.find('.ump_digits_otp_container').show();
452        }
453    }
454
455    var um_forgot = jQuery(".woocommerce-ResetPassword");
456    if (um_forgot.length) {
457        var um_forgot_uname_field = um_forgot.find('.um-field-username_b');
458        if (um_forgot_uname_field.length) {
459            um_forgot_uname_field.find('label').attr('for', 'username').text(dig_mdet.emailormobile);
460            um_forgot_uname_field.find('input').attr({'id': 'username', 'nan': 1});
461            um_forgot.addClass('digits_um_forgotpass');
462        }
463    }
464
465    var um_forgot_pass = 0;
466    jQuery('.digits_um_forgotpass #um-submit-btn').on('click', function () {
467        update_time_button = jQuery(this);
468        cuForm = jQuery(this).closest('form');
469        var uname_field = cuForm.find('#username');
470        var ccode_field = cuForm.find('.dig_wc_logincountrycode');
471        var uname = uname_field.val();
472        var ccode = ccode_field.val();
473        if (isNumeric(uname)) {
474
475            if (um_forgot_pass == 3) {
476                var pass = jQuery("#dig_wc_password").val();
477                var cpass = jQuery("#dig_wc_cpassword").val();
478                if (pass != cpass) {
479                    showDigErrorMessage(dig_mdet.Passwordsdonotmatch);
480                    return false;
481                }
482                cuForm.attr({'action': '?login=true', 'method': 'post'});
483                uname_field.attr('name', 'user');
484                ccode_field.attr('name', 'dig_countrycodec');
485                cuForm.find('#digit_ac_otp').attr('name', 'dig_otp');
486                cuForm.unbind('submit').submit();
487                return true;
488            }
489
490
491            if (um_forgot_pass == 2) {
492                verifyOtp(ccode, uname, nounce.val(), cuForm.find('#digit_ac_otp').val(), 3);
493                return false;
494            }
495
496            um_forgot_pass = 1;
497            prv_forg_wc = jQuery(this).val();
498            jQuery(".dig_otp_um_reg").appendTo(cuForm.find('.um-field-text'));
499            verifyMobileNoLogin(ccode, uname, nounce.val(), 3);
500
501            return false;
502        }
503    });
504
505
506    var wc_login_form = jQuery(".woocommerce-form-login");
507    if (wc_login_form.length) {
508        if (dig_mdet.login_mobile_accept == 1 && dig_mdet.login_mail_accept == 0 && dig_mdet.login_uname_accept == 0) {
509            wc_login_form.find('#username').data('type', 2);
510        }
511    }
512
513    jQuery('input[id="username"],.digits_mobile_field,.digits_ext_phone_field').each(function (index) {
514        var $this = jQuery(this);
515        update_username_field($this);
516    });
517
518    jQuery("#wc-pos-actions").find("#add_customer_to_register").on('click', function () {
519        setTimeout(function () {
520            update_username_field(jQuery('#username_field').find('#username'));
521        }, 100);
522    });
523
524
525    function update_username_field($this) {
526        if (dig_mdet.login_mobile_accept == 0) {
527            var fmob = $this.attr('f-mob');
528
529            if (!fmob || fmob == 0) return;
530        }
531        if (dig_mdet.mobile_accept == 0) {
532            var reg = $this.attr('reg');
533
534            if (reg == 1) return;
535        }
536        var usernameid = $this;
537
538        var dig_main = usernameid.attr('data-dig-main');
539        var ccd;
540        if (!dig_main) {
541            if ($this.attr('data-dig-mob') == 1) {
542                if ($this.attr('countryCode')) {
543                    ccd = $this.attr('countryCode');
544                } else {
545                    ccd = dig_mdet.uccode;
546                }
547
548            } else if ($this.attr('mob') != 1) {
549
550                var lb = dig_mdet.emailormobile;
551
552
553                var reg = $this.attr('reg');
554
555                if (!reg || reg == 0) {
556                    reg = 0;
557                    if (dig_mdet.login_mobile_accept > 0 && dig_mdet.login_mail_accept > 0) {
558                        lb = dig_mdet.emailormobile;
559                    } else if (dig_mdet.login_mobile_accept > 0) {
560                        lb = dig_mdet.MobileNumber;
561                    } else if (dig_mdet.login_mail_accept > 0) {
562                        lb = dig_mdet.email;
563                    }
564                } else if (reg == 1) {
565                    if (dig_mdet.mobile_accept > 0 && dig_mdet.mail_accept > 0) {
566                        lb = dig_mdet.emailormobile;
567                    } else if (dig_mdet.mobile_accept > 0) {
568                        lb = dig_mdet.MobileNumber;
569                    } else if (dig_mdet.mail_accept > 0) {
570                        lb = dig_mdet.email;
571                    }
572                }
573                if (reg != 2) {
574                    usernameid.prev().html(lb + " <span class=required>*</span>");
575                    if (usernameid.attr('placeholder')) usernameid.attr('placeholder', lb);
576                }
577                ccd = dig_mdet.uccode;
578
579            } else {
580                usernameid.prev().html(dig_mdet.MobileNumber + " <span class=required>*</span>");
581                if (usernameid.attr('placeholder')) usernameid.attr('placeholder', dig_mdet.MobileNumber);
582                if ($this.attr('countryCode')) {
583                    ccd = $this.attr('countryCode');
584                } else {
585                    ccd = dig_mdet.uccode;
586                }
587
588
589            }
590        }
591
592        var dig_ext = "";
593        var dig_mainattr = "";
594
595        var dig_ccd_name = "digt_countrycode";
596
597        var dig_skip_label = $this.attr('data-skip-label');
598
599        if (dig_skip_label) {
600            ccd = dig_mdet.uccode;
601        } else if (dig_main) {
602            var tc = $this.attr('countryCode');
603
604
605            if (tc !== undefined) {
606                if (tc == -1) {
607                    ccd = "+";
608                } else {
609                    ccd = "+" + tc;
610                }
611            } else {
612                ccd = dig_mdet.uccode;
613            }
614            dig_ext = "dig_update_hidden ";
615            dig_mainattr = 'data-dig-main="' + usernameid.attr('data-dig-main') + '"';
616            dig_ccd_name = usernameid.attr('data-dig-main') + "_digt_countrycode";
617        }
618
619
620        usernameid.wrap('<div class="digcon"></div>').before('<div class="dig_wc_countrycodecontainer dig_wc_logincountrycodecontainer">' +
621            '<input type="text" autocomplete="tel-country-code" name="' + dig_ccd_name + '" class="' + dig_ext + 'input-text countrycode dig_wc_logincountrycode" ' +
622            'value="' + ccd + '" maxlength="6" size="3" placeholder="' + ccd + '" ' + dig_mainattr + '/></div>');
623
624        if (!usernameid.attr("nan")) usernameid.attr('name', "mobile_email");
625
626
627        usernameid.on("keyup change focusin", function (e) {
628            var data_type = jQuery(this).data('type');
629            var dclcc = jQuery(this).parent().find('.dig_wc_countrycodecontainer');
630            var dcllInput = dclcc.find('input');
631
632            var dig_main = jQuery(this).attr('data-dig-main');
633            if (dig_main) {
634                var ccd_dig = jQuery(this).closest('.digcon').find(".dig_update_hidden");
635
636                var con = filter_mobile(jQuery(this).val());
637                var ccdval = ccd_dig.val();
638                //ccdval = ccdval.replace("+", "");
639                if (con.length > 0 && ccdval.length > 0) {
640                    var field_value = ccdval + "" + con
641                    if (dig_main === 'billing_phone') {
642                        if (dig_mdet.add_countrycode_in_billing_phone == 0) {
643                            field_value = con
644                        }
645                    }
646                    jQuery('#' + dig_main).val(field_value).trigger('change');
647
648                } else jQuery('#' + dig_main).val("").trigger('change')
649
650            }
651            if (isNumeric(jQuery(this).val()) || jQuery(this).attr('only-mob') || data_type == 2) {
652                dclcc.css({"display": "inline-block"});
653
654
655                dcllInput.trigger('keyup');
656                if (jQuery(this).attr('data-show-btn')) {
657                    jQuery("." + jQuery(this).attr('data-show-btn')).show();
658                }
659            } else {
660                dclcc.hide();
661
662
663                if (jQuery(this).attr('removeStyle')) jQuery(this).removeAttr('style');
664                else jQuery(this).css({"padding-left": ""});
665
666                if (jQuery(this).attr('data-show-btn')) {
667                    if (dig_mdet.mobile_accept != 2) jQuery("." + jQuery(this).attr('data-show-btn')).hide();
668                }
669            }
670            digit_validateLogin(jQuery(this));
671
672        });
673
674
675        setTimeout(function () {
676            usernameid.trigger('keyup');
677        }, 10);
678    }
679
680
681    jQuery(".dig_update_hidden").on('keyup change focusin', function () {
682        var toUp = jQuery(this).attr("data-dig-main");
683        var mob = jQuery(this).closest('.digcon').find("#username").val();
684
685        mob = filter_mobile(mob);
686        var ccd = jQuery(this).val();
687        // ccd = ccd.replace("+", "");
688        /**/
689        if (mob.length > 0 && ccd.length > 0) {
690            var field_value = custom_mersa_phone_prefix(ccd, mob)
691            if (toUp === 'billing_phone') {
692                if (dig_mdet.add_countrycode_in_billing_phone == 0) {
693                    field_value = mob
694                }
695            }
696            jQuery('#' + toUp).val(field_value);
697        } else jQuery('#' + toUp).val("");
698
699    });
700
701
702    jQuery("#dokan-vendor-register").find("#reg_email").addClass('no-overwrite');
703    jQuery(".woocommerce-EditAccountForm").find("#reg_email").addClass('no-overwrite');
704
705    jQuery('input[id="reg_email"]').each(function (index) {
706        var reg_email = jQuery(this);
707
708        if (reg_email.hasClass('no-overwrite')) {
709            return;
710        }
711
712        var reg_input = reg_email.parent();
713
714        var labe;
715
716
717        var req = " <span class=required>*</span>";
718        if (dig_mdet.mail_accept == 1 && dig_mdet.mobile_accept == 1) {
719            labe = dig_mdet.emailormobile;
720        } else if (dig_mdet.mobile_accept > 0) {
721            labe = dig_mdet.MobileNumber;
722            reg_email.data('type', '2');
723            reg_email.attr({'autocomplete': 'tel-national', 'name': 'tel_national'});
724            if (dig_mdet.mobile_accept == 1) req = ' <span class=required>(' + dig_mdet.optional + ')</span>';
725        } else if (dig_mdet.mail_accept == 1) {
726            labe = dig_mdet.email;
727        } else {
728            return;
729        }
730
731
732        reg_input.children("label").html(labe + req);
733        if (reg_email.attr('placeholder')) {
734            reg_email.attr('placeholder', labe);
735        }
736
737
738        reg_email.wrap('<div class="digcon"></div>')
739            .before('<div class="dig_wc_countrycodecontainer dig_wc_registercountrycodecontainer"><input type="text" name="digfcountrycode" class="input-text countrycode dig_wc_registercountrycode" value="' + dig_mdet.uccode + '" maxlength="6" size="3" placeholder="' + dig_mdet.uccode + '" autocomplete="tel-country-code"/></div>');
740
741
742        reg_email.on("keyup change focusin", function (e) {
743            var data_type = jQuery(this).data('type');
744
745            if (data_type == 3) return;
746            var dclcc = reg_input.find('.dig_wc_countrycodecontainer');
747            var dcllInput = dclcc.find('input');
748            if (isNumeric(reg_email.val()) || data_type == 2) {
749                dclcc.css({"display": "inline-block"});
750                dcllInput.trigger('keyup');
751            } else {
752                dclcc.hide();
753                jQuery(this).css({"padding-left": "0.75em"});
754            }
755            updateMailSecondLabel(reg_email);
756        });
757
758
759        var parentForm = jQuery(this).closest('form');
760
761
762        reg_email.attr({'type': 'text'});
763
764        setTimeout(function () {
765            reg_email.trigger('keyup');
766        });
767
768    });
769
770
771    user_login.parent().children("label").html(dig_mdet.emailormobile + " <span class=required>*</span>");
772
773
774    jQuery('input[id="secondmailormobile"]').each(function (index) {
775        if (dig_mdet.mail_accept == 2 || dig_mdet.mobile_accept == 2) return;
776        sRegMail = jQuery(this);
777        sRegMail.addClass();
778        sRegMail.wrap('<div class="digcon"></div>').before('<div class="dig_wc_countrycodecontainer dig_wc_registersecondcountrycodecontainer"><input type="text" name="digsfcountrycode2" class="input-text countrycode dig_wc_registersecondcountrycode" value="' + dig_mdet.uccode + '" maxlength="6" size="3" placeholder="' + dig_mdet.uccode + '" autocomplete="tel-country-code"/></div>');
779
780
781        if (sRegMail.attr('placeholder')) sRegMail.attr('placeholder', dig_mdet.emailormobile);
782        sRegMail.on("keyup change focusin", function () {
783
784            var dclcc = jQuery(this).parent().find('.dig_wc_registersecondcountrycodecontainer');
785
786            var dcllInput = dclcc.find('input');
787
788            if (isNumeric(jQuery(this).val()) && !isNumeric(reg_email.val())) {
789                dclcc.css({"display": "inline-block"});
790                dcllInput.trigger('keyup');
791
792            } else {
793                dclcc.hide();
794                jQuery(this).css({"padding-left": "0.75em"});
795            }
796        });
797        setTimeout(function () {
798            sRegMail.trigger('keyup');
799        });
800    });
801
802
803    jQuery('.dig_wc_registersecondcountrycode').on("keyup change focusin", function (e) {
804        var dwccr = jQuery(this);
805        var code = dwccr.val();
806        var size = code.length;
807        var curRegMail = dwccr.parent().parent().find('input#secondmailormobile');
808        size++;
809        if (size < 2) size = 2;
810        dwccr.attr('size', size);
811
812        if (code.trim().length == 0) {
813            dwccr.val("+");
814        }
815        curRegMail.css({"padding-left": mobilePaddingLeft(dwccr.outerWidth(false) + ew / 2 + "px")}, 'fast', function () {
816        });
817
818    });
819
820
821    if (!user_login.attr('disabled')) {
822        user_login.wrap('<div class="digcon"></div>').before('<div class="dig_wc_countrycodecontainer forgotcountrycodecontainer"><input type="text" name="dig_countrycodec" class="input-text countrycode forgotcountrycode" value="' + dig_mdet.uccode + '" maxlength="6" size="3" placeholder="' + dig_mdet.uccode + '"/></div>');
823
824
825        setTimeout(function () {
826            user_login.trigger('keyup');
827        });
828    }
829
830    function digit_validateLogin(usernameid) {
831        var form = usernameid.closest('form');
832        if (isNumeric(usernameid.val())) {
833            var dclcc = usernameid.parent().find('.dig_wc_countrycodecontainer').find('input');
834            form.find("#loginuname").val(dclcc.val() + usernameid.val());
835        } else {
836
837            form.find("#loginuname").val(usernameid.val());
838        }
839    }
840
841
842    jQuery('.dig_wc_registercountrycode').on("keyup change focusin", function (e) {
843        var rccBox = jQuery(this);
844        var code = jQuery(this).val();
845        var size = code.length;
846        var curRegMail = rccBox.parent().parent().find('input#reg_email');
847        size++;
848        if (size < 2) size = 2;
849        rccBox.attr('size', size);
850
851        if (code.trim().length == 0) {
852            rccBox.val("+");
853        }
854        curRegMail.css({"padding-left": mobilePaddingLeft(rccBox.outerWidth(false) + ew / 2 + "px")}, 'fast', function () {
855        });
856
857        updateMailSecondLabel(curRegMail);
858    });
859
860
861    user_login.on("keyup change focusin", function (e) {
862
863        if (isNumeric(jQuery(this).val())) {
864            jQuery(".forgotcountrycodecontainer").css({"display": "inline-block"});
865            jQuery(".forgotcountrycode").trigger('keyup');
866        } else {
867            jQuery(".forgotcountrycodecontainer").hide();
868            jQuery(this).css({"padding-left": "0.75em"});
869        }
870    });
871
872    jQuery('.forgotcountrycode').on("keyup change focusin", function (e) {
873        var size = jQuery(this).val().length;
874        size++;
875        if (size < 2) size = 2;
876
877        jQuery(this).attr('size', size);
878        var code = jQuery(this).val();
879        if (code.trim().length == 0) {
880            jQuery(this).val("+");
881        }
882
883        user_login.css({"padding-left": mobilePaddingLeft(jQuery('.forgotcountrycode').outerWidth(true) + ew / 2 + "px")}, 'fast', function () {
884        });
885    });
886
887
888    var isSecondMailVisible = false;
889    var inftype = 0;
890
891    function updateMailSecondLabel(reg_email) {
892
893        var con = reg_email.val();
894
895        var cPar = reg_email.closest('form');
896
897        var digSecondCountryCode = cPar.find('.dig_wc_registersecondcountrycodecontainer');
898        var regContainer = reg_email.parent();
899
900
901        var secondmailormobile = cPar.find('.secondmailormobile');
902
903
904        var mailSecondLabel = cPar.find("#dig_secHolder");
905
906        if ((isNumeric(con) && inftype != 1) || dig_mdet.mail_accept == 2) {
907            inftype = 1;
908            mailSecondLabel.html(dig_mdet.email);
909
910            digSecondCountryCode.hide();
911
912            secondmailormobile.css({"padding-left": "0.75em"});
913
914
915        } else if (!isNumeric(con) && inftype != 2 && dig_mdet.mobile_accept != 2) {
916            inftype = 2;
917            mailSecondLabel.html(dig_mdet.MobileNumber);
918
919
920            digSecondCountryCode.css({"display": "inline-block"});
921
922            secondmailormobile.css({"padding-left": mobilePaddingLeft(digSecondCountryCode.find(".dig_wc_registersecondcountrycode").outerWidth(false) + ew / 2 + "px")});
923        }
924
925        if (dig_mdet.mail_accept != 2 && dig_mdet.mobile_accept != 2) {
926
927            if (con == "" || con.length == 0) {
928                cPar.find(".dig_wc_mailsecond").stop().slideUp();
929                isSecondMailVisible = false;
930                return;
931            }
932
933            if (!isSecondMailVisible) {
934                cPar.find(".dig_wc_mailsecond").stop().slideDown().show();
935                isSecondMailVisible = true;
936            } else return;
937        }
938    }
939
940
941    jQuery(document).on("keyup", ".dig_wc_logincountrycode", function (e) {
942
943
944        var rliBox = jQuery(this);
945        var code = rliBox.val();
946        var size = code.length;
947        var container = rliBox.parent().parent();
948
949        var curLogMail = container.find('#username');
950        if (!curLogMail.length || !curLogMail) {
951            curLogMail = container.find('.digits_mobile_field');
952        }
953
954        size++;
955        if (size < 2) size = 2;
956        rliBox.attr('size', size);
957        if (code.trim().length == 0) {
958            rliBox.val("+");
959        }
960        curLogMail.attr("style", "padding-left:" + mobilePaddingLeft((rliBox.outerWidth(false) + ew / 2) + "px !important;"));
961
962        digit_validateLogin(curLogMail);
963    });
964
965
966    var max = 5;
967
968
969    jQuery(".login .inline").each(function () {
970        var form = jQuery(this).closest('form');
971        form.find('.woocommerce-LostPassword').prepend(jQuery(this));
972
973    });
974
975
976    var registerstatus = 0;
977
978
979    var regDone = 0;
980    register.find("input").on('focusout', function () {
981        if (regDone == 1) return;
982        register.find("input[type='submit']").each(function () {
983            jQuery(this).removeAttr("disabled").removeClass("disabled");
984        });
985        regDone = 0;
986    });
987
988
989    var forgotDone = 0;
990
991    var forgotOutDone = 0;
992
993    jQuery(".woocommerce-ResetPassword input").on('focusin', function () {
994        if (forgotDone == 1) return;
995        jQuery(".woocommerce-ResetPassword input[type='submit'],.woocommerce-ResetPassword button[type='submit']").each(function () {
996            jQuery(this).removeAttr('disabled').removeClass("disabled");
997        });
998        forgotDone = 1;
999    }).on('focusout', function () {
1000        if (forgotOutDone == 1) return;
1001        jQuery(".woocommerce-ResetPassword input[type='submit'],.woocommerce-ResetPassword button[type='submit']").each(function () {
1002            jQuery(this).removeAttr('disabled').removeClass("disabled");
1003        });
1004        forgotOutDone = 1;
1005    });
1006
1007    var loginDone = 0;
1008    jQuery("form.login input").on('focusout', function () {
1009        if (loginDone == 1) {
1010            jQuery("form.login input[type='submit'],form.login button[type='submit']").each(function () {
1011                jQuery(this).removeAttr("disabled").removeClass("disabled");
1012            });
1013            loginDone = 0;
1014        }
1015    });
1016
1017
1018    var curRegForm;
1019    var passwcdo = 0;
1020
1021    if (dig_mdet.pass_accept != 2 && dig_mdet.mobile_accept > 0) {
1022        register.find('input[id="reg_password"]').each(function () {
1023            jQuery(this).closest('.woocommerce-form-row').hide();
1024        });
1025    }
1026
1027
1028    register.find(".woocommerce-Button, button[name='register']").each(function () {
1029        if (jQuery(this).attr('name') == 'register') {
1030            if (!jQuery(this).hasClass("otp_reg_dig_wc")) {
1031                if (jQuery(".otp_reg_dig_wc").length)
1032                    jQuery(this).val(dig_mdet.RegisterWithPassword).text(dig_mdet.RegisterWithPassword).addClass("wc_reg_pass_btn");
1033            }
1034        }
1035    });
1036
1037
1038    register.off();
1039    jQuery("#reg_password").on('change', function () {
1040        jQuery(this).closest('form').find("[type='submit']").removeAttr('disabled');
1041    });
1042    register.find(".woocommerce-Button, button[name='register']").on('click', function (e) {
1043
1044        if (registerstatus == 1) return true;
1045        curRegForm = jQuery(this).closest('form');
1046
1047        var mail = jQuery.trim(curRegForm.find("#reg_email").val());
1048        var secmail = jQuery.trim(curRegForm.find("#secondmailormobile").val());
1049
1050        if (jQuery(this).hasClass('otp_reg_dig_whatsapp')) {
1051            useWhatsApp = 1;
1052            lastmobileNo = -1;
1053            lastDtype = 2;
1054        }
1055
1056        jQuery(".dig_otp_submit_button").removeClass('dig_otp_submit_button');
1057        jQuery(this).addClass('dig_otp_submit_button');
1058
1059        if (jQuery(this).hasClass("otp_reg_dig_wc")) {
1060            if (!isNumeric(mail) && !isNumeric(secmail)) {
1061                showDigNoticeMessage(dig_mdet.Thisfeaturesonlyworkswithmobilenumber);
1062                return false;
1063            }
1064
1065            curRegForm.find(".wc_reg_pass_btn").hide();
1066            curRegForm.find("#_wpnonce").parent().find("input[type='submit'],button[type='submit']").remove();
1067        } else if (passwcdo == 0) {
1068
1069            if (!curRegForm.find("#reg_billing_otp").is(":visible")) {
1070
1071
1072                passwcdo = 1;
1073                var a = curRegForm.find('#reg_password').closest('.woocommerce-form-row');
1074                if (a.css('display') == 'none') {
1075                    curRegForm.find(".otp_reg_dig_wc").hide();
1076                    a.show();
1077                    return false;
1078                }
1079            }
1080        }
1081    });
1082
1083    function digits_wc_recaptcha_error(res) {
1084        loader.hide();
1085    }
1086
1087    function digits_wc_recaptcha_callback(token) {
1088        curRegForm.find('.invi-recaptcha').last().attr('data-solved', 1);
1089        curRegForm.submit();
1090    }
1091
1092    register.on('submit', function (e) {
1093
1094        hideDigMessage();
1095
1096        if (registerstatus == 1) return true;
1097
1098        curRegForm = jQuery(this);
1099        update_time_button = register.find(".woocommerce-Button");
1100
1101
1102        var mail = jQuery.trim(curRegForm.find("#reg_email").val());
1103        var secmail = jQuery.trim(curRegForm.find("#secondmailormobile").val());
1104
1105
1106        var passf = curRegForm.find("#reg_password");
1107
1108
1109        if (passf.length > 0) {
1110            var tpass = passf.val();
1111            if (dig_mdet.strong_pass == 1) {
1112                if (dig_mdet.pass_accept == 2 || tpass.length > 0) {
1113                    try {
1114                        var strength = wp.passwordStrength.meter(tpass, ['black', 'listed', 'word'], tpass);
1115                        if (strength != null && strength < 3) {
1116                            showDigNoticeMessage(dig_mdet.useStrongPasswordString);
1117                            return false;
1118                        }
1119                    } catch (e) {
1120
1121                    }
1122                }
1123            }
1124        }
1125
1126
1127        var custom_validation = validateCustomFields(curRegForm);
1128
1129        if (!custom_validation) {
1130            return false;
1131        }
1132
1133        var recaptcha = curRegForm.find('.invi-recaptcha').last();
1134        if (recaptcha.length > 0 && !recaptcha.data('solved')) {
1135            var widget_id = grecaptcha.render(recaptcha.attr('id'),
1136                {
1137                    'callback': digits_wc_recaptcha_callback,
1138                    'error-callback': digits_wc_recaptcha_error,
1139                });
1140            grecaptcha.execute(widget_id);
1141            return false;
1142        }
1143
1144        if (dig_mdet.mobile_accept == 0 && dig_mdet.mail_accept == 0) {
1145            return true;
1146        }
1147
1148        if (passf.length > 0) {
1149            var pass = passf.val();
1150            if (!jQuery(this).hasClass("otp_reg_dig_wc") && passf.is(":visible")) {
1151
1152                if (pass.length == 0) {
1153                    showDigErrorMessage(dig_mdet.invalidpassword);
1154                    return false;
1155                }
1156            }
1157            if (pass.length == 0 && validateEmail(mail) && validateEmail(secmail) && !isNumeric(mail) && !isNumeric(secmail)) {
1158                showDigNoticeMessage(dig_mdet.eitherentermoborusepass);
1159                return false;
1160            }
1161        }
1162
1163        if (validateEmail(mail) && validateEmail(secmail) && secmail.length > 0) {
1164            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
1165            return false;
1166        }
1167        if (isNumeric(mail) && isNumeric(secmail) && secmail.length > 0) {
1168            showDigErrorMessage(dig_mdet.InvalidEmail);
1169            return false;
1170        }
1171
1172
1173        var dig_reg_mail = curRegForm.find(".dig_reg_mail");
1174        if (validateEmail(mail)) {
1175            dig_reg_mail.val(mail);
1176        } else if (validateEmail(secmail)) {
1177            dig_reg_mail.val(secmail);
1178        }
1179
1180
1181        if (dig_mdet.mail_accept == 2 && (!validateEmail(dig_reg_mail.val()))) {
1182            showDigErrorMessage(dig_mdet.InvalidEmail);
1183            return false;
1184        }
1185
1186
1187        if (dig_mdet.mobile_accept == 2 && !isNumeric(mail) && !isNumeric(secmail)) {
1188            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
1189            return false;
1190        }
1191
1192
1193        var otp = jQuery("#reg_billing_otp");
1194
1195        if (regverify == 1) {
1196            if (isNumeric(mail)) {
1197                verifyOtp(curRegForm.find(".dig_wc_registercountrycode").val(), mail, nounce.val(), otp.val(), 2);
1198                return false;
1199            } else if (isNumeric(secmail)) {
1200                verifyOtp(curRegForm.find(".dig_wc_registersecondcountrycode").val(), secmail, nounce.val(), otp.val(), 2);
1201                return false;
1202            }
1203            return false;
1204        }
1205
1206        if (curRegForm.find("#reg_username").length) {
1207            username_reg_field = curRegForm.find("#reg_username").val();
1208        }
1209        if (curRegForm.find(".dig-custom-field-type-captcha").length) {
1210            captcha_reg_field = curRegForm.find(".dig-custom-field-type-captcha").find("input[type='text']").val();
1211            captcha_ses_reg_field = curRegForm.find(".dig-custom-field-type-captcha").find(".dig_captcha_ses").val();
1212        }
1213        akCallback = 'registerWooCallBack';
1214
1215        if (isNumeric(mail)) {
1216            email_reg_field = secmail;
1217            verifyMobileNoLogin(curRegForm.find(".dig_wc_registercountrycode").val(), mail, nounce.val(), 2);
1218            email_reg_field = mail;
1219            return false;
1220        } else if (isNumeric(secmail)) {
1221            verifyMobileNoLogin(curRegForm.find(".dig_wc_registersecondcountrycode").val(), secmail, nounce.val(), 2);
1222            return false;
1223        }
1224
1225
1226    });
1227
1228
1229    function registerWooCallBack(response) {
1230        showDigitsLoader(true);
1231        if (response.status === "PARTIALLY_AUTHENTICATED") {
1232            registerstatus = 1;
1233
1234            var code = response.code;
1235            var csrf = response.state;
1236            curRegForm.find(".register_code").val(code);
1237            curRegForm.find(".register_csrf").val(csrf);
1238            curRegForm.find('[type="submit"]').click();
1239
1240        }
1241    }
1242
1243
1244    function validateEmail(email) {
1245        if ((email.search('@') >= 0) && (email.search(/\./) >= 0))
1246            if (email.search('@') < email.split('@')[1].search(/\./) + email.search('@')) return true;
1247            else return false;
1248        else return false;
1249    }
1250
1251
1252    var lastcountrycode, lastmobileNo, lastDtype;
1253
1254    var username_reg_field = '';
1255    var email_reg_field = '';
1256    var captcha_reg_field = '';
1257    var captcha_ses_reg_field = '';
1258    var isFirebase = 0;
1259
1260    function verifyMobileNoLogin(countrycode, mobileNo, csrf, dtype) {
1261
1262        otp_field = null;
1263        is_checkout = false;
1264        show_message = true;
1265        if (lastcountrycode == countrycode && lastmobileNo == mobileNo && lastDtype == dtype) {
1266            loader.hide();
1267            return;
1268        }
1269        dismissLoader = false;
1270
1271
1272        hideDigMessage();
1273
1274        loader.show();
1275
1276        if (lastDtype != dtype) {
1277            useWhatsApp = 0;
1278        }
1279
1280        if (update_time_button && update_time_button.hasClass('dig_wc_mobileWhatsApp')) {
1281            useWhatsApp = 1;
1282        }
1283
1284
1285        lastcountrycode = countrycode;
1286        lastmobileNo = mobileNo;
1287        lastDtype = dtype;
1288        jQuery.ajax({
1289            type: 'post',
1290            url: dig_mdet.ajax_url,
1291            data: {
1292                action: 'digits_check_mob',
1293                countrycode: countrycode,
1294                mobileNo: mobileNo,
1295                csrf: dig_mdet.nonce,
1296                login: dtype,
1297                username: username_reg_field,
1298                email: email_reg_field,
1299                captcha: captcha_reg_field,
1300                captcha_ses: captcha_ses_reg_field,
1301                json: 1,
1302                whatsapp: useWhatsApp
1303            },
1304            success: function (res) {
1305                username_reg_field = '';
1306                email_reg_field = '';
1307
1308                captcha_reg_field = '';
1309                captcha_ses_reg_field = '';
1310
1311                lastDtype = 0;
1312                lastmobileNo = 0;
1313
1314                loader.hide();
1315
1316                var ak = -1;
1317
1318                if (isJSON(res)) {
1319                    if (res.success === false) {
1320                        if (res.data.notice) {
1321                            showDigNoticeMessage(res.data.message);
1322                        } else {
1323                            showDigErrorMessage(res.data.message);
1324                        }
1325                        return;
1326                    }
1327
1328                    ak = res.accountkit;
1329                    isFirebase = res.firebase;
1330                    res = res.code;
1331                } else {
1332
1333                    res = res.trim();
1334                }
1335
1336
1337                if (res == -99) {
1338                    showDigErrorMessage(dig_mdet.invalidcountrycode);
1339                    return;
1340                }
1341                if (res == -11) {
1342                    if (dtype == 1) {
1343                        showDigNoticeMessage(dig_mdet.pleasesignupbeforelogginin);
1344                        return;
1345                    } else if (dtype == 3) {
1346                        showDigErrorMessage(dig_mdet.Mobilenumbernotfound);
1347                        return;
1348                    }
1349                } else if (res == 0) {
1350                    showDigErrorMessage(dig_mdet.error);
1351                    return;
1352                }
1353                if ((res == -1 && dtype == 2) || (res == -1 && dtype == 11)) {
1354                    showDigErrorMessage(dig_mdet.MobileNumberalreadyinuse);
1355                    return;
1356                }
1357
1358                mobileNo = mobileNo.replace(/^0+/, '');
1359                countrycode = countrycode.replace(/^0+/, '');
1360
1361
1362                if (ak == 1) {
1363                    processAccountkitLogin(countrycode, mobileNo);
1364                } else if (isFirebase == 1) {
1365                    dismissLoader = true;
1366                    loader.show();
1367
1368                    var phone = countrycode + mobileNo;
1369
1370                    if (countrycode == '+242' || countrycode == '+225') {
1371                        phone = countrycode + '0' + mobileNo;
1372                    } else {
1373                        phone = countrycode + mobileNo;
1374                    }
1375
1376                    var appVerifier = window.recaptchaVerifier;
1377                    firebase.auth().signInWithPhoneNumber(phone, appVerifier)
1378                        .then(function (confirmationResult) {
1379
1380                            loader.hide();
1381                            window.confirmationResult = confirmationResult;
1382
1383                            verifyMobNo_success(res, countrycode, mobileNo, csrf, dtype);
1384                        }).catch(function (error) {
1385
1386                        if (error.message === 'TOO_LONG' || error.message === 'TOO_SHORT') {
1387                            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
1388                        } else {
1389                            showDigErrorMessage(error.message);
1390                        }
1391                        loader.hide();
1392                    });
1393                } else {
1394                    verifyMobNo_success(res, countrycode, mobileNo, csrf, dtype);
1395                }
1396            }
1397        });
1398    }
1399
1400    function processAccountkitLogin(countrycode, phoneNumber) {
1401        hideDigitsLoader();
1402
1403    }
1404
1405
1406    loader.on('click', function () {
1407        if (dismissLoader) loader.hide();
1408    });
1409
1410
1411    function verifyMobNo_success(res, countrycode, mobileNo, csrf, dtype) {
1412        dismissLoader = false;
1413
1414        if (billing_page == 1) {
1415            digits_show_checkout_otp_modal(countrycode, mobileNo, csrf, dtype);
1416        } else if (dtype == 1) {
1417            if (res == 1) {
1418
1419                if (ihc_loginform == 1) {
1420
1421                    ihc_loginform = 0;
1422
1423                    updateTime(jQuery(".dig_impu_login_resend").attr({
1424                        "countrycode": countrycode,
1425                        "mob": mobileNo, "csrf": csrf, "dtype": dtype
1426                    }));
1427
1428
1429                    var otpin = jQuery("#impu-dig-otp");
1430                    otpin.show().find("input").attr("required", "required").trigger('focus');
1431                    verifyimpuotp = 1;
1432
1433                } else if (subitumotp == 1) {
1434
1435                    um_login.find(".digor").hide().remove();
1436                    um_login.find('.um-row').slideUp();
1437                    um_login.find('.um-col-alt').slideUp().remove();
1438                    um_login.find('.um-col-alt-b').hide().remove();
1439                    jQuery(".dig_otp_um_login").fadeIn().find("input").attr("required", "required").trigger('focus');
1440
1441
1442                    subitumotp = 2;
1443
1444                    tokenCon = um_login.find('form');
1445                    updateTime(jQuery(".dig_um_login_resend").attr({
1446                        "countrycode": countrycode,
1447                        "mob": mobileNo, "csrf": csrf, "dtype": dtype
1448                    }));
1449
1450
1451                } else {
1452
1453
1454                    updateTime(jQuery(".dig_wc_login_resend").attr({
1455                        "countrycode": countrycode,
1456                        "mob": mobileNo, "csrf": csrf, "dtype": dtype
1457                    }));
1458
1459                    hideloginpageitems();
1460                    logverify = 1;
1461
1462                    cuForm.find('.dig_wc_mobileLogin').not('.dig_otp_submit_button').hide();
1463
1464                    var otpin = cuForm.find("#dig_wc_log_otp_container");
1465                    otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1466                    jQuery("#username").closest("p").hide();
1467                }
1468
1469            }
1470        } else if (dtype == 2) {
1471
1472            if (dig_bp_btn == 1) {
1473
1474                updateTime(jQuery(".dig_wcbil_bill_resend").attr({
1475                    "countrycode": countrycode,
1476                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1477                }));
1478
1479                var otpin = jQuery("#dig_bp_reg_otp");
1480                otpin.show().find("input").attr("required", "required").trigger('focus');
1481                verifybpotp = 1;
1482                dig_bp_btn = 0;
1483
1484            } else if (subitumotp == 1) {
1485
1486
1487                var otpin = jQuery(".dig_otp_um_reg");
1488                tokenCon = um_register.closest('form');
1489                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1490                subitumotp = 2;
1491
1492
1493                updateTime(jQuery(".dig_um_regis_resend").attr({
1494                    "countrycode": countrycode,
1495                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1496                }));
1497
1498
1499            } else {
1500
1501                updateTime(jQuery(".dig_wc_register_resend").attr({
1502                    "countrycode": countrycode,
1503                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1504                }));
1505
1506
1507                curRegForm.find(".form-row").find("input[type='password']").each(function () {
1508                    jQuery(this).closest(".form-row").slideUp();
1509
1510                });
1511                curRegForm.find('.otp_reg_dig_wc').not('.dig_otp_submit_button').hide();
1512
1513                var otpin = curRegForm.find("#reg_billing_otp_container");
1514                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1515
1516                regverify = 1;
1517            }
1518
1519        } else if (dtype == 3) {
1520
1521
1522            if (forgotpassihc == 1) {
1523
1524
1525                updateTime(jQuery(".dig_impu_forg_resend").attr({
1526                    "countrycode": countrycode,
1527                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1528                }));
1529                var otpin = jQuery("#impu-dig-otp");
1530                otpin.show().find("input").attr("required", "required").trigger('focus');
1531                forgotpassMobVerifiedihc = 1;
1532                forgotpassihc = 0;
1533            } else if (um_forgot_pass == 1) {
1534                updateTime(jQuery(".dig_um_regis_resend").attr({
1535                    "countrycode": countrycode,
1536                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1537                }));
1538                jQuery(".dig_otp_um_reg").show();
1539                um_forgot_pass = 2;
1540            } else {
1541                updateTime(jQuery(".dig_wc_forgot_resend").attr({
1542                    "countrycode": countrycode,
1543                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1544                }));
1545
1546
1547                forgverify = 1;
1548                user_login.attr('name', 'forgotmail');
1549                var otpin = jQuery("#digit_forgot_otp_container");
1550                otpin.show().find("input").attr("required", "required").trigger('focus');
1551            }
1552        } else if (dtype == 11) {
1553            if (wpuseredit == 1) {
1554
1555                var otpin = curRegForm.find(".digits-edit-phone_otp-container");
1556                tokenCon = curRegForm;
1557                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1558                editverify = 1;
1559
1560            } else if (bpuseredit == 1) {
1561                var otpin = jQuery("#bp_otp_dig_ea");
1562                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1563                jQuery("#dig_bp_ac_ea_resend").show();
1564                updateTime(jQuery(".dig_bp_ac_ea_resend").attr({
1565                    "countrycode": countrycode,
1566                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1567                }));
1568                bpeditverify = 1;
1569            } else if (ihcedform == 1) {
1570                var otpin = jQuery("#dig_ihc_mobotp");
1571                tokenCon = otpin.closest('form');
1572                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1573                ihcedform = 2;
1574            } else {
1575
1576                updateTime(jQuery(".dig_wc_acc_edit_resend").attr({
1577                    "countrycode": countrycode,
1578                    "mob": mobileNo, "csrf": csrf, "dtype": dtype
1579                }));
1580                var otpin = jQuery("#digit_ac_otp_container");
1581                otpin.slideDown().find("input").attr("required", "required").trigger('focus');
1582                editverify = 1;
1583            }
1584        }
1585
1586        digits_WaitForSms();
1587
1588    }
1589
1590    var regverify = 0;
1591    var logverify = 0;
1592    var forgverify = 0;
1593    var editverify = 0;
1594
1595
1596    function hideloginpageitems() {
1597
1598        var wp_login = jQuery(".wp_login");
1599        if (cuForm.hasClass('wp_login')) {
1600            cuForm.find(".digor").remove();
1601            cuForm.find("input[type='password']").parent().remove();
1602            wp_login.children().each(function () {
1603                if (!jQuery(this).hasClass('dig_otp_block') && jQuery(this).find(".digcon").length === 0 &&
1604                    jQuery(this).find(".dig_bb_wp_otp_field").length === 0) {
1605                    jQuery(this).hide();
1606                }
1607            });
1608            cuForm.find(".bbp-submit-wrapper").hide();
1609            cuForm.append(cuForm.find(".dig_otp_block"));
1610            cuForm.find(".dig_otp_block").addClass('dig_otp_blk');
1611            cuForm.find(".bbp-remember-me").hide();
1612            return;
1613        }
1614
1615        cuForm.find(".digor").remove();
1616        cuForm.find(".lost_password").hide();
1617        cuForm.find("input[type='submit'],button[type='submit']").hide();
1618
1619        cuForm.find(".dig-custom-field-type-captcha").hide();
1620
1621
1622        if (wc_checkout.length) {
1623            wc_checkout.find('input[type="password"]').parent().hide();
1624            wc_checkout.find(".form-row-first").removeClass("form-row-first");
1625            wc_checkout.find('#rememberme').closest('label').hide();
1626            wc_checkout.find('[name="login"]').remove();
1627        }
1628        jQuery('#cfw_login_modal_form .cfw-login-modal-navigation').hide();
1629
1630
1631        cuForm.find(".form-row").find("input[type='password']").each(function (index) {
1632            var mrow = jQuery(this).closest(".form-row");
1633            if (index != 1 && mrow.attr('otp') != 1)
1634                mrow.remove();
1635            else if (index == 1) {
1636                mrow.find("label").text(dig_mdet.MobileNumber + " *");
1637            }
1638
1639        });
1640    }
1641
1642
1643    dig_login_wp_elem.on('submit', function () {
1644        if (logverify == 1) {
1645            jQuery(".dig_wc_mobileLogin").first().trigger('click');
1646            return false;
1647        }
1648
1649    });
1650    var cuForm;
1651
1652    var nounce = jQuery(".dig_nounce");
1653    jQuery(document).on('click', '.dig_wc_mobileLogin', function () {
1654
1655        update_time_button = jQuery(this);
1656
1657        cuForm = jQuery(this).closest('form');
1658        var countryCode = cuForm.find(".countrycode").val();
1659
1660        if (cuForm.find("#username").length > 0) {
1661            var phoneNumber = cuForm.find("#username").val();
1662        } else if (cuForm.find("#user_login").length > 0) {
1663            var phoneNumber = cuForm.find("#user_login").val();
1664        } else {
1665            var phoneNumber = cuForm.find(".digits_mobile_field").val();
1666        }
1667        jQuery(".dig_otp_submit_button").removeClass('dig_otp_submit_button');
1668        jQuery(this).addClass('dig_otp_submit_button');
1669
1670
1671        if (phoneNumber == "" || countryCode == "") {
1672            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
1673            return false;
1674        }
1675
1676        var otp = jQuery("#dig_wc_log_otp");
1677
1678        if (dig_mdet.captcha_accept == 1) {
1679
1680
1681            captcha_reg_field = cuForm.find("input[name='digits_reg_logincaptcha']").val();
1682            if (captcha_reg_field != null) {
1683                captcha_ses_reg_field = cuForm.find(".dig-custom-field-type-captcha").find(".dig_captcha_ses").val();
1684                if (captcha_reg_field.length == 0) {
1685                    showDigErrorMessage("Please enter a valid captcha!");
1686                    return false;
1687                }
1688            }
1689        }
1690
1691
1692        if (!isNumeric(countryCode) || !isNumeric(phoneNumber)) {
1693            var pass = cuForm.find("input[type='password']").val();
1694
1695            if (pass != null) {
1696                showDigErrorMessage(dig_mdet.InvalidMobileNumber);
1697            }
1698            return false;
1699        }
1700
1701        if (logverify == 1) {
1702            verifyOtp(countryCode, phoneNumber, nounce.val(), cuForm.find("#dig_wc_log_otp").val(), 1);
1703            return false;
1704        }
1705
1706
1707        if (isNumeric(phoneNumber)) {
1708            akCallback = 'loginCallback';
1709
1710            verifyMobileNoLogin(countryCode, phoneNumber, nounce.val(), 1);
1711        }
1712
1713        return false;
1714    });
1715
1716
1717    var updateProfileStatus = 0;
1718
1719    function updateProfileCallback(response) {
1720        showDigitsLoader(true);
1721        if (response.status === "PARTIALLY_AUTHENTICATED") {
1722            var code = response.code;
1723            var csrf = response.state;
1724
1725            updateProfileStatus = 1;
1726
1727            curRegForm.find("input[name='code']").val(code);
1728            curRegForm.find("input[name='csrf']").val(csrf);
1729            curRegForm.find("[type='submit']").click();
1730        } else if (response.status === "NOT_AUTHENTICATED") {
1731            // handle authentication failure
1732        } else if (response.status === "BAD_PARAMS") {
1733            //Need to update this
1734        }
1735
1736    }
1737
1738    function updateCheckoutDetails(response) {
1739        showDigitsLoader(true);
1740        if (response.status === "PARTIALLY_AUTHENTICATED") {
1741            var code = response.code;
1742            var csrf = response.state;
1743
1744
1745            jQuery(".dig_billing_otp_signup").hide();
1746
1747            jQuery("#dig_wc_bill_code").val(code);
1748            jQuery("#dig_wc_bill_csrf").val(csrf);
1749
1750
1751        }
1752    }
1753
1754
1755    var prv_forg_wc = -1;
1756    jQuery("form.lost_reset_password input[type='submit'],form.lost_reset_password button[type='submit']").on('click', function () {
1757        update_time_button = jQuery(this);
1758        if (prv_forg_wc == -1) {
1759            if (jQuery(this).is(':input')) {
1760                prv_forg_wc = jQuery(this).val();
1761            } else {
1762                prv_forg_wc = jQuery(this).text();
1763            }
1764        }
1765
1766        if (forgotPassChange == 1) {
1767            var pass = jQuery("#dig_wc_password").val();
1768            var cpass = jQuery("#dig_wc_cpassword").val();
1769            if (pass != cpass) {
1770                showDigErrorMessage(dig_mdet.Passwordsdonotmatch);
1771                return false;
1772            }
1773            return true;
1774        }
1775        var mom = user_login.val();
1776        var countryCode = jQuery("form.lost_reset_password .forgotcountrycode").val();
1777        var otp = jQuery("#digit_forgot_otp");
1778
1779        if (forgverify == 1) {
1780            verifyOtp(countryCode, mom, nounce.val(), otp.val(), 3);
1781            return false;
1782        }
1783
1784        if (isNumeric(mom)) {
1785
1786            jQuery("form.lost_reset_password").attr('action', window.location.pathname + "?login=true");
1787
1788
1789            akCallback = 'forgotPasswordCallBack';
1790            verifyMobileNoLogin(countryCode, mom, nounce.val(), 3);
1791
1792            return false;
1793        } else {
1794            jQuery("form.lost_reset_password").removeAttr('action');
1795        }
1796        return true;
1797    });
1798
1799    function forgotPasswordCallBack(response) {
1800        showDigitsLoader(true);
1801        if (response.status === "PARTIALLY_AUTHENTICATED") {
1802            var code = response.code;
1803            var csrf = response.state;
1804            forgotPassChange = 1;
1805            user_login.parent().parent().hide();
1806            user_login.attr('name', 'forgotmail');
1807            jQuery("#digits_wc_code").val(code);
1808            jQuery("#digits_wc_csrf").val(csrf);
1809            jQuery("form.lost_reset_password .changePassword").show();
1810        } else if (response.status === "NOT_AUTHENTICATED") {
1811            // handle authentication failure
1812        } else if (response.status === "BAD_PARAMS") {
1813            //Need to update this
1814        }
1815
1816    }
1817
1818
1819    var lastotpcountrycode, lastotpmobileNo, lastotpDtype;
1820
1821    function verifyOtp(countryCode, phoneNumber, csrf, otp, dtype) {
1822        otp = convert_number.toNormal(otp);/**/
1823        dismissLoader = false;
1824        hideDigMessage();
1825        if (show_message) {
1826            loader.show();
1827        }
1828
1829        if (isFirebase == 1) verify_firebase_otp(countryCode, phoneNumber, csrf, otp, dtype);
1830        else verify_cust_otp(countryCode, phoneNumber, csrf, otp, dtype, -1);
1831
1832
1833    }
1834
1835    function verify_firebase_otp(countryCode, phoneNumber, csrf, otp, dtype) {
1836        phoneNumber = phoneNumber.replace(/^0+/, '');
1837        countryCode = countryCode.replace(/^0+/, '');
1838
1839        if (otp == null || otp.length == 0) {
1840            loader.hide();
1841            showDigErrorMessage(dig_mdet.InvalidOTP);
1842            return;
1843        }
1844        window.confirmationResult.confirm(otp)
1845            .then(function (result) {
1846
1847                firebase.auth().currentUser.getIdToken(true).then(function (idToken) {
1848                    window.verifyingCode = false;
1849                    window.confirmationResult = null;
1850                    jQuery("#dig_ftok_fbase").remove();
1851                    tokenCon.append("<input type='hidden' name='dig_ftoken' value='" + idToken + "' id='dig_ftok_fbase' />");
1852                    verify_cust_otp(countryCode, phoneNumber, csrf, otp, dtype, idToken);
1853                }).catch(function (error) {
1854                    loader.hide();
1855                    showDigErrorMessage(error);
1856                });
1857
1858
1859            }).catch(function (error) {
1860            loader.hide();
1861            if (show_message) {
1862                showDigErrorMessage(dig_mdet.InvalidOTP);
1863            }
1864            add_otp_class(0, otp_field);
1865
1866        });
1867    }
1868
1869    function verify_cust_otp(countryCode, phoneNumber, csrf, otp, dtype, idToken) {
1870        if (lastotpcountrycode == countryCode && lastotpmobileNo == phoneNumber && lastotpDtype == otp) {
1871            loader.hide();
1872            return;
1873        }
1874        lastotpcountrycode = countryCode;
1875        lastotpmobileNo = phoneNumber;
1876        lastotpDtype = otp;
1877
1878        var rememberMe = 0;
1879        if (jQuery("#rememberme").length) {
1880            rememberMe = jQuery("#rememberme:checked").length > 0;
1881        }
1882
1883        jQuery.ajax({
1884            type: 'post',
1885            url: dig_mdet.ajax_url,
1886            data: {
1887                action: 'digits_verifyotp_login',
1888                countrycode: countryCode,
1889                mobileNo: phoneNumber,
1890                otp: otp,
1891                dig_ftoken: idToken,
1892                csrf: csrf,
1893                dtype: dtype,
1894                rememberMe: rememberMe,
1895            },
1896            success: function (res) {
1897                if (isJSON(res)) {
1898                    try {
1899                        var parsedRes = (typeof res === 'object') ? res : JSON.parse(res);
1900                        window.digits_last_login_response = parsedRes.data || parsedRes;
1901                    } catch (e) {}
1902                }
1903
1904                if (isJSON(res)) {
1905
1906                    if (!res.data) {
1907                        res = res;
1908                    } else {
1909
1910                        if (res.data.error_msg) {
1911                            loader.hide();
1912                            if (show_message) {
1913                                if (res.data.error_type) {
1914                                    showDigMessage(res.data.error_msg, res.data.error_type);
1915                                } else {
1916                                    showDigErrorMessage(res.data.error_msg);
1917                                }
1918                            }
1919                            add_otp_class(0, otp_field);
1920                            return;
1921                        }
1922
1923                        if (res.data.redirect) {
1924                            showDigLoginSuccessMessage();
1925                            digits_redirect(res.data.redirect);
1926                            return;
1927                        }
1928                        res = res.data.code;
1929                    }
1930                } else {
1931                    res = res.trim();
1932                }
1933
1934
1935                if (res != 11) loader.hide();
1936
1937                if (res == 1011) {
1938                    showDigErrorMessage(dig_mdet.error);
1939                    return;
1940                }
1941
1942                if (res == 1013) {
1943                    showDigErrorMessage(dig_mdet.error);
1944                    return;
1945                }
1946
1947                if (res == -99) {
1948                    showDigErrorMessage(dig_mdet.invalidcountrycode);
1949                    return;
1950                }
1951
1952                if (res == 0) {
1953
1954                    if (show_message) {
1955                        showDigErrorMessage(dig_mdet.InvalidOTP);
1956                    }
1957
1958                    add_otp_class(0, otp_field);
1959                    return;
1960                } else if (res == 11) {
1961
1962                    if (ihcloginform.length || subitumotp > 0) {
1963                        document.location.href = "/";
1964                    } else {
1965                        showDigLoginSuccessMessage();
1966                        var redirect_to = jQuery('input[name="redirect_to"]');
1967                        if (redirect_to.length) {
1968                            digits_redirect(redirect_to.first().val());
1969                        } else if (jQuery("#digits_redirect_page").length) {
1970                            digits_redirect(jQuery("#digits_redirect_page").val());
1971                        } else digits_redirect(dig_mdet.uri);
1972
1973                    }
1974
1975
1976                    return;
1977                } else if (res == -1 && dtype != 2 && dtype != 11 && dtype != 101) {
1978                    showDigErrorMessage(dig_mdet.ErrorPleasetryagainlater);
1979                    return;
1980                } else if ((res == 1 && dtype == 2) || (res == 1 && dtype == 11)) {
1981                    showDigErrorMessage(dig_mdet.MobileNumberalreadyinuse);
1982                    return;
1983                }
1984                if (is_checkout) {
1985                    curRegForm.find('#dig_man_resend_otp_btn').hide();
1986                    digits_checkout_otp_verify_success(countryCode, phoneNumber, 
1986csrf, otp, dtype, idToken);
1987                } else if (dtype == 2) {
1988
1989                    if (verifybpotp == 1) {
1990                        verifybpotp = 0;
1991                        dig_bp_btn = 2;
1992                        jQuery("#buddypress .signup-form").find("input[name='signup_submit']").click();
1993                    } else if (subitumotp == 2) {
1994                        submitumform = 1;
1995                        jQuery(".um-register").find("form").submit();
1996                    } else {
1997                        registerstatus = 1;
1998                        curRegForm.submit();
1999                    }
2000
2001                } else if (dtype == 3) {
2002
2003
2004                    if (forgotpassihc == 1) {
2005
2006                        jQuery("#digits_password_ihc_cont").show().find("input").attr("required", "required");
2007                        jQuery("#digits_cpassword_ihc_cont").show().find("input").attr("required", "required");
2008                        forgotpassihc = 2;
2009                    } else if (um_forgot_pass == 2) {
2010                        um_forgot_pass = 3;
2011                        cuForm.find('.um-field-text').hide();
2012                        cuForm.find('#dig_man_resend_otp_btn').hide();
2013                        cuForm.find('.changePassword').show();
2014                        update_time_button.val(prv_forg_wc);
2015                        update_time_button.text(prv_forg_wc);
2016
2017                    } else {
2018                        forgotPassChange = 1;
2019                        user_login.parent().parent().hide();
2020                        jQuery("#digit_forgot_otp_container").hide();
2021                        jQuery(".dig_wc_forgot_resend").hide();
2022                        user_login.attr('name', 'forgotmail');
2023                        jQuery("form.lost_reset_password .changePassword").show();
2024                        update_time_button.val(prv_forg_wc);
2025                        update_time_button.text(prv_forg_wc);
2026
2027                    }
2028
2029                } else if (dtype == 11) {
2030
2031                    if (wpuseredit == 1) {
2032                        updateProfileStatus = 1;
2033                        curRegForm.find("[type='submit']").click();
2034
2035                    } else if (bpuseredit == 1) {
2036                        jQuery("#buddypress").find("form").off("submit").submit();
2037                    } else if (ihcedform == 2) {
2038                        submiticform = 1;
2039                        jQuery(".ihc-form-create-edit").submit();
2040                    } else {
2041                        updateAccountStatus = 1;
2042                        jQuery("form.woocommerce-EditAccountForm").submit();
2043                    }
2044
2045                }
2046
2047
2048            }
2049        });
2050    }
2051
2052    var updateAccountStatus = 0;
2053
2054    jQuery("form.woocommerce-EditAccountForm input[type='submit'],form.woocommerce-EditAccountForm button[type='submit']").on('click', function () {
2055
2056        update_time_button = jQuery(this);
2057
2058        if (updateAccountStatus == 1) return true;
2059
2060        var curForm = jQuery(this).closest('form');
2061        var oldMobile = curForm.find('#dig_wc_cur_phone').val();
2062        var curMobile = curForm.find('.dig_wc_nw_phone').val();
2063        var countryCode = curForm.find(".dig_wc_logincountrycode").val();
2064        if (curMobile.length == 0) return true;
2065
2066        if (oldMobile == curMobile) return true;
2067
2068        if (isNumeric(curMobile)) {
2069
2070
2071            var otp = jQuery("#digit_ac_otp");
2072
2073            if (editverify == 1) {
2074
2075                verifyOtp(countryCode, curMobile, nounce.val(), otp.val(), 11);
2076
2077                return false;
2078            }
2079
2080
2081            akCallback = 'updateAccountCallback';
2082            verifyMobileNoLogin(countryCode, curMobile, nounce.val(), 11);
2083
2084        } else {
2085            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2086        }
2087        return false;
2088
2089    });
2090
2091
2092    function updateAccountCallback(response) {
2093        showDigitsLoader(true);
2094        if (response.status === "PARTIALLY_AUTHENTICATED") {
2095            var code = response.code;
2096            var csrf = response.state;
2097
2098            updateAccountStatus = 1;
2099
2100            jQuery("form.woocommerce-EditAccountForm #dig_wc_prof_code").val(code);
2101            jQuery("form.woocommerce-EditAccountForm #dig_wc_prof_csrf").val(csrf);
2102
2103            jQuery("form.woocommerce-EditAccountForm input[type='submit'],form.woocommerce-EditAccountForm button[type='submit']").click();
2104        } else if (response.status === "NOT_AUTHENTICATED") {
2105            // handle authentication failure
2106        } else if (response.status === "BAD_PARAMS") {
2107            //Need to update this
2108        }
2109
2110    }
2111
2112
2113    var wpuseredit = 0;
2114    var edit_profile_form;
2115
2116    jQuery(document).on('keyup', '.digits-edit-phone_field input', function () {
2117        var form = jQuery(this).closest('form');
2118        var phoneNumber = form.find(".mobile_number").val();
2119        var countryCode = form.find(".dig_wc_logincountrycode").val();
2120
2121        var m = countryCode + phoneNumber;
2122        var curPhone = form.find(".dig_cur_phone").val();
2123
2124        if (phoneNumber.length == 0 || curPhone == m) {
2125            form.find('.digits_update_mobile_submit').attr('disabled', 'disabled');
2126        } else {
2127            form.find('.digits_update_mobile_submit').removeAttr('disabled');
2128        }
2129
2130    })
2131
2132    jQuery("form#your-profile input[type='submit'],.digits_update_mobile_submit,form#your-profile button[type='submit']").on('click', function () {
2133        wpuseredit = 1;
2134        update_time_button = jQuery(this);
2135        curRegForm = jQuery(this).closest('form');
2136        var is_digits_update = curRegForm.find('.digits_update_mobile');
2137        if (updateProfileStatus == 1) return true;
2138
2139        if (dig_mdet.verify_mobile == 1 || is_digits_update.length) {
2140
2141            var phoneNumber = curRegForm.find(".mobile_number").val();
2142            var countryCode = curRegForm.find(".dig_wc_logincountrycode").val();
2143
2144            var m = countryCode + phoneNumber;
2145            var curPhone = curRegForm.find(".dig_cur_phone").val();
2146
2147            if (phoneNumber.length == 0 || curPhone == m) {
2148                if (is_digits_update.length) {
2149                    return false;
2150                }
2151                return true;
2152            }
2153
2154
2155            var otp = curRegForm.find(".digits_otp_field");
2156
2157            if (isNumeric(phoneNumber)) {
2158
2159                if (editverify == 1) {
2160                    verifyOtp(countryCode, phoneNumber, nounce.val(), otp.val(), 11);
2161                    return false;
2162                }
2163                akCallback = 'updateProfileCallback';
2164                verifyMobileNoLogin(countryCode, phoneNumber, nounce.val(), 11);
2165
2166            } else {
2167                showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2168            }
2169
2170            return false;
2171        }
2172        if (is_digits_update.length) return false;
2173    });
2174
2175    jQuery(document).on("click", "#dig_man_resend_otp_btn", function () {
2176
2177        var dbbtn = jQuery(this);
2178        if (!jQuery(this).hasClass("dig_resendotp_disabled")) {
2179            loader.show();
2180
2181            if (isFirebase == 1) {
2182                dismissLoader = true;
2183                loader.show();
2184
2185                var countrycode = dbbtn.attr("countrycode");
2186                var phone;
2187
2188                if (countrycode == '+242' || countrycode == '+225') {
2189                    phone = countrycode + '0' + dbbtn.attr("mob");
2190                } else {
2191                    phone = countrycode + dbbtn.attr("mob");
2192                }
2193
2194                grecaptcha.reset(window.recaptchaWidgetId);
2195
2196                var appVerifier = window.recaptchaVerifier;
2197                firebase.auth().signInWithPhoneNumber(phone, appVerifier)
2198                    .then(function (confirmationResult) {
2199                        isDigFbAdd = 1;
2200                        loader.hide();
2201                        window.confirmationResult = confirmationResult;
2202                        updateTime(dbbtn);
2203                    }).catch(function (error) {
2204                    if (error.message === 'TOO_LONG' || error.message === 'TOO_SHORT') {
2205                        showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2206                    } else {
2207                        showDigErrorMessage(dig_mdet.Invaliddetails);
2208                    }
2209                    loader.hide();
2210                });
2211
2212
2213            } else {
2214                jQuery.ajax({
2215                    type: 'post',
2216                    url: dig_mdet.ajax_url,
2217                    data: {
2218                        action: 'digits_resendotp',
2219                        countrycode: dbbtn.attr("countrycode"),
2220                        mobileNo: dbbtn.attr("mob"),
2221                        csrf: dbbtn.attr("csrf"),
2222                        login: dbbtn.attr("dtype"),
2223                        whatsapp: useWhatsApp
2224                    },
2225                    success: function (res) {
2226                        res = res.trim();
2227                        loader.hide();
2228                        if (res == 0) {
2229                            showDigNoticeMessage(dig_mdet.Pleasetryagain);
2230                        } else if (res == -99) {
2231                            showDigErrorMessage(dig_mdet.invalidcountrycode);
2232                        } else {
2233                            updateTime(dbbtn);
2234                        }
2235                    }
2236                });
2237            }
2238        }
2239    });
2240
2241
2242    var resendTime = dig_mdet.resendOtpTime;
2243    var update_time_button;
2244
2245    function updateTime(time) {
2246
2247        tokenCon = time.closest('form');
2248
2249        if (update_time_button) {
2250            if (update_time_button.is('input')) {
2251                update_time_button.attr('value', dig_mdet.SubmitOTP);
2252            } else {
2253                update_time_button.text(dig_mdet.SubmitOTP);
2254            }
2255        }
2256
2257
2258        time.attr("dis", 1).addClass("dig_resendotp_disabled").show().find("span").show();
2259        var time_spam = time.find("span");
2260        time_spam.text(convToMMSS(resendTime));
2261        var counter = 0;
2262        var interval = setInterval(function () {
2263            var rem = resendTime - counter;
2264            time_spam.text(convToMMSS(rem));
2265            counter++;
2266
2267            if (counter >= resendTime) {
2268                clearInterval(interval);
2269                time.removeAttr("dis").removeClass("dig_resendotp_disabled").find("span").hide();
2270                counter = 0;
2271            }
2272
2273        }, 1000, true);
2274    }
2275
2276    function convToMMSS(timeInSeconds) {
2277        var sec_num = parseInt(timeInSeconds, 10);
2278        var hours = Math.floor(sec_num / 3600);
2279        var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
2280        var seconds = sec_num - (hours * 3600) - (minutes * 60);
2281
2282        if (minutes < 10) {
2283            minutes = "0" + minutes;
2284        }
2285        if (seconds < 10) {
2286            seconds = "0" + seconds;
2287        }
2288        return "(" + minutes + ':' + seconds + ")";
2289    }
2290
2291
2292    jQuery(document.body).on('payment_method_selected', function () {
2293        var place_order = jQuery('#place_order').text();
2294    })
2295
2296    jQuery(document.body).on('updated_checkout', function (e) {
2297    })
2298
2299
2300    var verfiybilling = 0;
2301    var billing_page = 0;
2302    if ((jQuery('.woocommerce-checkout').length || jQuery("#checkout").length)) {
2303        var billing_otp_field = jQuery("#dig_billing_otp");
2304        billing_otp_field.closest("p").hide();
2305
2306        var regForm;
2307        var undigbill = jQuery(".woocommerce-checkout");
2308
2309        var createAccount = undigbill.find(".create-account").last();
2310
2311        jQuery(document).on('change', '#createaccount', function () {
2312            createAccount.find('.digcon #username').trigger('keyup');
2313        });
2314
2315        var digchbtn = "<input type='submit' class='dig_billing_otp_signup' onclick='verifyOTPbilling(1);return false;' value='" + dig_mdet.verifymobilenumber + "'/>";
2316
2317        if (!(dig_billing_password.length && dig_mdet.pass_accept == 1)) {
2318            undigbill.attr('data-show-btn', 'dig_billing_otp_signup');
2319        }
2320
2321        if (dig_mdet.mobile_accept == 2) {
2322            jQuery(".dig_billing_otp_signup").show();
2323        }
2324
2325        /* createAccount.append("" +
2326             "<div class='dig_billing_wc_dv'>" +
2327             digchbtn +
2328             '</div><div  class="dig_resendotp dig_wcbil_bill_resend" id="dig_man_resend_otp_btn" dis="1">' + dig_mdet.resendOTP + ' <span>(00:<span>30</span>)</span></div>' +
2329             "<a id='dig_billing_validate_button' style='display:none;'></a><a id='dig_billing_signupwithpassword' style='display:none;'></a><br /> ");*/
2330
2331        var tasc = 0;
2332
2333        function digits_checkout_otp_verify_success(countryCode, phoneNumber, 
2333csrf, otp, dtype, idToken) {
2334            var form = jQuery('form.checkout');
2335
2336            if (!form.find('#digits_checkout_otp').length) {
2337                form.append('<input type="hidden" name="digit_ac_otp" id="digits_checkout_otp" />');
2338            }
2339            form.find('#digits_checkout_otp').val(otp);
2340
2341            var mobile_field = form.find('input[name="mobile_email"]');
2342            var billing_phone = form.find('input[name="billing_phone"]');
2343
2344            if (!mobile_field.length) {
2345                form.append('<input type="hidden" name="mobile_email" id="username" />');
2346                form.find('input[name="mobile_email"]').val(phoneNumber);
2347            }
2348            if (!billing_phone.length) {
2349                var wc_billing_phone = jQuery('#billing_phone');
2350                if (wc_billing_phone.length) {
2351                    form.append('<input type="hidden" name="billing_phone" id="billing_phone" />');
2352                    form.find('input[name="billing_phone"]').val(wc_billing_phone.val());
2353                }
2354            }
2355
2356            digits_process_checkout()
2357        }
2358
2359        function digits_show_checkout_otp_modal(countrycode, mobileNo, csrf, dtype) {
2360            var nonce = jQuery('#place_order').data('digits_verify');
2361            loader.show()
2362            jQuery.ajax({
2363                type: 'post',
2364                url: dig_mdet.ajax_url,
2365                data: {
2366                    action: 'digits_wc_checkout_phone_verification_modal',
2367                    _ajax_nonce: nonce,
2368                },
2369                success: function (res) {
2370                    var data = res.data;
2371                    if (res.success) {
2372                        jQuery('.digits_wc_checkout_phone_verification_modal').remove();
2373                        var html = jQuery(data.html);
2374                        jQuery('body').append(html);
2375                        html.find('input').focus().attr('dtype', dtype);
2376                    } else {
2377                        showDigErrorMessage(data.message)
2378                    }
2379                    loader.hide();
2380
2381                },
2382                error: function (res) {
2383                    loader.hide();
2384                }
2385            });
2386
2387        }
2388
2389        jQuery(document).on('click', '.digits-checkout_phone_verification .digits-form_button', function (e) {
2390            var $this = jQuery(this);
2391            var form = jQuery('form.checkout');
2392            otp_field = $this.closest('form').find('#digits_secure_billing_phone_otp');
2393            var otp = otp_field.val();
2394            var dtype = otp_field.attr('dtype');
2395            unbpchk = form.find(".woocommerce-billing-fields #username");
2396            if (!unbpchk.length) {
2397                unbpchk = form.find("#username");
2398            }
2399            if (!unbpchk.length) {
2400                unbpchk = jQuery('#billing_phone_field #username');
2401            }
2402
2403            curRegForm = form;
2404            is_checkout = true;
2405
2406            if (otp == null || otp.length == 0) {
2407                return false;
2408            }
2409
2410            if (isFirebase == 1 && otp.length != 6) {
2411                return false;
2412            }
2413            tokenCon = form;
2414            var phone = unbpchk.val();
2415            var countrycode = unbpchk.parent().parent().parent().find(".dig_wc_logincountrycode").val();
2416            verifyOtp(countrycode, phone, nounce.val(), otp, dtype);
2417
2418            return false;
2419        })
2420
2421        function digits_process_checkout() {
2422            jQuery('.digits_wc_checkout_phone_verification_modal').fadeOut('fast');
2423            jQuery('form.checkout').trigger('submit');
2424        }
2425
2426
2427        jQuery(document).on('click', '.digits_wc_checkout_phone_verification_modal .digits_secure_modal-close', function (e) {
2428            var container = jQuery(this).closest('.digits_secure_modal_box');
2429            container.fadeOut();
2430
2431            return false;
2432        })
2433
2434        jQuery(document).on('digits_process_wc_checkout', function () {
2435            var form = jQuery('form.checkout');
2436            if (!form) {
2437                form = jQuery('#place_order').closest('form');
2438            }
2439
2440            var create_verify_inp = form.find('#digits_vcustomer_phone');
2441
2442            var dtype = 2;
2443            var verify = false;
2444
2445            if (!create_verify_inp.length) {
2446                if (dig_mdet.mob_verify_checkout == 1 && dig_mdet.mobile_accept > 0) {
2447                    verify = true;
2448                    dtype = 101;
2449                } else {
2450                    verify = false;
2451                }
2452            } else {
2453                var create_verify = create_verify_inp.val();
2454                var payment_verify = form.find('#digits_vbill_phone').val();
2455                var guest_verify = form.find('#digits_guest_vbill_phone').val();
2456
2457                var createaccount = jQuery('input#createaccount');
2458
2459                if (dig_mdet.mobile_accept > 0) {
2460                    if (create_verify !== 'all') {
2461                        if (create_verify === 'check') {
2462                            verify = createaccount.is(':checked');
2463                        }
2464                    } else {
2465                        verify = true;
2466                    }
2467                }
2468
2469                var payment_method = form.find('input[name="payment_method"]:checked').val();
2470
2471                if (wc_checkout_params.option_guest_checkout === 'yes') {
2472                    if (!verify && guest_verify !== 'none') {
2473                        if (!createaccount.length || !createaccount.is(':checked')) {
2474                            if (payment_method === 'cod' && guest_verify === 'cod') {
2475                                verify = true;
2476                                dtype = 101;
2477                            } else if (guest_verify === 'all_methods') {
2478                                verify = true;
2479                                dtype = 101;
2480                            }
2481                        }
2482                    }
2483                }
2484
2485                if (!verify && payment_verify !== 'none') {
2486                    if (form.find('#digits_customer_checkout').length > 0 || (createaccount.length && createaccount.is(':checked'))) {
2487                        if (payment_method === 'cod' && payment_verify === 'cod') {
2488                            verify = true;
2489                            dtype = 101;
2490                        } else if (payment_verify === 'all_methods') {
2491                            verify = true;
2492                            dtype = 101;
2493                        }
2494
2495                    }
2496                }
2497            }
2498
2499            if (!verify || form.find('#digits_checkout_otp').length > 0) {
2500                digits_process_checkout();
2501                return true;
2502            }
2503
2504            var $this = form.find('#place_order');
2505            billing_page = 1;
2506            unbpchk = form.find(".woocommerce-billing-fields #username");
2507            if (!unbpchk.length) {
2508                unbpchk = form.find("#username");
2509            }
2510
2511            if (!unbpchk.length) {
2512                unbpchk = jQuery('#billing_phone_field #username');
2513            }
2514
2515
2516            var error = false;
2517            form.find('input').each(function () {
2518                var inp = jQuery(this);
2519                var val = inp.val();
2520                if (inp.is(":visible") && val.length == 0) {
2521                    var par = jQuery(this).closest('.form-row');
2522                    if (par.hasClass('validate-required')) {
2523                        error = true;
2524                        return true;
2525                    }
2526                }
2527            });
2528
2529
2530            var custom_validation = validateCustomFields(createAccount);
2531
2532            if (!custom_validation || error) {
2533                showDigNoticeMessage(dig_mdet.fillAllDetails);
2534                return false;
2535            }
2536
2537
2538            var termsCheckBox = form.find('#terms');
2539            if (termsCheckBox.length > 0) {
2540                var termsCheckBoxChecked = termsCheckBox.prop('checked');
2541                if (!termsCheckBoxChecked) {
2542                    showDigErrorMessage(dig_mdet.accepttac);
2543                    return false;
2544                }
2545            }
2546
2547
2548            if (jQuery(".dig_opt_mult_con_tac").find('.dig_input_error').length) {
2549                showDigErrorMessage(dig_mdet.accepttac);
2550                return false;
2551            }
2552
2553            if (dig_log_obj.mobile_accept == 0 && dig_log_obj.mail_accept == 0) {
2554                digits_process_checkout();
2555                return true;
2556            }
2557
2558            if(unbpchk.length === 0){
2559                digits_process_checkout();
2560                return true;
2561            }
2562            var phone = unbpchk.val();
2563            var countrycode = unbpchk.parent().parent().parent().find(".dig_wc_logincountrycode").val();
2564
2565            if (!isNumeric(phone) && dig_mdet.mobile_accept != 2) {
2566                showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2567                return false;
2568            }
2569            if (isNumeric(phone)) {
2570                akCallback = 'updateCheckoutDetails';
2571                verifyMobileNoLogin(countrycode, phone, nounce.val(), dtype);
2572
2573            } else {
2574                showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2575                return false;
2576            }
2577        })
2578
2579    }
2580
2581    var unbpchk;
2582    var ihcloginform = jQuery("#ihc_login_form");
2583
2584    var acur = window.location.href;
2585    acur = acur.substring(0, acur.indexOf('?'));
2586
2587
2588    if (ihcloginform.length && dig_mdet.login_mobile_accept > 0) {
2589        var usernameihc = ihcloginform.find("#iump_login_username");
2590        var passwordihc = ihcloginform.find("#iump_login_password");
2591        usernameihc.attr("placeholder", dig_mdet.UsernameMobileno);
2592
2593
2594        //ihcloginform.attr("action", acur + "?login=true");
2595
2596        var ccd = dig_mdet.uccode;
2597
2598
2599        ihcloginform.find("input[type='hidden']").val(dig_mdet.nonce).attr("name", "dig_nounce");
2600
2601        ihcloginform.append("<input type='hidden' value='true' name='isimpc' />");
2602
2603        usernameihc.wrap('<div class="digcon"></div>').before('<div class="dig_ihc_countrycodecontainer dig_ihc_logincountrycodecontainer" style="display: none;">' +
2604            '<input type="text" name="countrycode" class="input-text countrycode dig_ihc_logincountrycode" ' +
2605            'value="' + ccd + '" maxlength="6" size="3" placeholder="' + ccd + '" style="position: absolute;top:0;"/></div>');
2606
2607        usernameihc.on("keyup change focusin", function (e) {
2608            if (isNumeric(jQuery(this).val())) {
2609                jQuery(".dig_ihc_logincountrycodecontainer").css({"display": "inline-block"});
2610                jQuery(this).attr('style', "padding-left:" + mobilePaddingLeft((jQuery(".dig_ihc_logincountrycode").outerWidth(true) + 10) + "px !important"));
2611            } else {
2612                jQuery(".dig_ihc_logincountrycodecontainer").hide();
2613                jQuery(this).removeAttr('style');
2614            }
2615        });
2616
2617        jQuery('<div class="impu-form-line-fr impu-dig-otp" id="impu-dig-otp" style="display: none;">' +
2618            '<input value="" id="digits_otp_ihc" name="digit_otp" placeholder="' + dig_mdet.OTP + '" type="tel" style="padding-left:10px !important;">')
2619            .insertBefore("#ihc_login_form .impu-form-submit");
2620
2621
2622        jQuery('.dig_ihc_logincountrycode').on("keyup change focusin", function (e) {
2623            var size = jQuery(this).val().length;
2624            size++;
2625            if (size < 2) size = 2;
2626            jQuery(this).attr('size', size);
2627            var code = jQuery(this).val();
2628            if (code.trim().length == 0) {
2629                jQuery(this).val("+");
2630            }
2631            usernameihc.attr('style', "padding-left:" + mobilePaddingLeft((jQuery(".dig_ihc_logincountrycode").outerWidth(true) + 10) + "px !important"));
2632        });
2633
2634
2635        jQuery('#ihc_login_form').off('submit');
2636
2637        var remotp = 0;
2638
2639        if (!dig_mdet.secure_forms) {
2640            jQuery(document).on("click", "#impu_log_submit", function () {
2641                update_time_button = jQuery(this);
2642                cuForm = jQuery(this).closest('form');
2643
2644                if (verifyimpuotp == 1) {
2645                    verifyOtp(jQuery(".dig_ihc_logincountrycode").val(), usernameihc.val(), dig_mdet.nonce, jQuery("#digits_otp_ihc").val(), 1);
2646                    return false;
2647                }
2648
2649                if (isNumeric(usernameihc.val())) {
2650                    ihc_loginform = 1;
2651
2652                    akCallback = 'loginCallback';
2653                    verifyMobileNoLogin(jQuery(".dig_ihc_logincountrycode").val(), usernameihc.val(), dig_mdet.nonce, 1);
2654
2655
2656                    if (remotp == 0) {
2657                        remotp = 1;
2658
2659                        ihcloginform.find("#digorimp").hide();
2660                        ihcloginform.find('.impu-form-submit').find("input:first").remove();
2661
2662                        ihcloginform.find("div").each(function (index) {
2663                            if (index > 1) {
2664                                if (!jQuery(this).hasClass("impu-form-submit") && !jQuery(this).hasClass("dig_ihc_logincountrycodecontainer") && !jQuery(this).hasClass("impu-dig-otp"))
2665                                    jQuery(this).hide();
2666                            }
2667                        });
2668                    }
2669                }
2670                return false;
2671            });
2672            if (dig_mdet.login_otp_accept > 0) {
2673                ihcloginform.find(".impu-form-submit").append("<div id='digorimp'> " + dig_mdet.or + "<br /><br /></div>" +
2674                    "<input type='submit' id='impu_log_submit' value='" + dig_mdet.loginwithotp + "' />" +
2675                    "<div class='dig_resendotp dig_impu_login_resend' id='dig_man_resend_otp_btn' dis='1'>" + dig_mdet.resendOTP + " <span>(00:<span>30</span>)</span></div></div>");
2676            }
2677        }
2678    }
2679    var verifyimpuotp = 0;
2680    var ihc_loginform = 0;
2681
2682
2683    var ihcforgotpasswrap = jQuery(".ihc-pass-form-wrap");
2684    var ihforgaction = ihcforgotpasswrap.find("input[type='hidden']");
2685    var forgotpassMobVerifiedihc = 0;
2686    var forgotpassihc = 0;
2687    if (ihforgaction.val() == "reset_pass" && dig_mdet.forgot_pass > 0) {
2688
2689        var ihcforgpassform = ihcforgotpasswrap.find("form");
2690
2691
2692        var ihcforgsub = ihcforgpassform.find("input[type='submit'],button[type='submit']");
2693
2694        jQuery("<div class='dig_resendotp dig_impu_forg_resend' id='dig_man_resend_otp_btn' dis='1'>" + dig_mdet.resendOTP + " <span>(00:<span>30</span>)</span></div>")
2695            .insertAfter(ihcforgsub);
2696
2697        ihcforgpassform.append("<input type='hidden' name='dig_nounce' value='" + dig_mdet.nonce + "' /><input type='hidden' name='ihc' value='true' />");
2698
2699        var ihcForgotUsername = ihcforgotpasswrap.find("input[type='text']");
2700
2701
2702        ihcforgpassform.on('submit', function (e) {
2703            update_time_button = jQuery(this);
2704            if (forgotpassihc == 2) {
2705                var pass = jQuery("#digits_password_ihc").val();
2706                var cpass = jQuery("#digits_cpassword_ihc").val();
2707                if (pass != cpass) {
2708                    showDigErrorMessage(dig_mdet.Passwordsdonotmatch);
2709                    return false;
2710                }
2711                ihcforgpassform.off('submit').submit();
2712                return;
2713            }
2714            forgotpassihc = 1;
2715            if (isNumeric(ihcForgotUsername.val())) {
2716
2717
2718                ihcforgpassform.attr("action", acur + "?login=true");
2719                ihcForgotUsername.attr("name", "forgotmail");
2720
2721                var countrycode = jQuery(".dig_ihc_forgotcountrycode").val();
2722
2723                akCallback = 'forgotihcCallback';
2724
2725
2726                if (forgotpassMobVerifiedihc == 0) {
2727                    verifyMobileNoLogin(countrycode, ihcForgotUsername.val(), dig_mdet.nonce, 3);
2728                } else {
2729                    forgotpassihc = 1;
2730                    verifyOtp(countrycode, ihcForgotUsername.val(), dig_mdet.nonce, jQuery("#digits_otp_forg_ihc").val(), 3)
2731
2732                }
2733
2734                return false;
2735            }
2736            ihcForgotUsername.attr("name", "email_or_userlogin");
2737            ihcforgpassform.removeAttr("action");
2738            return true;
2739
2740        });
2741
2742
2743        var ccd = dig_mdet.uccode;
2744
2745        ihcForgotUsername.wrap('<div class="digcon"></div>').before('<div class="dig_ihc_forgot_countrycodecontainer dig_ihc_forgot_logincountrycodecontainer" style="display: none;">' +
2746            '<input type="text" name="countrycode" class="input-text countrycode dig_ihc_forgotcountrycode" ' +
2747            'value="' + ccd + '" maxlength="6" size="3" placeholder="' + ccd + '" style="position: absolute;top:0;"/></div>');
2748        ihcForgotUsername.attr("placeholder", dig_mdet.UsernameMobileno);
2749
2750        jQuery(
2751            '<div class="impu-form-line-fr" id="digits_password_ihc_cont" style="display: none;"><input value="" id="digits_password_ihc" name="digits_password" placeholder="' + dig_mdet.Password + '" type="password" style="padding-left:10px !important;"></div>' +
2752            '<div class="impu-form-line-fr" id="digits_cpassword_ihc_cont" style="display: none;"><input value="" id="digits_cpassword_ihc" name="digits_cpassword" placeholder="' + dig_mdet.ConfirmPassword + '" type="password" style="padding-left:10px !important;"></div>')
2753            .insertAfter(ihcForgotUsername.closest(".impu-form-line-fr"));
2754
2755        jQuery('<div class="impu-form-line-fr impu-dig-otp" id="impu-dig-otp" style="display: none;"><input value="" id="digits_otp_forg_ihc" name="dig_otp" placeholder="' + dig_mdet.OTP + '" type="tel" style="padding-left:10px !important;" autocomplete="one-time-code"></div>')
2756            .insertAfter(ihcForgotUsername.closest(".impu-form-line-fr"));
2757
2758        jQuery('<input type="hidden" name="code" id="digits_impu_code"/><input type="hidden" name="csrf" id="digits_impu_csrf"/>')
2759            .insertAfter(ihcForgotUsername.closest(".impu-form-line-fr"));
2760
2761
2762        ihcForgotUsername.on("keyup change focusin", function (e) {
2763            if (isNumeric(jQuery(this).val())) {
2764                jQuery(".dig_ihc_forgot_countrycodecontainer").css({"display": "inline-block"});
2765                jQuery(this).attr('style', "padding-left:" + mobilePaddingLeft((jQuery(".dig_ihc_forgotcountrycode").outerWidth(true) + 10) + "px !important"));
2766
2767            } else {
2768                jQuery(".dig_ihc_forgot_countrycodecontainer").hide();
2769                jQuery(this).removeAttr('style');
2770
2771            }
2772        });
2773
2774        jQuery('.dig_ihc_forgotcountrycode').on("keyup change focusin", function (e) {
2775            var size = jQuery(this).val().length;
2776            size++;
2777            if (size < 2) size = 2;
2778            jQuery(this).attr('size', size);
2779            var code = jQuery(this).val();
2780            if (code.trim().length == 0) {
2781                jQuery(this).val("+");
2782            }
2783            ihcForgotUsername.attr('style', "padding-left:" + mobilePaddingLeft((jQuery(".dig_ihc_forgotcountrycode").outerWidth(true) + 10) + "px !important"));
2784        });
2785
2786    }
2787
2788
2789    function mobilePaddingLeft(value) {
2790        if (dig_mdet.dig_hide_ccode == 1) {
2791            return '0.75em';
2792        } else {
2793            return value;
2794        }
2795    }
2796
2797    if (jQuery(".dig_bp_enb").length) {
2798        jQuery(".dig_bp_enb").each(function (index) {
2799            jQuery(this).remove();
2800        });
2801    }
2802    var dig_bp_btn = 0;
2803    var verfiyBPReg = 0;
2804
2805    jQuery(document).on("click", "#signup_submit_pass_bp", function () {
2806        if (verfiyBPReg == 1) return true;
2807        verfiyBPReg = 1;
2808        var bpForm = jQuery("#buddypress").find("form");
2809
2810        bpForm.find("#dig_reg_bp_pass").show().find("input").attr("required", "required");
2811        bpForm.find("#signup_submit_otp_bp").hide();
2812        return false;
2813    });
2814
2815    jQuery("#buddypress").find('#signup-form,#signup_form').addClass('signup-form');
2816    jQuery("#buddypress .signup-form").on('submit', function () {
2817        update_time_button = jQuery(this).find('input[name="signup_submit"]');
2818        if (dig_bp_btn == 2) return true;
2819        dig_bp_btn = 1;
2820
2821        var bpForm = jQuery(this);
2822        tokenCon = bpForm;
2823        var phone = bpForm.find("#username").val();
2824        var countrycode = bpForm.find(".dig_wc_logincountrycode").val();
2825        var otp = jQuery("#dig_bp_reg_otp");
2826
2827
2828        var pass = bpForm.find("#signup_password").val();
2829
2830
2831        if (dig_mdet.strong_pass == 1) {
2832            if (dig_mdet.pass_accept == 2 || pass.length > 0) {
2833                var strength = wp.passwordStrength.meter(pass, ['black', 'listed', 'word'], pass);
2834                if (strength != null && strength < 3) {
2835                    showDigNoticeMessage(dig_mdet.useStrongPasswordString);
2836                    return false;
2837                }
2838            }
2839        }
2840
2841
2842        if (verifybpotp == 1) {
2843            verifyOtp(countrycode, phone, nounce.val(), otp.find("input").val(), 2);
2844        } else if (phone.length == 0) {
2845            showDigNoticeMessage(dig_mdet.pleaseentermobormail);
2846        } else if (pass.length == 0 && !isNumeric(phone)) {
2847            showDigNoticeMessage(dig_mdet.eitherentermoborusepass);
2848        } else if (isNumeric(phone)) {
2849
2850
2851            if (bpForm.find("#signup_submit_otp_bp").is(':visible')) bpForm.find("#signup_submit_pass_bp").remove();
2852
2853
2854            akCallback = 'updateRegisterDetails';
2855            verifyMobileNoLogin(countrycode, phone, nounce.val(), 2);
2856
2857
2858        } else if (validateEmail(phone)) {
2859            return true;
2860        } else {
2861            showDigErrorMessage(dig_mdet.Invaliddetails);
2862        }
2863        return false;
2864    });
2865
2866    var verifybpotp = 0;
2867
2868    function updateRegisterDetails(response) {
2869        showDigitsLoader(true);
2870        if (response.status === "PARTIALLY_AUTHENTICATED") {
2871            var code = response.code;
2872            var csrf = response.state;
2873
2874            jQuery("#dig_bp_reg_code").val(code);
2875            jQuery("#dig_bp_reg_csrf").val(csrf);
2876            dig_bp_btn = 2;
2877            jQuery("#buddypress").find("form").submit();
2878        }
2879    }
2880
2881
2882    var bpuseredit = 0;
2883    var bpeditverify = 0;
2884
2885    jQuery("#buddypress").find("form#settings-form").on('submit', function () {
2886        update_time_button = jQuery(this).find('[type="submit"]');
2887        var form = jQuery(this);
2888        tokenCon = form;
2889        var uname = form.find("#username").val();
2890        var ccode = form.find(".dig_wc_logincountrycode").val();
2891
2892        if (jQuery("#dig_superadmin").length) return true;
2893
2894        if (isNumeric(uname)) {
2895            if (uname == form.find("#dig_bp_current_mob")) return true;
2896            if (bpeditverify == 1) {
2897                var otp = jQuery("#bp_otp_dig_ea");
2898                verifyOtp(ccode, uname, nounce.val(), otp.find("input").val(), 11);
2899            } else {
2900                bpuseredit = 1;
2901                akCallback = 'updateBPAccountDetails';
2902
2903                verifyMobileNoLogin(ccode, uname, nounce.val(), 11);
2904
2905            }
2906        } else return true;
2907        return false;
2908    });
2909
2910    function updateBPAccountDetails(response) {
2911        showDigitsLoader(true);
2912        if (response.status === "PARTIALLY_AUTHENTICATED") {
2913            var code = response.code;
2914            var csrf = response.state;
2915
2916            jQuery("#dig_bp_ea_code").val(code);
2917            jQuery("#dig_bp_ea_csrf").val(csrf);
2918            dig_bp_btn = 2;
2919            jQuery("#buddypress").find("form").off("submit").submit();
2920        }
2921    }
2922
2923
2924    if (dig_mdet.login_mobile_accept !== 0) {
2925        var bb_wp_lform = jQuery(".wp_login");
2926        if (dig_mdet.login_mail_accept == 0 && dig_mdet.login_uname_accept == 0) {
2927            bb_wp_lform.find('#username').data('type', 2);
2928        }
2929        if (!bb_wp_lform.length) {
2930            bb_wp_lform = jQuery(".wp-core-ui #loginform");
2931            bb_wp_lform.addClass('wp_login');
2932        }
2933        if (!dig_mdet.secure_forms) {
2934            if (bb_wp_lform.length && dig_mdet.login_otp_accept > 0) {
2935                bb_wp_lform.addClass('digits');
2936                bb_wp_lform.find("[type='submit']").parent().append("<div class='dig_otp_block'><div class='digor'> " + dig_mdet.or + "<br /><br /></div>" +
2937                    "<input type='submit' class='dig_wc_mobileLogin button button-primary button-large' id='wp_bb_log_submit' value='" + dig_mdet.loginwithotp + "' />" +
2938                    "<div class='dig_resendotp dig_wc_login_resend dig_bb_login_resend' id='dig_man_resend_otp_btn' dis='1'>" + dig_mdet.resendOTP + " <span>(00:<span>30</span>)</span></div></div></div>");
2939            }
2940        }
2941    }
2942    jQuery(".wp_reg").on('submit', function () {
2943
2944        if (registerstatus == 1) return true;
2945
2946        update_time_button = jQuery(this).find("[type='submit']");
2947        curRegForm = jQuery(this);
2948        tokenCon = curRegForm;
2949        var mobile = formatMobileNumber(curRegForm.find("#username").val());
2950        var ccode = curRegForm.find(".dig_wc_logincountrycode").val();
2951
2952
2953        var custom_validation = validateCustomFields(curRegForm);
2954
2955        if (!custom_validation) {
2956            return false;
2957        }
2958
2959        if (dig_mdet.mobile_accept == 0) {
2960            return true;
2961        }
2962
2963        if (!isNumeric(mobile) || !isNumeric(ccode) || ccode.length == 0 || mobile.length == 0) {
2964            if (mobile.length == 0 && dig_mdet.mobile_accept == 1) {
2965                return true;
2966            }
2967            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
2968            return false;
2969        }
2970
2971
2972        var otp = jQuery("#reg_billing_otp");
2973
2974        if (regverify == 1) {
2975            verifyOtp(ccode, mobile, nounce.val(), otp.val(), 2);
2976            return false;
2977        }
2978
2979
2980        if (curRegForm.find("#user_uname").length) {
2981            username_reg_field = curRegForm.find("#user_uname").val();
2982        }
2983        if (curRegForm.find(".dig-custom-field-type-captcha").length) {
2984            captcha_reg_field = curRegForm.find(".dig-custom-field-type-captcha").find("input[type='text']").val();
2985            captcha_ses_reg_field = curRegForm.find(".dig-custom-field-type-captcha").find(".dig_captcha_ses").val();
2986        }
2987        email_reg_field = curRegForm.find("#user_email").val();
2988
2989
2990        akCallback = 'registerWooCallBack';
2991        verifyMobileNoLogin(ccode, mobile, nounce.val(), 2);
2992
2993        return false;
2994
2995    });
2996
2997
2998    function updateIHCAccountDetails(response) {
2999        showDigitsLoader(true);
3000        if (response.status === "PARTIALLY_AUTHENTICATED") {
3001            var code = response.code;
3002            var csrf = response.state;
3003
3004            jQuery("#dig_ihc_ea_code").val(code);
3005            jQuery("#dig_ihc_ea_csrf").val(csrf);
3006            submiticform = 1;
3007            jQuery(".ihc-form-create-edit").submit();
3008        }
3009    }
3010
3011    var submiticform = 0;
3012    var ihcedform = 0;
3013    if (c.length) {
3014
3015        var e = jQuery("#dig_ihc_mobcon");
3016
3017        if (jQuery(".iump-register-form").find("#edituser").length && dig_mdet.mobile_accept > 0) {
3018            jQuery(c).prepend(e);
3019            jQuery(e.find("#dig_ihc_mobotp")).insertBefore(c.find("input[type='submit'],button[type='submit']").closest('.iump-submit-form'));
3020        }
3021
3022        jQuery(".ihc-form-create-edit input[type=submit]").on('click', function () {
3023            update_time_button = jQuery(this);
3024            var form = jQuery(".ihc-form-create-edit");
3025
3026            if (submiticform == 1 || !form.find("#username").length) return true;
3027            var mob = form.find("#username").val();
3028            var ccode = form.find(".dig_wc_logincountrycode").val();
3029
3030            if (mob == form.find("#dig_ihc_current_mob").val()) return true;
3031
3032            if (isNumeric(mob)) {
3033                if (ihcedform == 2) {
3034                    var otp = form.find("#dig_ihc_mobotp");
3035                    verifyOtp(ccode, mob, nounce.val(), otp.find("input").val(), 11);
3036
3037                } else {
3038                    akCallback = 'updateIHCAccountDetails';
3039
3040                    ihcedform = 1;
3041                    verifyMobileNoLogin(ccode, mob, nounce.val(), 11);
3042                }
3043
3044            } else if (mob.length > 0) {
3045                showDigErrorMessage(dig_mdet.InvalidMobileNumber);
3046            } else return true;
3047            return false;
3048        })
3049    }
3050
3051
3052    var submitumform = 0;
3053    var subitumotp = 0;
3054
3055    um_register.find("form").on('submit', function () {
3056
3057        update_time_button = jQuery(this).find('#um-submit-btn');
3058        if (submitumform == 1) return true;
3059        var form = jQuery(this);
3060        var uid = form.find("#username").val();
3061        var ccode = form.find(".dig_wc_logincountrycode").val();
3062        var c = form.find(".dig_otp_um_reg");
3063        if (!uid) return true;
3064        if (form.find("#um_sub").length > 0) {
3065            return true;
3066        }
3067
3068        var custom_validation = validateCustomFields(form);
3069        if (!custom_validation) {
3070            return false;
3071        }
3072
3073
3074        if (!isNumeric(uid)) {
3075            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
3076            return false;
3077        }
3078        loader.show();
3079
3080        uid = formatMobileNumber(uid);
3081
3082        akCallback = 'submitUMRegform';
3083
3084        if (subitumotp == 2) {
3085            verifyOtp(ccode, uid, nounce.val(), c.find("input").val(), 2);
3086        } else {
3087
3088            subitumotp = 1;
3089            verifyMobileNoLogin(ccode, uid, nounce.val(), 2);
3090        }
3091
3092
3093        jQuery(".um-register").find("input[type='submit'],button[type='submit']").removeAttr('disabled');
3094        return false;
3095    });
3096
3097
3098    jQuery(".dig_um_loginviaotp").on('click', function () {
3099        update_time_button = jQuery(this);
3100        var phoneNumber = um_login.find("#username").val();
3101        var csrf = jQuery(".dig_nounce").val();
3102        var countryCode = um_login.find(".dig_wc_logincountrycode").val();
3103        if (phoneNumber == "" || countryCode == "") {
3104            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
3105            return false;
3106        }
3107        var otpin = jQuery(".dig_otp_um_login");
3108
3109
3110        if (!isNumeric(phoneNumber) || !isNumeric(phoneNumber)) {
3111            showDigErrorMessage(dig_mdet.InvalidMobileNumber);
3112            return false;
3113        }
3114
3115        if (subitumotp == 2) {
3116            verifyOtp(countryCode, phoneNumber, csrf, otpin.find("input").val(), 1);
3117            return false;
3118        }
3119        if (isNumeric(phoneNumber)) {
3120
3121            akCallback = 'loginCallback';
3122
3123            subitumotp = 1;
3124            verifyMobileNoLogin(countryCode, phoneNumber, csrf, 1);
3125
3126        } else if (phoneNumber.length > 0) {
3127            showDigNoticeMessage(dig_log_obj.Thisfeaturesonlyworkswithmobilenumber);
3128        } else {
3129            akCallback = 'loginCallback';
3130
3131            verifyMobileNoLogin(countryCode, phoneNumber, csrf);
3132
3133
3134        }
3135        return false;
3136
3137    });
3138
3139    function submitUMRegform(response) {
3140        showDigitsLoader(true);
3141        if (response.status === "PARTIALLY_AUTHENTICATED") {
3142            var code = response.code;
3143            var csrf = response.state;
3144
3145            jQuery("#digits_um_code").val(code);
3146            jQuery("#digits_um_csrf").val(csrf);
3147            submitumform = 1;
3148            jQuery(".um-register").find("form").submit();
3149        }
3150    }
3151
3152    if (jQuery("#dig_reg_mail").length > 0) {
3153        if (jQuery("#reg_email").attr('placeholder') != '' && jQuery("#reg_email").attr('placeholder') != null) {
3154            var fn_pld = jQuery("#reg_billing_first_name");
3155            fn_pld.attr('placeholder', jQuery.trim(fn_pld.parent().find('label').text()));
3156            register.find('.dig-custom-field').each(function () {
3157
3158
3159                var lb = jQuery.trim(jQuery(this).find('label').text());
3160                if (lb) jQuery(this).find('input').attr('placeholder', lb);
3161
3162
3163            });
3164        }
3165    }
3166
3167
3168    function formatMobileNumber(number) {
3169        return number.replace(/^0+/, '');
3170    }
3171
3172
3173    function validateCustomFields(form) {
3174        var error = false;
3175
3176
3177        if (form.attr('wait')) {
3178            showDigNoticeMessage(form.attr('wait'));
3179            return false;
3180        }
3181
3182        if (form.attr('error')) {
3183            showDigErrorMessage(form.attr('error'));
3184            return false;
3185        }
3186
3187
3188        form.find('input,textarea,select').each(function () {
3189            if ((jQuery(this).attr('required') && jQuery(this).is(":visible")) ||
3190                jQuery(this).attr('data-req')) {
3191
3192                var $this = jQuery(this);
3193                var dtype = $this.attr('dtype');
3194
3195                if (dtype && dtype == 'range') {
3196                    var range = $this.val().split('-');
3197                    if (!range[1]) {
3198                        error = true;
3199                        $this.val('');
3200                    }
3201                }
3202                if ($this.attr('date')) {
3203
3204                    if (dtype == 'time') {
3205                        var validTime = $this.val().match(/^(0?[1-9]|1[012])(:[0-5]\d) [APap][mM]$/);
3206                        if (!validTime) {
3207                            error = true;
3208                            $this.val('');
3209                        }
3210                    } else if (dtype != 'range') {
3211                        var date = new Date($this.val());
3212
3213                        if (!isDateValid(date)) {
3214                            error = true;
3215                            $this.val('');
3216
3217                        }
3218                    } else {
3219                        var date1 = new Date(range[0]);
3220                        var date2 = new Date(range[1]);
3221                        if (!isDateValid(date1) || !isDateValid(date2)) {
3222                            error = true;
3223                            $this.val('');
3224
3225                        }
3226                    }
3227                } else if ($this.is(':checkbox') || $this.is(':radio')) {
3228
3229                    if (!$this.is(':checked') && !jQuery('input[name="' + $this.attr('name') + '"]:checked').val()) {
3230                        error = true;
3231                    }
3232                } else {
3233                    var value = $this.val();
3234                    if (value == null || value.length == 0 || (value == -1 && $this.is("select"))) {
3235                        error = true;
3236                        if ($this.is("select"))
3237                            $this.next().addClass('dig_input_error');
3238
3239                        $this.trigger('focus');
3240                    }
3241                }
3242
3243            }
3244
3245        });
3246
3247
3248        if (error) {
3249            showDigNoticeMessage(dig_mdet.fillAllDetails);
3250            return false;
3251        }
3252        if (form.find(".dig_opt_mult_con_tac").find('.dig_input_error').length) {
3253            showDigErrorMessage(dig_mdet.accepttac);
3254            return false;
3255        }
3256
3257        return true;
3258    }
3259
3260
3261    function hideDigitsLoader() {
3262        jQuery('body').addClass('dig_low_overlay');
3263        loader.show();
3264        hideDigMessage();
3265
3266    }
3267
3268    function showDigitsLoader(hideLoader) {
3269        jQuery('body').removeClass('dig_low_overlay');
3270        if (hideLoader) loader.hide();
3271
3272    }
3273
3274    function isDateValid(date) {
3275        return date.getTime() === date.getTime();
3276    }
3277
3278    function isJSON(data) {
3279        if (typeof data != 'string')
3280            data = JSON.stringify(data);
3281
3282        try {
3283            JSON.parse(data);
3284            return true;
3285        } catch (e) {
3286            return false;
3287        }
3288    }
3289
3290    function add_otp_class(status, field) {
3291        if (field == null) return;
3292        var container = field.parent().parent();
3293        container.find('.otp_message').remove();
3294        var read_only = false;
3295
3296        var otp_class;
3297        if (status == 10) {
3298            otp_class = 'checking_otp';
3299        } else if (status == 1) {
3300            read_only = true;
3301            otp_class = 'valid_otp';
3302            container.append('<div class="otp_message otp_valid_message">' + dig_mdet.codevalidproceedcheckout + '</div>');
3303        } else if (status == -1) {
3304            otp_class = '';
3305        } else {
3306            otp_class = 'invalid_otp';
3307        }
3308
3309        field.attr('readonly', read_only);
3310        container.removeClass('valid_otp invalid_otp checking_otp').addClass(otp_class);
3311
3312
3313    }
3314
3315
3316    /*Remove Duplicate Fields*/
3317    var dokan_if_seller = jQuery(".woocommerce-form-register .show_if_seller");
3318    if (dokan_if_seller.length) {
3319        var wc_form = jQuery(".woocommerce-form-register");
3320        if (wc_form.find('#dig_cs_name').length) {
3321            wc_form.find("#first-name").closest('.form-row').remove();
3322        }
3323        if (wc_form.find('#dig_cs_lastname').length) {
3324            wc_form.find("#last-name").closest('.form-row').remove();
3325        }
3326        if (dig_mdet.mobile_accept > 0) {
3327            wc_form.find("#shop-phone").closest('.form-row').remove();
3328        }
3329    }
3330
3331
3332    //next social
3333    setTimeout(function () {
3334        var form = jQuery('.digits_login_form').find('#nsl-custom-login-form-2');
3335        if (form.length) {
3336            form.parent().append(form);
3337        }
3338    }, 500);
3339
3340
3341    if (dig_mdet.secure_forms) {
3342        var wc_login_form = jQuery('.woocommerce-form-login');
3343        if (wc_login_form.length) {
3344            wc_login_form.each(function (index) {
3345                var login_form = jQuery(this);
3346                login_form.find('input[type="password"]').closest('.form-row').remove();
3347                var wc_login_submit = login_form.find('[type="submit"]');
3348                var lost_password = login_form.find('.lost_password');
3349                var last_wc_submit = wc_login_submit.last().closest('.form-row');
3350                lost_password.appendTo(last_wc_submit);
3351                var last_wc_submit_index = last_wc_submit.index() + 1
3352                if (last_wc_submit_index == 0) {
3353                    last_wc_submit_index = 1;
3354                }
3355                login_form.children().slice(0, last_wc_submit_index).wrapAll(secure_wrap);
3356
3357                wc_login_submit.remove();
3358            });
3359        }
3360
3361        var wp_login_form = jQuery(".wp_login");
3362        if (wp_login_form.length) {
3363            wp_login_form.find('input[type="password"]').closest('.user-pass-wrap').remove();
3364            wp_login_form.wrapInner(secure_wrap);
3365            var wp_login_form_section = wp_login_form.find('.form_last_section');
3366            wp_login_form.find('[type="submit"]').remove();
3367            wp_login_form_section.appendTo(wp_login_form);
3368        }
3369
3370        var ihc_secure_login_form = jQuery("#ihc_login_form");
3371        if (ihc_secure_login_form.length) {
3372            ihc_secure_login_form.addClass('digits_form_index_section');
3373            ihc_secure_login_form.find('input[type="password"]').closest('.impu-form-line-fr').remove();
3374            ihc_secure_login_form.find('input').first().nextUntil('.ihc-clear').next().andSelf().wrapAll(secure_wrap);
3375            var ihc_secure_login_form_submit = ihc_secure_login_form.find('.impu-form-submit');
3376            ihc_secure_login_form_submit.empty();
3377            ihc_secure_login_form_submit.append(jQuery('#digits_ihc_form_secure_login').html());
3378            var ihc_secure_login_uname_wrap = ihc_secure_login_form.find('.digcon');
3379            ihc_secure_login_uname_wrap.find('.countrycode').attr('name', 'digt_countrycode');
3380            ihc_secure_login_uname_wrap.find('#iump_login_username').attr('id', 'user_login');
3381            var ihc_captcha = ihc_secure_login_form.find('.digits_captcha_row').first();
3382            ihc_captcha.insertBefore(ihc_secure_login_form.find('.impu-remember-wrapper'));
3383        }
3384
3385        jQuery(document).on('click', '.digits_secure_login-tp', function (e) {
3386            e.preventDefault();
3387            var $this = jQuery(this);
3388            var form = $this.closest('form');
3389            form.removeAttr('action');
3390            var username = form.find('#username');
3391            if (!username.length) {
3392                username = form.find('#user_login');
3393            }
3394            update_login_action_type(form, username);
3395            window.digitsSecureFormSubmit(form);
3396            return false;
3397        })
3398
3399        function update_login_action_type(form, login_user_inp) {
3400            var login_type = 'email';
3401            var update_login_field = 'digits_email';
3402            var login_user = login_user_inp.val();
3403            if (is_mobile(login_user)) {
3404                login_type = 'phone';
3405                update_login_field = 'digits_phone';
3406            }
3407            form.addClass('digits-tp_style');
3408            form.find('[name="action_type"]').val(login_type);
3409            form.find('[name="' + update_login_field + '"]').val(login_user);
3410        }
3411
3412        jQuery(window).trigger('digits_auto_login');
3413    }
3414
3415});
3416
3417function verifyOTPbilling(sen) {
3418    if (sen === 10) {
3419        jQuery(document).trigger('digits_process_wc_checkout');
3420        return;
3421    }
3422    var l;
3423    if (sen == 2) {
3424        l = document.getElementById('dig_billing_signupwithpassword');
3425    } else {
3426        l = document.getElementById('dig_billing_validate_button');
3427    }
3428    l.click();
3429
3430}
3431jQuery(function() {
3432    jQuery(document).ready(function(){
3433        jQuery("#username,#dig-mobmail,.countrycode,#digits_reg_name,#digits_reg_username,#digits_reg_email,#reg_email,.dig-secondmailormobile,#forgotpass,#user_login,#secondmailormobile,.license_key,.mobile,.dig_wc_nw_phone,.mobile_field,input[type='tel']").on("keyup change",function(e){
3434            jQuery(this).val(convert_number.toNormal(jQuery(this).val()));
3435        });
3436    });
3437});

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.