Обратный отсчет FlipClock (глюк)

vave

Полезный
Регистрация
22 Июн 2007
Сообщения
466
Реакции
16
Когда счетчик доходит до нулей, проблем не возникает, но стоит после этого обновить страницу, и я вижу такую вот картину (см вложение)

Вот код скрипта

Код:
    <script>
            $(function(){
                countDown = function(){
                    var currentDate = Math.round(new Date() / 1000);

                    var clock = $('.clock').FlipClock({
                        language: 'ru',
                        countdown: true,
                        callbacks: {
                            init: function() {
                                //store end date If it's not yet in cookies
                                if(!$.cookie('endDate')){
                                    // end date = current date + 1 minutes
                                    var endDate = Date.now() + 197*57*1000;

                                    // store end date in cookies
                                    $.cookie('endDate', Math.round(endDate / 1000));
                                }
                            },
                            interval: function () {
                                var currentDate = Math.round(new Date() / 1000);
                                var time = clock.getTime().time;
                            },
                            stop: function() {
                                $('.message').html('Sale ended!');
                            },
                        }
                    });

                    // counter will be in first 1 min if the user refresh the page the counter will be the difference between current and end Date, so like this counter can continue the countdown normally in case of refresh.
                    var counter = $.cookie('endDate')-currentDate;

                    clock.setTime(counter);
                    clock.setCountdown(true);

                       clock.start();
                   }

                //reset button
                   $('#reset').click(function(){
                    $.removeCookie('endDate'); //removing end date from cookies
                    countDown(); //launch countdown function
                });
               
                //Lanching countDown function on ready
                countDown();
               });
        </script>
 

Вложения

  • Без-имени-2.jpg
    Без-имени-2.jpg
    58,5 KB · Просмотры: 7
Назад
Сверху