Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if( isset($_SESSION['id_s']) || isset($_SESSION['usuario_s']) ) { ?>
- <script>
- var chat = {
- ult_id: 0,
- pos: 'fechado',
- enviando: false,
- count: false,
- carreg: false,
- a: function() {
- $('.sus_hab').click(function() {
- var habb = $(this).attr('id').replace('u_', '');
- var atual = $('#texto_chat').val();
- $('#texto_chat').val('');
- $('#texto_chat').val(':sussurrar '+habb+' '+atual).focus();
- });
- },
- iniciar: function() {
- if ($.cookie('chat_pos') == 'aberto') {
- $('#chat').css('width', '610px');
- $('.button_chat[rel=max]').css('display', 'none');
- $('#chat').css('height', '205px');
- chat.pos = 'aberto';
- }
- $('.button_chat').click(function(){
- if( chat.carreg == false ) {
- chat.carreg = true;
- if( chat.pos == 'fechado' ) {
- $('#chat').css('width', '610px');
- $('.button_chat[rel=max]').animate({
- top: '32px'
- }, 200, function() {
- $(this).css('display', 'none');
- $('#chat').animate({
- height: '205px'
- }, 200, function() {
- chat.pos = 'aberto';
- chat.carreg = false;
- $.cookie('chat_pos', 'aberto', { path: '/', expires: 7 });
- chat.msgs();
- });
- });
- } else if( chat.pos == 'aberto' ) {
- $('#chat').animate({
- height: '32px'
- }, 200, function() {
- $('.button_chat[rel=max]').css('display', 'block');
- $('.button_chat[rel=max]').animate({
- top: '0px'
- }, 200, function() {
- chat.pos = 'fechado';
- $('#chat').css('width', '101px');
- chat.carreg = false;
- $.cookie('chat_pos', 'fechado', { path: '/', expires: 7 });
- });
- });
- }
- }
- });
- chat.msgs();
- },
- msgs: function() {
- if (this.pos == 'aberto') {
- $.ajax({
- type: 'GET',
- url: '<?php echo $siteB;?>scorpionchat/recebe.php',
- data: { 'id': chat.ult_id },
- dataType: 'json',
- cache: false,
- success: function (html) {
- var texto = '';
- if(html[0] == 's') {
- for( i = 0; i < html[2].length; i++ ) {
- if( $('#chat-' + html[2][i][4]).length == 0 ) {
- texto += '<div id="chat-' + html[2][i][4] + '" style="width:568px;padding:3px;background:' + html[2][i][3] + ';border-bottom:1px solid #bbb">';
- texto += '<div style="float:left;"><b style="font-size:10px;color:#333">' + html[2][i][0] + '</b><br><span style="font-size:9px;color:#666666;">' + html[2][i][1] + '</span></div>';
- texto += '<div style="width:1px;height:21px;border-right:1px solid #666;float:left;margin:4px 3px 0px 3px"></div>';
- texto += '<div style="width:438px;float:left;word-wrap:break-word;font-size:11px;color:#333333;max-width:438px">' + html[2][i][2] + '</div>';
- texto += '<div class="clear"></div>';
- texto += '</div>';
- }
- }
- $('#content_chat').prepend( texto );
- chat.ult_id = html[1];
- }
- }
- });
- }
- clearTimeout(this.count);
- chat.count = setTimeout(function() {
- chat.msgs();
- }, 3000);
- },
- form: function() {
- $('#form_chat').submit(function() {
- clearTimeout(chat.count);
- if( chat.enviando == false ) {
- chat.enviando = true;
- $('#texto_chat').attr('disabled', 'disabled');
- var txt = $('#texto_chat').val();
- if( txt == '' ) {
- chat.enviando = false;
- alert('Digite alguma coisa!');
- $('#texto_chat').removeAttr('disabled');
- } else {
- $.ajax({
- type: 'POST',
- url: '<?php echo $siteB;?>scorpionchat/envia.php',
- data: { 'texto': txt},
- dataType: 'json',
- success: function(html) {
- if( html.erro == 'n' ) {
- $('#texto_chat').val('').focus();
- } else {
- alert(html.msg);
- }
- $('#texto_chat').removeAttr('disabled');
- chat.enviando = false;
- chat.msgs();
- }
- });
- }
- }
- return false;
- });
- }
- }
- $(function() {
- chat.iniciar();
- chat.form();
- });
- </script>
- <div id="chat" style="z-index:99999;width:101px;position:fixed;height:32px;bottom:0px;right:10px;overflow:hidden;">
- <div class="button_chat" rel="max" style="position:relative;float:right;width:101px;height:32px;cursor:pointer;opacity:0.9;background:url('<?php echo $siteB;?>library/imagens/chat_min.png') no-repeat;"></div>
- <div class="clear"></div>
- <div style="width:610px;height:205px;background:url('<?php echo $siteB;?>library/imagens/fundo_chat.png');">
- <div style="width:590px;margin:0px auto 4px auto;position:relative;top:10px;">
- <b style="color:#333333;float:left;">Chat Scorpion</b> <span style="float:left;font-size:10px;color:#666666;padding-top:1px;padding-left:10px;">Converse, debata e fa?a novos amigos...</span>
- <a href="javascript:;" class="button_chat" style="float:right;color:#666666;font-size:10px;" rel="min">Fechar [-]</a>
- <div class="clear"></div>
- <div style="width:590px;height:3px;background:url('<?php echo $siteB;?>library/imagens/linear_chat.png') no-repeat;margin:2px auto 2px auto"></div>
- <div class="clear"></div>
- </div>
- <div class="clear"></div>
- <div id="content_chat" style="width:590px;height:140px;overflow-y:auto;overflow-x:hidden;margin:12px auto 3px auto"></div>
- <form action="javascript:;" id="form_chat">
- <input type="text" id="texto_chat" maxlength="125" style="width:470px;font-size:11px;font-family:verdana;color:#555;border:3px solid #ccc;margin-left:9px;" />
- <input type="submit" value="Enviar" style="background:#fff;font-weight:bold;width:85px;font-size:11px;font-family:verdana;color:#555;border:3px solid #ccc;margin-left:9px;" />
- </form>
- </div>
- </div>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement