Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function skl(a, n) {
- return a[n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2];
- }
- var mdays = Array(31, new Date().getFullYear() % 4 == 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), tmp = 0, last_sec = 0, last_min = 0, last_hour = 0, last_day = 0, last_mon = 0, last_year = 0;
- setInterval(function() {
- var data = new Date(), years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
- years = 0;
- months = 0;
- days = data.getDate() > 5 ? data.getHours() > 3 ? data.getDate() - 6 : data.getDate() - 5 : data.getDate() + mdays[data.getMonth() == 0 ? 11 : data.getMonth() - 1] - 6;
- hours = data.getHours() > 3 ? data.getHours() - 4 : data.getHours() + 20;
- minutes = data.getMinutes();
- seconds = data.getSeconds();
- if (!tmp) {
- last_sec = seconds;
- last_min = minutes;
- last_hour = hours;
- last_day = days;
- last_mon = months;
- last_year = years;
- tmp++
- }
- if (years != 0) {
- if (last_year != years)
- $("#years").fadeToggle(200);
- setTimeout(function() {
- $("#years").html(years + ' ' + skl(Array('год', 'года', 'лет'), years))
- }, last_year != years ? 200 : 0);
- $("#years").stop().fadeIn(200)
- } else
- $("#years").fadeOut().html(" ")
- if (months != 0) {
- if (last_mon != months)
- $("#months").fadeToggle(200);
- setTimeout(function() {
- $("#months").html(months + ' месяц' + skl(Array('', 'а', 'ев'), months))
- }, last_mon != months ? 200 : 0);
- $("#months").fadeIn(200)
- } else
- $("#months").stop().fadeOut().html(" ")
- if (days != 0) {
- if (last_day != days)
- $("#days").fadeToggle(200);
- setTimeout(function() {
- $("#days").html(days + ' д' + skl(Array('ень', 'ня', 'ней'), days))
- }, last_day != days ? 200 : 0);
- $("#days").fadeIn(200)
- } else
- $("#days").stop().fadeOut().html(" ")
- if (hours != 0) {
- if (last_hour != hours)
- $("#hours").fadeToggle(200);
- setTimeout(function() {
- $("#hours").html(hours + ' час' + skl(Array('', 'а', 'ов'), hours))
- }, last_hour != hours ? 200 : 0);
- $("#hours").fadeIn(200)
- } else
- $("#hours").stop().fadeOut().html(" ")
- if (minutes != 0) {
- if (last_min != minutes)
- $("#minutes").fadeToggle(200);
- setTimeout(function() {
- $("#minutes").html(minutes + ' минут' + skl(Array('у', 'ы', ''), minutes))
- }, last_min != minutes ? 200 : 0);
- $("#minutes").fadeIn(200)
- } else
- $("#minutes").stop().fadeOut().html(" ")
- if (seconds != 0) {
- if (last_sec != seconds)
- $("#seconds").fadeToggle(200);
- setTimeout(function() {
- $("#seconds").html(seconds + ' секунд' + skl(Array('у', 'ы', ''), seconds))
- }, last_sec != seconds ? 200 : 0);
- $("#seconds").fadeIn(200)
- } else
- $("#seconds").stop().fadeOut().html(" ")
- $('body').stop().animate({backgroundSize: '100%'}, 100).delay(100).animate({backgroundSize: '100.5%'}, 100)
- last_sec = seconds;
- last_min = minutes;
- last_hour = hours;
- last_day = days;
- last_mon = months;
- last_year = years
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement