Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.3 kB
1
Indexable
Never
<script type="text/javascript">
    var target_time = "";
    var countdown_dom_m = "upsell-countdown";
    var countdown_dom_s = "upsell-countdown-s";
    
    var countDownDate = new Date("' . $countdown . '".replace(/-/g,"/")).getTime();
    
    var x;
    
    function updateCountdown() {
        var now = new Date().getTime();
        var distance = countDownDate - now;
        
        if (distance <= 0) {
            clearInterval(x);
            document.cookie = "set_timer_for_upsell=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.getElementById(countdown_dom_m).innerHTML = "0";
            document.getElementById(countdown_dom_s).innerHTML = "0";
        } else {
            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
            
            if (minutes < 10) {
                minutes = "0" + minutes;
            }
            
            if (seconds < 10) {
                seconds = "0" + seconds;
            }
            
            document.getElementById(countdown_dom_m).innerHTML = minutes;
            document.getElementById(countdown_dom_s).innerHTML = seconds;
        }
    }
    
    x = setInterval(updateCountdown, 1000);
</script>