Advertisement
AndreyKlipikov

Project Loving. Beta 1.1

Jan 10th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 3.33 KB | None | 0 0
  1.             function skl(a, n) {
  2.                 return a[n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2];
  3.             }
  4.            
  5.             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;
  6.             setInterval(function() {
  7.                 var data = new Date(), years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0;
  8.                 years = 0;
  9.                 months = 0;
  10.                
  11.                 days = data.getDate() > 5 ? data.getHours() > 3 ? data.getDate() - 6 : data.getDate() - 5 : data.getDate() + mdays[data.getMonth() == 0 ? 11 : data.getMonth() - 1] - 6;
  12.                 hours = data.getHours() > 3 ? data.getHours() - 4 : data.getHours() + 20;
  13.                 minutes = data.getMinutes();
  14.                 seconds = data.getSeconds();
  15.                
  16.                 if (!tmp) {
  17.                     last_sec = seconds;
  18.                     last_min = minutes;
  19.                     last_hour = hours;
  20.                     last_day = days;
  21.                     last_mon = months;
  22.                     last_year = years;
  23.                     tmp++
  24.                 }
  25.                
  26.                 if (years != 0) {
  27.                     if (last_year != years)
  28.                         $("#years").fadeToggle(200);
  29.                     setTimeout(function() {
  30.                         $("#years").html(years + ' ' + skl(Array('год', 'года', 'лет'), years))
  31.                     }, last_year != years ? 200 : 0);
  32.                     $("#years").stop().fadeIn(200)
  33.                 } else
  34.                     $("#years").fadeOut().html("&nbsp;")
  35.                
  36.                 if (months != 0) {
  37.                     if (last_mon != months)
  38.                         $("#months").fadeToggle(200);
  39.                     setTimeout(function() {
  40.                         $("#months").html(months + ' месяц' + skl(Array('', 'а', 'ев'), months))
  41.                     }, last_mon != months ? 200 : 0);
  42.                     $("#months").fadeIn(200)
  43.                 } else
  44.                     $("#months").stop().fadeOut().html("&nbsp;")
  45.                
  46.                 if (days != 0) {
  47.                     if (last_day != days)
  48.                         $("#days").fadeToggle(200);
  49.                     setTimeout(function() {
  50.                         $("#days").html(days + ' д' + skl(Array('ень', 'ня', 'ней'), days))
  51.                     }, last_day != days ? 200 : 0);
  52.                     $("#days").fadeIn(200)
  53.                 } else
  54.                     $("#days").stop().fadeOut().html("&nbsp;")
  55.                
  56.                 if (hours != 0) {
  57.                     if (last_hour != hours)
  58.                         $("#hours").fadeToggle(200);
  59.                     setTimeout(function() {
  60.                         $("#hours").html(hours + ' час' + skl(Array('', 'а', 'ов'), hours))
  61.                     }, last_hour != hours ? 200 : 0);
  62.                     $("#hours").fadeIn(200)
  63.                 } else
  64.                     $("#hours").stop().fadeOut().html("&nbsp;")
  65.                
  66.                 if (minutes != 0) {
  67.                     if (last_min != minutes)
  68.                         $("#minutes").fadeToggle(200);
  69.                     setTimeout(function() {
  70.                         $("#minutes").html(minutes + ' минут' + skl(Array('у', 'ы', ''), minutes))
  71.                     }, last_min != minutes ? 200 : 0);
  72.                     $("#minutes").fadeIn(200)
  73.                 } else
  74.                     $("#minutes").stop().fadeOut().html("&nbsp;")
  75.                
  76.                 if (seconds != 0) {
  77.                     if (last_sec != seconds)
  78.                         $("#seconds").fadeToggle(200);
  79.                     setTimeout(function() {
  80.                         $("#seconds").html(seconds + ' секунд' + skl(Array('у', 'ы', ''), seconds))
  81.                     }, last_sec != seconds ? 200 : 0);
  82.                     $("#seconds").fadeIn(200)
  83.                 } else
  84.                     $("#seconds").stop().fadeOut().html("&nbsp;")
  85.                
  86.                 $('body').stop().animate({backgroundSize: '100%'}, 100).delay(100).animate({backgroundSize: '100.5%'}, 100)
  87.                
  88.                 last_sec = seconds;
  89.                 last_min = minutes;
  90.                 last_hour = hours;
  91.                 last_day = days;
  92.                 last_mon = months;
  93.                 last_year = years
  94.             }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement