Rommax
Проверенные
- Сообщения
- 1,342
- Реакции
- 502
- Баллы
- 28,615
Приветствую. Нужна помощь ( Понимаю что тема не связанна с форумом но идти куда то на левый сайт не хочется так как привязан к вам.
Нашел шаблон (заглушку) с обратным отсчетом (до такого то события осталось стока то времени)
Помогите сделать чтобы не в убыль время шло а прибавляло.
вот содержимое js файла countdown.js
Если кто разбирается и может помочь скину ссылку в лс на саму заглушку.
Нашел шаблон (заглушку) с обратным отсчетом (до такого то события осталось стока то времени)
Помогите сделать чтобы не в убыль время шло а прибавляло.
вот содержимое js файла countdown.js
Код:
(function($) {
$.fn.countdown = function(options, callback) {
//custom 'this' selector
var thisEl = $(this);
//array of custom settings
var settings = {
'date': null,
'format': null
};
//append the settings array to options
if(options) {
$.extend(settings, options);
}
//main countdown function
function countdown_proc() {
var eventDate = Date.parse(settings['date']) / 1000;
var currentDate = Math.floor($.now() / 1000);
if(eventDate <= currentDate) {
callback.call(this);
clearInterval(interval);
}
var seconds = eventDate - currentDate;
var days = Math.floor(seconds / (60 * 60 * 24)); //calculate the number of days
seconds -= days * 60 * 60 * 24; //update the seconds variable with no. of days removed
var hours = Math.floor(seconds / (60 * 60));
seconds -= hours * 60 * 60; //update the seconds variable with no. of hours removed
var minutes = Math.floor(seconds / 60);
seconds -= minutes * 60; //update the seconds variable with no. of minutes removed
//conditional Ss
if (days == 1) { thisEl.find(".timeRefDays").text("дней"); } else { thisEl.find(".timeRefDays").text("дней"); }
if (hours == 1) { thisEl.find(".timeRefHours").text("часа"); } else { thisEl.find(".timeRefHours").text("часа"); }
if (minutes == 1) { thisEl.find(".timeRefMinutes").text("минут"); } else { thisEl.find(".timeRefMinutes").text("минут"); }
if (seconds == 1) { thisEl.find(".timeRefSeconds").text("секунд"); } else { thisEl.find(".timeRefSeconds").text("секунд"); }
//logic for the two_digits ON setting
if(settings['format'] == "on") {
days = (String(days).length >= 2) ? days : "0" + days;
hours = (String(hours).length >= 2) ? hours : "0" + hours;
minutes = (String(minutes).length >= 2) ? minutes : "0" + minutes;
seconds = (String(seconds).length >= 2) ? seconds : "0" + seconds;
}
//update the countdown's html values.
if(!isNaN(eventDate)) {
thisEl.find(".days").text(days);
thisEl.find(".hours").text(hours);
thisEl.find(".minutes").text(minutes);
thisEl.find(".seconds").text(seconds);
} else {
alert("Invalid date. Here's an example: 12 Tuesday 2012 17:30:00");
clearInterval(interval);
}
}
//run the function
countdown_proc();
//loop the function
interval = setInterval(countdown_proc, 1000);
}
}) (jQuery);
Если кто разбирается и может помочь скину ссылку в лс на саму заглушку.