Форум программистов, компьютерный форум, киберфорум
jQuery
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
2 / 2 / 0
Регистрация: 18.12.2014
Сообщений: 103
1

Как настроить счетчик обратного отсчета

27.07.2016, 13:59. Показов 1031. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Здравствуйте помогите с счетчиком обратного отсчета. Задача в том, чтобы каждые сутки в 00:00 счетчик вновь показывал 2 дней 00 часов 00 минут 00 секунд.

Кликните здесь для просмотра всего текста
Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    $('#countdown_dashboard').countDown({
                        targetOffset: {
                            'day':      1,
                            'month':    0,
                            'year':     0,
                            'hour':     7,
                            'min':      58,
                            'sec':      15  }
                    });
                $('#countdown_dashboardd').countDown({
                        targetOffset: {
                            'day':      1,
                            'month':    0,
                            'year':     0,
                            'hour':     7,
                            'min':      58,
                            'sec':      15  }
                    });
            });


Кликните здесь для просмотра всего текста
Javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*!
 * jQuery Countdown plugin v0.9.5
 * [url]http://www.littlewebthings.com/projects/countdown/[/url]
 *
 * Copyright 2010, Vassilis Dourdounis
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
(function($){
 
    $.fn.countDown = function (options) {
 
        config = {};
 
        $.extend(config, options);
 
        diffSecs = this.setCountDown(config);
 
        $('#' + $(this).attr('id') + ' .digit').html('<div class="top"></div><div class="bottom"></div>');
        $(this).doCountDown($(this).attr('id'), diffSecs, 500);
 
        if (config.onComplete)
        {
            $.data($(this)[0], 'callback', config.onComplete);
        }
        if (config.omitWeeks)
        {
            $.data($(this)[0], 'omitWeeks', config.omitWeeks);
        }
        return this;
 
    };
 
    $.fn.stopCountDown = function () {
        clearTimeout($.data(this[0], 'timer'));
    };
 
    $.fn.startCountDown = function () {
        this.doCountDown($(this).attr('id'),$.data(this[0], 'diffSecs'), 500);
    };
 
    $.fn.setCountDown = function (options) {
        var targetTime = new Date();
 
        if (options.targetDate)
        {
            targetTime.setDate(options.targetDate.day);
            targetTime.setMonth(options.targetDate.month-1);
            targetTime.setFullYear(options.targetDate.year);
            targetTime.setHours(options.targetDate.hour);
            targetTime.setMinutes(options.targetDate.min);
            targetTime.setSeconds(options.targetDate.sec);
        }
        else if (options.targetOffset)
        {
            targetTime.setDate(options.targetOffset.day + targetTime.getDate());
            targetTime.setMonth(options.targetOffset.month + targetTime.getMonth());
            targetTime.setFullYear(options.targetOffset.year + targetTime.getFullYear());
            targetTime.setHours(options.targetOffset.hour + targetTime.getHours());
            targetTime.setMinutes(options.targetOffset.min + targetTime.getMinutes());
            targetTime.setSeconds(options.targetOffset.sec + targetTime.getSeconds());
        }
 
        var nowTime = new Date();
 
        diffSecs = Math.floor((targetTime.valueOf()-nowTime.valueOf())/1000);
 
        $.data(this[0], 'diffSecs', diffSecs);
 
        return diffSecs;
    };
 
    $.fn.doCountDown = function (id, diffSecs, duration) {
        $this = $('#' + id);
        if (diffSecs <= 0)
        {
            diffSecs = 0;
            if ($.data($this[0], 'timer'))
            {
                clearTimeout($.data($this[0], 'timer'));
            }
        }
 
        secs = diffSecs % 60;
        mins = Math.floor(diffSecs/60)%60;
        hours = Math.floor(diffSecs/60/60)%24;
        if ($.data($this[0], 'omitWeeks') == true)
        {
            days = Math.floor(diffSecs/60/60/24);
            weeks = Math.floor(diffSecs/60/60/24/7);
        }
        else 
        {
            days = Math.floor(diffSecs/60/60/24)%7;
            weeks = Math.floor(diffSecs/60/60/24/7);
        }
 
        $this.dashChangeTo(id, 'seconds_dash', secs, duration ? duration : 800);
        $this.dashChangeTo(id, 'minutes_dash', mins, duration ? duration : 1200);
        $this.dashChangeTo(id, 'hours_dash', hours, duration ? duration : 1200);
        $this.dashChangeTo(id, 'days_dash', days, duration ? duration : 1200);
        $this.dashChangeTo(id, 'weeks_dash', weeks, duration ? duration : 1200);
 
        $.data($this[0], 'diffSecs', diffSecs);
        if (diffSecs > 0)
        {
            e = $this;
            t = setTimeout(function() { e.doCountDown(id, diffSecs-1) } , 1000);
            $.data(e[0], 'timer', t);
        } 
        else if (cb = $.data($this[0], 'callback')) 
        {
            $.data($this[0], 'callback')();
        }
 
    };
 
    $.fn.dashChangeTo = function(id, dash, n, duration) {
        $this = $('#' + id);
        d2 = n%10;
        d1 = (n - n%10) / 10
 
        if ($('#' + $this.attr('id') + ' .' + dash))
        {
            $this.digitChangeTo('#' + $this.attr('id') + ' .' + dash + ' .digit:first', d1, duration);
            $this.digitChangeTo('#' + $this.attr('id') + ' .' + dash + ' .digit:last', d2, duration);
        }
    };
 
    $.fn.digitChangeTo = function (digit, n, duration) {
        if (!duration)
        {
            duration = 800;
        }
        if ($(digit + ' div.top').html() != n + '')
        {
 
            $(digit + ' div.top').css({'display': 'none'});
            $(digit + ' div.top').html((n ? n : '0')).slideDown(duration);
 
            $(digit + ' div.bottom').animate({'height': ''}, duration, function() {
                $(digit + ' div.bottom').html($(digit + ' div.top').html());
                $(digit + ' div.bottom').css({'display': 'block', 'height': ''});
                $(digit + ' div.top').hide().slideUp(10);
 
            
            });
        }
    };
 
})(jQuery);
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
27.07.2016, 13:59
Ответы с готовыми решениями:

Таймер обратного отсчета, как поменять дату ?
Будьте добры, покажите пожалуйста, где в таймере обратного отсчета времени поменять конечную дату ?...

Как изменить время в таймере обратного отсчета?
Доброго времени суток! Таймер начинает обратный отсчет после обновления страницы с 1 часа: 59...

Таймер обратного отсчёта
У меня возникла проблема с реализацией работы таймера. Во-первых, у меня не получается...

Таймер обратного отсчета
Доброго времени суток, хочу сделать что-то вроде таймера. Есть число 10000 и 100, и хочу чтоб был...

0
27.07.2016, 13:59
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
27.07.2016, 13:59
Помогаю со студенческими работами здесь

Таймер обратного отсчета
Подскажите что нужно дописать, что таймер автоматом каждые сутки в 00:00 добавлял время+1 день и...

Таймер обратного отсчета
Здравствуйте. Делаю таймер, использую плагин ФлипКоунт. Вопрос: что нужно вставить в переменную t,...

Цикл таймера обратного отсчета
Привет, друзья! Помогите зациклить таймер обратного отсчета. Сейчас счетчик выставляется вручную...

Циклический скрипт обратного отсчета
Доброго времени суток. Есть вот такой скрипт обратного отсчета до нового года: &lt;script&gt; ...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru