Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.06 KB | None | 0 0
  1. <?php if( isset($_SESSION['id_s']) || isset($_SESSION['usuario_s']) ) { ?>
  2. <script>
  3. var chat = {
  4. ult_id: 0,
  5. pos: 'fechado',
  6. enviando: false,
  7. count: false,
  8. carreg: false,
  9. a: function() {
  10. $('.sus_hab').click(function() {
  11. var habb = $(this).attr('id').replace('u_', '');
  12. var atual = $('#texto_chat').val();
  13. $('#texto_chat').val('');
  14. $('#texto_chat').val(':sussurrar '+habb+' '+atual).focus();
  15. });
  16. },
  17. iniciar: function() {
  18. if ($.cookie('chat_pos') == 'aberto') {
  19. $('#chat').css('width', '610px');
  20. $('.button_chat[rel=max]').css('display', 'none');
  21. $('#chat').css('height', '205px');
  22. chat.pos = 'aberto';
  23. }
  24. $('.button_chat').click(function(){
  25. if( chat.carreg == false ) {
  26. chat.carreg = true;
  27.  
  28. if( chat.pos == 'fechado' ) {
  29.  
  30. $('#chat').css('width', '610px');
  31. $('.button_chat[rel=max]').animate({
  32. top: '32px'
  33. }, 200, function() {
  34. $(this).css('display', 'none');
  35. $('#chat').animate({
  36. height: '205px'
  37. }, 200, function() {
  38. chat.pos = 'aberto';
  39. chat.carreg = false;
  40. $.cookie('chat_pos', 'aberto', { path: '/', expires: 7 });
  41. chat.msgs();
  42. });
  43. });
  44.  
  45.  
  46. } else if( chat.pos == 'aberto' ) {
  47.  
  48. $('#chat').animate({
  49. height: '32px'
  50. }, 200, function() {
  51. $('.button_chat[rel=max]').css('display', 'block');
  52. $('.button_chat[rel=max]').animate({
  53. top: '0px'
  54. }, 200, function() {
  55. chat.pos = 'fechado';
  56. $('#chat').css('width', '101px');
  57. chat.carreg = false;
  58. $.cookie('chat_pos', 'fechado', { path: '/', expires: 7 });
  59. });
  60. });
  61.  
  62. }
  63.  
  64. }
  65. });
  66. chat.msgs();
  67. },
  68. msgs: function() {
  69.  
  70.  
  71. if (this.pos == 'aberto') {
  72. $.ajax({
  73. type: 'GET',
  74. url: '<?php echo $siteB;?>scorpionchat/recebe.php',
  75. data: { 'id': chat.ult_id },
  76. dataType: 'json',
  77. cache: false,
  78. success: function (html) {
  79. var texto = '';
  80. if(html[0] == 's') {
  81.  
  82. for( i = 0; i < html[2].length; i++ ) {
  83. if( $('#chat-' + html[2][i][4]).length == 0 ) {
  84. texto += '<div id="chat-' + html[2][i][4] + '" style="width:568px;padding:3px;background:' + html[2][i][3] + ';border-bottom:1px solid #bbb">';
  85. 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>';
  86. texto += '<div style="width:1px;height:21px;border-right:1px solid #666;float:left;margin:4px 3px 0px 3px"></div>';
  87. texto += '<div style="width:438px;float:left;word-wrap:break-word;font-size:11px;color:#333333;max-width:438px">' + html[2][i][2] + '</div>';
  88. texto += '<div class="clear"></div>';
  89. texto += '</div>';
  90. }
  91. }
  92. $('#content_chat').prepend( texto );
  93. chat.ult_id = html[1];
  94.  
  95. }
  96. }
  97. });
  98. }
  99.  
  100. clearTimeout(this.count);
  101. chat.count = setTimeout(function() {
  102. chat.msgs();
  103. }, 3000);
  104. },
  105. form: function() {
  106. $('#form_chat').submit(function() {
  107. clearTimeout(chat.count);
  108. if( chat.enviando == false ) {
  109. chat.enviando = true;
  110. $('#texto_chat').attr('disabled', 'disabled');
  111. var txt = $('#texto_chat').val();
  112. if( txt == '' ) {
  113. chat.enviando = false;
  114. alert('Digite alguma coisa!');
  115. $('#texto_chat').removeAttr('disabled');
  116. } else {
  117.  
  118. $.ajax({
  119. type: 'POST',
  120. url: '<?php echo $siteB;?>scorpionchat/envia.php',
  121. data: { 'texto': txt},
  122. dataType: 'json',
  123. success: function(html) {
  124. if( html.erro == 'n' ) {
  125. $('#texto_chat').val('').focus();
  126. } else {
  127. alert(html.msg);
  128. }
  129. $('#texto_chat').removeAttr('disabled');
  130. chat.enviando = false;
  131. chat.msgs();
  132. }
  133. });
  134.  
  135. }
  136. }
  137. return false;
  138. });
  139. }
  140. }
  141. $(function() {
  142. chat.iniciar();
  143. chat.form();
  144. });
  145. </script>
  146. <div id="chat" style="z-index:99999;width:101px;position:fixed;height:32px;bottom:0px;right:10px;overflow:hidden;">
  147. <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>
  148. <div class="clear"></div>
  149. <div style="width:610px;height:205px;background:url('<?php echo $siteB;?>library/imagens/fundo_chat.png');">
  150. <div style="width:590px;margin:0px auto 4px auto;position:relative;top:10px;">
  151. <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>
  152. <a href="javascript:;" class="button_chat" style="float:right;color:#666666;font-size:10px;" rel="min">Fechar [-]</a>
  153. <div class="clear"></div>
  154. <div style="width:590px;height:3px;background:url('<?php echo $siteB;?>library/imagens/linear_chat.png') no-repeat;margin:2px auto 2px auto"></div>
  155. <div class="clear"></div>
  156. </div>
  157. <div class="clear"></div>
  158. <div id="content_chat" style="width:590px;height:140px;overflow-y:auto;overflow-x:hidden;margin:12px auto 3px auto"></div>
  159. <form action="javascript:;" id="form_chat">
  160. <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;" />
  161. <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;" />
  162. </form>
  163. </div>
  164. </div>
  165. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement