Главная » Файлы » Скрипты для uCoz » Пользователи |
Оповещение о новых сообщениях на форуме как ВКонтакте для uCoz
24.06.14, 09:31:03 | |
На днях решил написать такой скрипт... Извиняюсь если похожее уже есть. Скрипт требует подключения API (ПУ > Настройки > Общие настройки > Использовать API). Там же включаем версию jQuery 1.6, если она еще не включена. Установка: 1. Вставляем в CSS сайта Код .NotifyBox{position:fixed;bottom:5px;right:5px;z-index:9999;display:none;} .NotifyBoxMessage{background:none repeat scroll 0 0 rgba(0, 0, 0, 0.75);border-radius:5px;moz-border-radius:5px;webkit-border-radius:5px;box-shadow:0 2px 15px #000;moz-box-shadow:0 2px 15px #000;webkit-box-shadow:0 2px 15px #000;color:#FFF;cursor:pointer;text-shadow:0 1px 0 #262626;width:320px;font-family:tahoma,arial,verdana,sans-serif,Lucida Sans;font-size:11px;margin-bottom:5px;overflow:hidden;padding:7px;} .NotifyBoxClose{background:#000;display:none;border-radius:3px;moz-border-radius:3px;webkit-border-radius:3px;box-shadow:0 0 2px #111;moz-box-shadow:0 0 2px #111;webkit-box-shadow:0 0 2px #111;padding:5px;margin:3px 3px 0 15px;width:7px;float:right;} .NotifyBoxCloseLink{display:block;background:url("/images/notifier_close.gif") no-repeat scroll 0 0 transparent;width:7px;height:7px;} .NotifyTitle{font-size:12px;font-weight:bold;margin-bottom:8px;margin-top:3px;margin-left:3px;} .NotifyAvatar{border-radius:3px;moz-border-radius:3px;webkit-border-radius:3px;box-shadow:0 1px 2px #111111;moz-box-shadow:0 1px 2px #111111;webkit-box-shadow:0 1px 2px #111111;line-height:0;overflow:hidden;} .NotifyAvatar img{width:50px;max-height:50px;} .NotifyText{margin-left:6px;margin-top:1px;} 2. Переходим в Вид материалов форума и заменяем $MESSAGE$ на Код <span class="ForumPost">$MESSAGE$</span> 3. Переходим в Нижнюю часть сайта и вставляем в самый низ Код <div class="NotifyBox"><div class="NotifyBoxMessage"><span class="NotifyBoxClose"><span class="NotifyBoxCloseLink"></span></span><div class="NotifyTitle">Новое оповещение</div><table><tr><td valign="top"><div class="NotifyAvatar"></div></td><td valign="top"><div class="NotifyText">Обновлена тема <b><span id="NotTitle">загрузка..</span></b>.<br>Пост оставил <b><span id="NotUser">загрузка..</span></b>.<br>Сообщение: <span id="NotPost">загрузка..</span></div></td></tr></table></div></div> <script>$(function() { var ForumApi = $.ajax({type: 'GET', url: '/api/forum/0-0-1-34', dataType: 'xml', async: false}).responseText; var fla = $(ForumApi).find('member:contains("TOPIC_NAME")').first().find('string').text(); var flb = $(ForumApi).find('member:contains("REPLIES_NUM")').first().find('i4').text(); setInterval(function() { var ForumApiNew = $.ajax({type: 'GET', url: '/api/forum/0-0-1-34', dataType: 'xml', async: false}).responseText; var ForumTitle = $(ForumApiNew).find('member:contains("TOPIC_NAME")').first().find('string').text(); var ForumCount = $(ForumApiNew).find('member:contains("REPLIES_NUM")').first().find('i4').text(); if (!(ForumTitle == fla && ForumCount == flb)) { $('#NotTitle').html(ForumTitle); var ForumUser = $(ForumApiNew).find('member:contains("LASTPOST_AUTHOR")').first().find('string').text(); $('#NotUser').html(ForumUser); var ForumPost = $(ForumApiNew).find('member:contains("LASTPOST_LINK")').first().find('string').text(); $('#NotPost').load(ForumPost+' .ForumPost:last'); var AvatarApi = $.ajax({type: 'GET', url: '/api/index/8-0-'+ForumUser, dataType: 'xml', async: false}).responseText; var ForumAvatar = $(AvatarApi).find('member:contains("USER_AVATAR")').find('string').text(); if (ForumAvatar.length) {$('.NotifyAvatar').html('<img src="'+ForumAvatar+'">');} else {$('.NotifyAvatar').html('<img src="/images/noavatar.png">');} $('.NotifyBox').animate({height:'toggle',opacity:'toggle'}, 400).delay(10000).animate({height:'toggle',opacity:'toggle'}, 400); $('#player').remove(); $('body').append('<embed id="player" type="application/x-shockwave-flash" src="http://s45.ucoz.net/flash/audio1.swf?song_url=/alert.mp3&autoplay=1&loop=0" width="0" height="0" hidden="true">'); fla = ForumTitle; flb = ForumCount; };}, 30000);}); $('.NotifyBoxClose').click(function(){$('.NotifyBox').css('display', 'none')}); $('.NotifyBoxMessage').hover(function(){$('.NotifyBoxClose').fadeIn(100)},function(){$('.NotifyBoxClose').fadeOut(100)}); </script> 4. Заливаем на сайт файлы из архива, сораняя структуру. Готово. Скрипт не обладает какими-либо плюшками и настройками, просто уведомлялка и ничего больше Автор - collapse | |
Просмотров: 403 | Загрузок: 0 | |
Всего комментариев: 0 | |
| |