Зацикленный таймер обратного отсчета
Здравствуйте. Помогите чайнику...установил на сайт таймер обратного отсчета, но он умеет только отсчитать до указанной даты и останавливается, а надо что бы отсчитал 7 дней и начал считать по новому кругу...
Если поставить дату не указывая месяц либо число, таймер обновляется при каждом обновлении страницы... $(function(){ var note = $('#note'), ts = new Date(2013,0, 8), newYear = true; if((new Date()) > ts){ // The new year is here! Count towards something else. // Notice the *1000 at the end - time must be in milliseconds ts = (new Date()).getTime() + 10*24*60*60*1000; newYear = false; } $('#countdown').countdown({ timestamp : ts, callback : function(days, hours, minutes, seconds){ var message = ""; message += days + " day" + ( days==1 ? '':'s' ) + ", "; message += hours + " hour" + ( hours==1 ? '':'s' ) + ", "; message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />"; if(newYear){ message += "left until the new year!"; } else { message += "left to 10 days from now!"; } note.html(message); } }); }); Заранее спасибо!!! |
Цитата:
найди циферку 6 в коде и поменяй на 7 :cray: :cray: :cray: ... чего они там все считают переодически ... ? |
Цитата:
|
Зациклить таймер.
Добрый день. Использую вот этот таймер:
<style> #bigtimerblacklabels { width: 460px; margin: 0 auto; } #clock-ticker { display: block; margin-bottom: 15px;} #clock-ticker .block { position: relative; color: #fff; font-weight: bold; float: left; margin-right: 22px; } #clock-ticker .block .flip-top { width: 88px; height: 39px; line-height: 75px; font-size: 55px; background: url('img/flip-top.png') no-repeat; text-align: center; } #clock-ticker .block .flip-btm { width: 88px; height: 40px; background: url('img/flip-btm.png') no-repeat; text-align: center; } #clock-ticker .block .label { color: #000; font-weight: bold; font-size: 14px; text-transform: uppercase; width: 88px; line-height: 35px; text-align: center; font-family: "Calibri", Arial, sans-serif;} </style> <div id="bigtimerblacklabels"> <div id="clock-ticker" class="clearfix"> <div class="block"> <span class="flip-top" id="numdays">8</span> <span class="flip-btm"></span> <footer class="label">Дней</footer> </div> <div class="block"> <span class="flip-top" id="numhours">14</span> <span class="flip-btm"></span> <footer class="label">Часов</footer> </div> <div class="block"> <span class="flip-top" id="nummins">34</span> <span class="flip-btm"></span> <footer class="label">Мин</footer> </div> <div class="block"> <span class="flip-top" id="numsecs">9</span> <span class="flip-btm"></span> <footer class="label">Сек</footer> </div> </div> </div> <script type="text/javascript"> $(document).ready(function(){ var theDaysBox = $("#numdays"); var theHoursBox = $("#numhours"); var theMinsBox = $("#nummins"); var theSecsBox = $("#numsecs"); var refreshId = setInterval(function() { var currentSeconds = theSecsBox.text(); var currentMins = theMinsBox.text(); var currentHours = theHoursBox.text(); var currentDays = theDaysBox.text(); if(currentSeconds == 0 && currentMins == 0 && currentHours == 0 && currentDays == 0) { // if everything rusn out our timer is done!! // do some exciting code in here when your countdown timer finishes } else if(currentSeconds == 0 && currentMins == 0 && currentHours == 0) { // if the seconds and minutes and hours run out we subtract 1 day theDaysBox.html(currentDays-1); theHoursBox.html("23"); theMinsBox.html("59"); theSecsBox.html("59"); } else if(currentSeconds == 0 && currentMins == 0) { // if the seconds and minutes run out we need to subtract 1 hour theHoursBox.html(currentHours-1); theMinsBox.html("59"); theSecsBox.html("59"); } else if(currentSeconds == 0) { // if the seconds run out we need to subtract 1 minute theMinsBox.html(currentMins-1); theSecsBox.html("59"); } else { theSecsBox.html(currentSeconds-1); } }, 1000); }); </script> В ручную выставляю в нем дни часы минуты. Подскажите пожалуйста как его зациклить. Мне нужно выставить 24 часа и, чтобы когда они пройдут таймер снова сбросился на ноль и начал по новой отсчет. Реально ли это сделать? Заранее спасибо. |
Могу посоветовать вот этот таймер для сайта. У него есть такая функция - перезапуск таймера каждую неделю. Сам ей всегда пользуюсь для лэндингов.
|
giv13,
Цитата:
|
BETEPAH, Что мне это даст? Скажите, пожалуйста, я новичок на форуме. Просто как бы выставляешь на критику?
|
Часовой пояс GMT +3, время: 09:42. |