ANTICHAT.XYZ    VIDEO.ANTICHAT.XYZ    НОВЫЕ СООБЩЕНИЯ    ФОРУМ  
Баннер 1   Баннер 2
Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей. Здесь обсуждаются безопасность, программирование, технологии и многое другое. Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz
Вернуться   Форум АНТИЧАТ > Программирование > PHP, PERL, MySQL, JavaScript
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #11  
Старый 27.05.2008, 05:02
Аватар для astrologer
astrologer
Постоянный
Регистрация: 30.08.2007
Сообщений: 773
Провел на форуме:
3069349

Репутация: 808


По умолчанию

Код:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<style type="text/css">

#countbox
{
  font-family: "Lucida Grande", Calibri, Georgia, Verdana;
}

#countbox .unit
{
  margin-left: 3px;
  font-size: 80%;
}

</style>

<script type="text/javascript">

var Countdown =
{
  timer: null,
  init: function(id, until)
  {
    Countdown.node  = document.getElementById(id);
    Countdown.update(until);
    Countdown.timer = setInterval(function()
    {
      Countdown.update(until);
    }, 1000);
  },

  stop: function()
  {
    clearInterval(Countdown.timer);
    return true;
  },
  
  update: function(until)
  {
    var s = Countdown.process(new Date(), until);
    Countdown.node.innerHTML = s || Countdown.stop() && 'Всё :)';
  },
  
  difference: function(before, after)
  {
    if (after < before) return false;

    var
    days   = after.getDate()  - before.getDate(),
    months = after.getMonth() - before.getMonth(),
    years  = after.getYear()  - before.getYear(),
    hms    = (after / 1000 - before / 1000) % 86400,
    
    seconds = Math.floor(hms % 60),
    minutes = Math.floor(hms/60) % 60,
    hours   = Math.floor(hms/3600) % 60,

    date = new Date();

    if (days < 0)
    {
      date.setFullYear(before.getYear(), before.getMonth(), 32);
      days += 32 - date.getDate();
      months--;
    }

    if (months < 0)
    {
      months += 12;
      years--;
    }

    return {
      years:   years,
      months:  months,
      days:    days,
      
      hours:   hours,
      minutes: minutes,
      seconds: seconds
    };
  },

  process: function(before, after)
  {
    var diff = null, a = [], i = '';
    if(!(diff = Countdown.difference(before, after))) return false;

    for(i in diff)
    {
      if(!diff[i]) continue;
      a.push('<span class="num">'
              + diff[i] +
             '</span><span class="unit">'
              + Countdown.lang[i][Countdown.lang.choose( diff[i] )] +
             '</span>');
    }

    return a.join(' ');
  },

  lang:
  {
    years:   ['год', 'года', 'лет'],
    months:  ['месяц', 'месяца', 'месяцев'],
    days:    ['день', 'дня', 'дней'],
    hours:   ['час', 'часа', 'часов'],
    minutes: ['минута', 'минуты', 'минут'],
    seconds: ['секунда', 'секунды', 'секунд'],
    choose:  function(n)
    {
      var m = n % 100, i = 2;
      if(m < 5 || 20 < m)
      {
        if((m %= 10) === 1)
        {
          i = 0;
        }
        else if(1 < m && m < 5)
        {
          i = 1;
        }
      }
      return i; 
    }
  }
};

window.onload = function()
{
  Countdown.init('countbox', new Date(2010, 7, 29, 0, 0, 30));
};

</script>
</head>
<body>

<span id="countbox"></span>

</body>
</html>
 
Ответить с цитированием

  #12  
Старый 27.05.2008, 10:10
Аватар для IIAHbI4
IIAHbI4
Banned
Регистрация: 24.08.2006
Сообщений: 483
Провел на форуме:
3895065

Репутация: 1112
Отправить сообщение для IIAHbI4 с помощью ICQ
По умолчанию

Цитата:
Сообщение от astrologer  
Код:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<style type="text/css">

#countbox
{
  font-family: "Lucida Grande", Calibri, Georgia, Verdana;
}

#countbox .unit
{
  margin-left: 3px;
  font-size: 80%;
}

</style>

<script type="text/javascript">

var Countdown =
{
  timer: null,
  init: function(id, until)
  {
    Countdown.node  = document.getElementById(id);
    Countdown.update(until);
    Countdown.timer = setInterval(function()
    {
      Countdown.update(until);
    }, 1000);
  },

  stop: function()
  {
    clearInterval(Countdown.timer);
    return true;
  },
  
  update: function(until)
  {
    var s = Countdown.process(new Date(), until);
    Countdown.node.innerHTML = s || Countdown.stop() && 'Всё :)';
  },
  
  difference: function(before, after)
  {
    if (after < before) return false;

    var
    days   = after.getDate()  - before.getDate(),
    months = after.getMonth() - before.getMonth(),
    years  = after.getYear()  - before.getYear(),
    hms    = (after / 1000 - before / 1000) % 86400,
    
    seconds = Math.floor(hms % 60),
    minutes = Math.floor(hms/60) % 60,
    hours   = Math.floor(hms/3600) % 60,

    date = new Date();

    if (days < 0)
    {
      date.setFullYear(before.getYear(), before.getMonth(), 32);
      days += 32 - date.getDate();
      months--;
    }

    if (months < 0)
    {
      months += 12;
      years--;
    }

    return {
      years:   years,
      months:  months,
      days:    days,
      
      hours:   hours,
      minutes: minutes,
      seconds: seconds
    };
  },

  process: function(before, after)
  {
    var diff = null, a = [], i = '';
    if(!(diff = Countdown.difference(before, after))) return false;

    for(i in diff)
    {
      if(!diff[i]) continue;
      a.push('<span class="num">'
              + diff[i] +
             '</span><span class="unit">'
              + Countdown.lang[i][Countdown.lang.choose( diff[i] )] +
             '</span>');
    }

    return a.join(' ');
  },

  lang:
  {
    years:   ['год', 'года', 'лет'],
    months:  ['месяц', 'месяца', 'месяцев'],
    days:    ['день', 'дня', 'дней'],
    hours:   ['час', 'часа', 'часов'],
    minutes: ['минута', 'минуты', 'минут'],
    seconds: ['секунда', 'секунды', 'секунд'],
    choose:  function(n)
    {
      var m = n % 100, i = 2;
      if(m < 5 || 20 < m)
      {
        if((m %= 10) === 1)
        {
          i = 0;
        }
        else if(1 < m && m < 5)
        {
          i = 1;
        }
      }
      return i; 
    }
  }
};

window.onload = function()
{
  Countdown.init('countbox', new Date(2010, 7, 29, 0, 0, 30));
};

</script>
</head>
<body>

<span id="countbox"></span>

</body>
</html>
ты ближе всех к истине, я ещё немного переделал, но твёрдая пятёрка, это точно!
 
Ответить с цитированием
Ответ



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
цвет в формат Rgb SSB1981 PHP, PERL, MySQL, JavaScript 6 20.01.2008 15:57
Взлом чата через цвет.. Чаты 0 26.10.2003 17:15



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT.XYZ