помогите запустить таймер! [требует правки]

258
23 января 2017, 20:51
/* Adding blocks, transform blocks, only for correct display */
$(document).ready(function() {  
    var prefix = $('.prefix').val();
    var url = prefix+"respond.php";

    $('.button').click(function() {
        $('body').find('form:not(this)').children('label').removeClass('red');
        var request_url = '\n'+$('input[name="ref_url"]').val().toString().replace(/&/g, '\n');
        var utm_source = $('input[name="ref_url"]').val().match(/(?:utm_source=)(.*)(?:&utm_medium)/i);
        var utm_medium = $('input[name="ref_url"]').val().match(/(?:utm_medium=)(.*)(?:&utm_campaign)/i);
        var utm_campaign = $('input[name="ref_url"]').val().match(/(?:utm_campaign=)(.*)(?:&utm_term)/i);
        var utm_term = $('input[name="ref_url"]').val().match(/(?:utm_term=)([0-9a-zA-ZĐồ-ứỐĐỒ-Đố%]{1,})/i);
        if(utm_source == null || utm_medium == null || utm_campaign == null || utm_term == null)
            var utms = '';
        else
            var utms = '\nutm_source='+utm_source[1]+'\nutm_medium='+utm_medium[1]+'\nutm_campaign='+utm_campaign[1]+'\nutm_term='+utm_term[1]+'\n';
        var answer = checkForm($(this).parent().get(0));
        if(answer != false)
        {
            var $form = $(this).parent(),
                name = $('input[name="name"]', $form).val(),
                phone = $('input[name="phone"]', $form).val()+' '+$('input[name="phone2"]', $form).val()+' '+$('input[name="phone3"]', $form).val(),
                email = $('input[name="email"]', $form).val(),
        usluga = $('input[name="usluga"]', $form).val(),
        referer = $('input[name="referer"]', $form).val(),
        phrase = $('input[name="phrase"]', $form).val(),
        ccall = $('input[name="ccall"]', $form).val(),
                ques = $('textarea[name="ques"]', $form).val(),
                sbt = $('input[type="button"]', $form).attr("name"),
                submit = $('input[name='+sbt+']', $form).val();
            var ref = $('input[name="referer"]').val();
            var ref = ref+'\nutm-ĐỬĐộứẰĐỨĐị:'+request_url;
            var formname = $('input[name="formname"]').val();
            $.ajax({
                type: "POST",
                url: url,
                dataType: "json",
                data: "name="+name+"&usluga="+usluga+"&referer="+referer+"&phrase="+phrase+"&ccall="+ccall+"&phone="+phone+"&"+sbt+"="+submit+"&email="+email+"&ques="+ques+"&formname="+formname+"&ref="+ref
            }).always(function() {
                //ĐỬĐộứẰứẠĐịĐỨĐị
                //ga('send', 'event', ''+sbt, ''+sbt, ''+sbt);
                thx();
            });
        }
    });
    /* Youtube fix */
    $("iframe").each(function() {
        var ifr_source=$(this).attr('src');
        var wmode="wmode=transparent";
        if(ifr_source.indexOf('?')!=-1) {
            var getQString=ifr_source.split('?');
            var oldString=getQString[1];
            var newString=getQString[0];
            $(this).attr('src',newString+'?'+wmode+'&'+oldString)
        } else $(this).attr('src',ifr_source+'?'+wmode)
    });
    var set_slide = function(selector, slide) {
        $(selector).text(slide);
    }
    var time = new Date();
    var target_time = new Date(time.getFullYear(), time.getMonth(), time.getDate());
    target_time = target_time.valueOf()+1000*60*60*24;
    var tick = function(init) {
        if (init == undefined) {
            init = false;
        }
        var current_time = new Date();
        current_time = current_time.valueOf();
        if (current_time > target_time) {
            var time = new Date();
            .getFullYear = new Date(time.getFullYear('2017'), time.getMonth('03'), time.getDate('01/03/2017'));
            target_time = target_time.valueOf()+1000*60*60*24;          
        }
        var time_diff = Math.floor((target_time - current_time)/1000);  
        var second_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
        var second_1 = time_diff % 6; time_diff = Math.floor(time_diff/6);
        var minute_2 = time_diff % 10; time_diff = Math.floor(time_diff/10);
        var minute_1 = time_diff % 6; time_diff = Math.floor(time_diff/6);
        var hour_2 = Math.floor(time_diff/10);
        var hour_1 = time_diff % 10;
        set_slide('span.secondPlay', second_2);
        if ((second_2 == 9) || init) {set_slide('span.second6Play', second_1);
        if ((second_1 == 5) || init) {set_slide('span.minutePlay', minute_2);
        if ((minute_2 == 9) || init) {set_slide('span.minute6Play', minute_1);
        if ((minute_1 == 5) || init) {set_slide('span.hourPlay', hour_1);
        if ((hour_2 == 9) || init) {set_slide('span.hour2Play', hour_2);}}}}}
      }
    tick(true);
    setInterval(tick, 1000);
    if(null === navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad|android)/)){
        // ĐơĐịĐờĐộ ĐỗứẮứẰĐồĐỗĐỪứỐĐộĐỬ ĐỨĐớĐƠ, ĐỨĐớứẰĐớứẠứỀĐỰ ĐŨĐỚ ĐỔĐặĐỢĐỚĐằ ĐÕĐỒĐỔĐỤĐằĐỒĐằĐể ĐơĐồ iphone|ipod|ipad|android
        $('head').append('<link rel="stylesheet" href="../css/animations.css" />');
        $('.scroll-animate').each(function () {
            var block = $(this);
            $(window).scroll(function() {
                var top = block.offset().top;
                var bottom = block.height()+top;
                top = top - $(window).height() + 200;
                var scroll_top = $(this).scrollTop();
                if ((scroll_top > top) && (scroll_top < bottom)) {
                    if (!block.hasClass('animate')) {
                        block.addClass('animate');
                        block.trigger('animateIn');
                    }
                } else {
                    block.removeClass('animate');
                    block.trigger('animateOut');
                }
            }); 
        });
        $('.counts, .why, .reviews_block1, .faq_col').on('animateIn', function() {
            var inter = 0;
            $(this).find('.animation').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInDown');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.animation').each(function() {
                $(this).removeClass('fadeInDown');
            });
        });

        $('.pr1, .pr3, .pr5, .pr7, .pr9, .pr11, .pr13').on('animateIn', function() {
            var inter = 0;
            $(this).find('.animation').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInLeft');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.animation').each(function() {
                $(this).removeClass('fadeInLeft');
            });
        });

        $('.pr2, .pr4, .pr6, .pr8, .pr10, .pr12, .pr14').on('animateIn', function() {
            var inter = 0;
            $(this).find('.animation').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInRight');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.animation').each(function() {
                $(this).removeClass('fadeInRight');
            });
        });
        $('.problems, .s2, .s4, .w1, .w2, .w3, .reviews_block2').on('animateIn', function() {
            var inter = 0;
            $(this).find('.animation').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInLeft');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.animation').each(function() {
                $(this).removeClass('fadeInLeft');
            });
        });
        $('.s1, .s3').on('animateIn', function() {
            var inter = 0;
            $(this).find('.animation').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInRight');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.animation').each(function() {
                $(this).removeClass('fadeInRight');
            });
        });
        $('.hww').on('animateIn', function() {
            var inter = 0;
            $(this).find('.hww_one').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.css('opacity', 1);
                    block.css('transform', 'scale(1.0, 1.0)');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.hww_one').each(function() {
                $(this).css('opacity', 0.01);
                $(this).css('transform', 'scale(0.5, 0.5)');
            });
        });
        $('.hww').on('animateIn', function() {
            var inter = 0;
            $(this).find('.hww_line').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.css('opacity', 1);
                }, inter*300);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.hww_line').each(function() {
                $(this).css('opacity', 0.01);
            });
        });
        $('.contacts').on('animateIn', function() {
            var inter = 0;
            $(this).find('.contacts_map').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInLeft');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.contacts_map').each(function() {
                $(this).removeClass('fadeInLeft');
            });
        });
        $('.contacts').on('animateIn', function() {
            var inter = 0;
            $(this).find('.contacts_block').each(function() {
                var block = $(this);
                setTimeout(function() {
                    block.addClass('fadeInDown');
                }, inter*200);
                inter++;
            });
        }).on('animateOut', function() {
            $(this).find('.contacts_block').each(function() {
                $(this).removeClass('fadeInDown');
            });
        });
    }
if(null !== navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad|android)/)){ 
    }
});

$(function() {
        if ($('.top_menu').length > 0) {
            $('.top_menu').css('z-index', 9);
            var menu = $('.top_menu').offset().top;
            $(window).scroll(function() {
                if ($(this).scrollTop() > menu) {
                    if ($('.top_menu').css('position') != 'fixed') {
                        $('.top_menu').css({
                            'position': 'fixed',
                            'top': '0px'
                        });
                    }
                } else {
                    if ($('.top_menu').css('position') != 'static') {
                        $('.top_menu').css({
                            'position': 'static'
                        });
                    }
                }
            });
        }
    });

$(window).resize(function(){
    var Mtop = -($('.activePopup').outerHeight() / 2) + 'px';
    var Mleft = -($('.activePopup').outerWidth() / 2) + 'px';
    $('.activePopup').css({
        'margin-top' : Mtop,
        'margin-left' : Mleft,
        'left' : '50%',
        'top' : '50%'
    });
});
function popup(id, form, h1, h2, btn) { //onClick="popup('callback', '', '', '', '');"
    $('.popup_overlay').fadeIn(150);
    $('#'+id).addClass('activePopup');
    var Mtop = -($('.activePopup').outerHeight() / 2) + 'px';
    var Mleft = -($('.activePopup').outerWidth() / 2) + 'px';
    $('.activePopup').css({
        'margin-top' : Mtop,
        'margin-left' : Mleft,
        'left' : '50%',
        'top' : '50%'
    });
    if(h1 != '') {$('#'+id).find('.popup_h1').html(h1);}
    if(h2 != '') {$('#'+id).find('.popup_h2').html(h2);}
    if(btn != '') {$('#'+id).find('input[type="button"]').attr("value", btn);}
    $('.activePopup').fadeIn(150);
    $('.formname').attr("value", form);
}
function work_popup(src, h1) {
    $('.popup_overlay').fadeIn(150);
    $('.work_popup').addClass('activePopup');
    var Mtop = -($('.activePopup').outerHeight() / 2) + 'px';
    var Mleft = -($('.activePopup').outerWidth() / 2) + 'px';
    $('.activePopup').css({
        'margin-top' : Mtop,
        'margin-left' : Mleft,
        'left' : '50%',
        'top' : '50%'
    });
    if(h1 != '') {$('.work_popup').find('.popup_h1').html(h1);}
    $('.activePopup').fadeIn(150);
    $('.work_popup.activePopup').find('img').attr('src', src);
    $('.work_popup .work_img_cntnr').animate({scrollTop: 0}, 0);
}
function popup_out() {
    $('.popup_overlay').fadeOut(150);
    $('.work_popup').fadeOut(150);
    $('.work_popup').removeClass('activePopup');
    $('.popup').fadeOut(150);
    $('.popup').removeClass('activePopup');
    $('input[type="text"]').each(function(){
        $(this).val('');
    });
    $('input[name="phone"]').each(function(){
        $(this).val('+7');
    });
    $('textarea').val('');
    $('body').find('label').removeClass('red');
}
function formname(name) { //onClick="formname('text');"
    $('.formname').attr("value", name);
}
function thx() {
    $('.popup').hide();
    $('.popup').removeClass('activePopup');
    popup('thx', '');
    $('input[type="text"]').each(function(){
        $(this).val('');
    });
    $('textarea').val('');
}
function scrollTo(id) {
    var to = $('#'+id).offset().top - 41;
    $("html, body").animate({scrollTop: to}, 500);
}
READ ALSO
Изменение языка в input type date

Изменение языка в input type date

Здравствуйте! Есть input[type="date"], проблема в том, что при отсутствии изначально установленного value, поле отображается на русском языке:

1039
Когда input заполнен

Когда input заполнен

Добавить класс к label, когда его input заполнен

386