Главная » Файлы » Скрипты для uCoz » Комментарии

Автообновление комментариев by Apocalypse для uCoz
24.06.14, 14:23:12





Скрипт разработан по просьбе пользователя Bilbao111

Топик с обсуждением ЗДЕСЬ

Временное демо ЗДЕСЬ

У скрипта три режима: Автообновление, ручное обновление и быстрая проверка на новые комментарии с выводом ответа

Установка:

В Виде материалов комментариев в самый верх:
Код
<div id="apoucomments" apotms="$TIMESTAMP$">
Здесь же в виде материалов в самый низ:
Код
</div>


В форму добавления комментариев в самый низ:
Код
<script>  
  // ApoTeam (c) 2013  
  var apocominterval;  
  $('div#apoucomments:first').before('<input class="apoButtons" style="margin-right:2px;" type="button" value="Проверить комментарии" onclick="aporefcomments()" /> <input class="apoButtons" style="margin-right:2px;" type="button" value="Обновить комментарии" onclick="apofullrefcomments()" /><br><br>');  

  // Функция простой проверки на наличие новых комментариев  
  function aporefcomments(s) {  
  $('div#apoucomments').stop().fadeTo(300, 0.6);  
  $.get(location.href, function(apogt) {  
  var apolastcom = $('#apoucomments:first').attr('apotms');  
  $('div#apoucomments').stop().fadeTo(300, 1);  
  if(apolastcom == $('#apoucomments:first', apogt).attr('apotms')) {  
  if(!s) {  
  _uWnd.alert('Нет новых комментариев', 'Увы', {w:250, h:70});  
  };  
  } else {  
  apofullrefcomments();  
  if(!s) {  
  _uWnd.alert('Подгружены новые комментарии', 'Уау!', {w:250, h:70});  
  };  
  }  
  });  
  }  

  // Задаём интервал автообновления в 60 секунд  
  apocominterval = setInterval(function() {  
  aporefcomments('s');  
  }, 60000);  

  // Функция полной подгрузки  
  function apofullrefcomments() {  
  clearInterval(apocominterval);  
  apocominterval = setInterval(function() {  
  aporefcomments('s');  
  }, 30000);  
  $('#allEntries').stop().fadeTo(300, 0.6);  
  setTimeout(function() {  
  $.get(location.href, function(apogt) {  
  $('#allEntries').html($('#allEntries', apogt).html()).stop().fadeTo(300, 1);  
  $('div#apoucomments:first').before('<input class="apoButtons" style="margin-right:2px;" type="button" value="Проверить комментарии" onclick="aporefcomments()" /> <input class="apoButtons" style="margin-right:2px;" type="button" value="Обновить комментарии" onclick="apofullrefcomments()" /><br><br>');  
  });  
  }, 1000);  
  }  

  // Модифицированная функция добавления комментариев  
  function addcom(f){  
  if (document.getElementById('addcBut')){document.getElementById('addcBut').disabled=true;}else {try{document.addform.submit.disabled=true;}catch(e){}}if (document.getElementById('eMessage')){document.getElementById('eMessage').innerHTML='<span style="color:#8B8B8B"><img src="http://s36.ucoz.net/img/ma/m/i2.gif" border="0" align="absmiddle" width="13" height="13"> Идет передача данных...</span>';}  
  if($('#apodop1').val().length > 4) {  
  $('.commFl').val($('.commFl').val() + '\n[url=' + $('#apodop1').val() + ']' + $('#apodop1').val() + '[/url]')  
  }  
  _uPostForm('acform',{type:'POST',url:'/index/', success:apofullrefcomments()});  
  }  

  // apo-ucoz.com (c) 2013  
  </script>  

  <style>  
  #newEntryB {  
  display:none;  
  }  

  .apoButtons {  
  transition: all 1s;  
  -moz-transition: all 1s; /* Firefox 4 */  
  -webkit-transition: all 1s; /* Safari and Chrome */  
  -o-transition: all 1s; /* Opera */  
  background: white;  
  border: none;  
  border-bottom: 1px solid #CCC;  
  border-right: 1px solid #CCC;  
  }  

  .apoButtons:hover {  
  background:#eee;  
  }  

  .apoButtons:active {  
  background:#ddd;  
  border-bottom: 1px solid #BBB;  
  border-right: 1px solid #BBB;  
  }  
  </style>

Категория: Комментарии | Добавил: Apocalypse | Теги: Apocalypse, ucoz, by, комментариев, Автообновление, для
Просмотров: 592 | Загрузок: 0 | Рейтинг: 0.0/0
Всего комментариев: 0
Имя *:
Email: