/** * * @package mChat JavaScript Code mini * @version 1.2.6 of 22.05.2009 * @copyright (c) By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/ * @license http://opensource.org/licenses/gpl-license.php GNU Public License * **/ var $jQ=jQuery;if($jQ.cookie('mChatNoSound')=='yes'){$jQ('#mChatUseSound').attr('checked',false)}var mChat={sound:function(file){if($jQ.cookie('mChatNoSound')=='yes'){return}if($jQ.browser.msie){document.getElementById('mChatSound').innerHTML=''}else{$jQ('#mChatSound').html('')}},toggle:function(id){$jQ('#mChat'+id).slideToggle('fast',function(){if($jQ('#mChat'+id).is(':visible')){$jQ.cookie('mChatShow'+id,'yes')}if($jQ('#mChat'+id).is(':hidden')){$jQ.cookie('mChatShow'+id,null)}})},add:function(){if($jQ('#mChatMessage').val()==''){alert(mChatNoMessageInput);return}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:$jQ('#mChatForm').serialize(),dataType:'text',success:function(){$jQ('#mChatMessage').val('');mChat.refresh()},error:function(XMLHttpRequest){if(XMLHttpRequest.status==400){alert(mChatFlood)}else if(XMLHttpRequest.status==403){alert(mChatNoAccess)}else if(XMLHttpRequest.status==501){alert(mChatNoMessageInput)}},beforeSend:function(){window.clearInterval(interval)},complete:function(){interval=setInterval(function(){mChat.refresh()},mChatRefresh)}})},edit:function(id){var message=$jQ('#edit'+id).val();var data=prompt(mChatEditInfo,message);if(data){$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:true,data:{mode:'edit',message_id:id,message:data},dataType:'text',success:function(html){$jQ('#mess'+id).fadeOut('slow',function(){$jQ(this).replaceWith(html);$jQ('#mess'+id).css('display','none').fadeIn('slow')})},error:function(XMLHttpRequest){if(XMLHttpRequest.status==403){alert(mChatNoAccess)}else if(XMLHttpRequest.status==501){alert(mChatNoMessageInput)}},beforeSend:function(){window.clearInterval(interval)},complete:function(){interval=setInterval(function(){mChat.refresh()},mChatRefresh)}})}},del:function(id){if(confirm(mChatDelConfirm)){$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:true,data:{mode:'delete',message_id:id},success:function(){$jQ('#mess'+id).fadeOut('slow',function(){$jQ(this).remove()});mChat.sound(mChatForumRoot+'mchat/del.swf')},error:function(){alert(mChatNoAccess)},beforeSend:function(){window.clearInterval(interval)},complete:function(){interval=setInterval(function(){mChat.refresh()},mChatRefresh)}})}},refresh:function(){if(mChatArchiveMode){if($jQ('#mChatData').find('div:first').not('#mChatArchiveNoMessage').not('#mChatNoMessage').attr('id')==undefined){$jQ('#mChatArchiveNoMessage').show('slow')}return}var mess_id=0;if($jQ('#mChatData').find('div:first').not('#mChatNoMessage').attr('id')!=undefined){mess_id=$jQ('#mChatData').find('div:first').attr('id').replace('mess','')}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:true,data:{mode:'read',message_last_id:mess_id},dataType:'html',beforeSend:function(){$jQ('#mChatLoadIMG').show();$jQ('#mChatOkIMG').hide();$jQ('#mChatErrorIMG').hide()},success:function(html){if(html!=''){$jQ('#mChatData').prepend(html).find('div:first').not('#mChatNoMessage').css('display','none');$jQ('#mChatData div:first').not('#mChatNoMessage').fadeIn('slow');mChat.sound(mChatForumRoot+'mchat/add.swf');$jQ('#mChatNoMessage').hide()}setTimeout(function(){$jQ('#mChatLoadIMG').hide();$jQ('#mChatOkIMG').show();$jQ('#mChatErrorIMG').hide()},1000)},error:function(){$jQ('#mChatLoadIMG').hide();$jQ('#mChatOkIMG').hide();$jQ('#mChatErrorIMG').show();mChat.sound(mChatForumRoot+'mchat/error.swf')},complete:function(){if($jQ('#mChatData').find('div:first').not('#mChatNoMessage').attr('id')==undefined){$jQ('#mChatNoMessage').show('slow')}}})}};var interval=setInterval(function(){mChat.refresh()},mChatRefresh);if($jQ.cookie('mChatShowSmiles')=='yes'){$jQ('#mChatSmiles:hidden').slideToggle('slow')}if($jQ.cookie('mChatShowBBCodes')=='yes'){$jQ('#mChatBBCodes:hidden').slideToggle('slow')}$jQ('#mChatUseSound').change(function(){if($jQ(this).is(':checked')){$jQ.cookie('mChatNoSound',null)}else{$jQ.cookie('mChatNoSound','yes')}});