Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/08/2012, 04:34
edie8
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 13 años, 2 meses
Puntos: 10
Respuesta: problemas con un chat

Código Javascript:
Ver original
  1. function checkChatBoxInputKey(event,chatboxtextarea,chatboxtitle,chatid) {
  2.      
  3.     if(event.keyCode == 13 && event.shiftKey == 0)  {
  4.         message = $(chatboxtextarea).val();
  5.         message = message.replace(/^\s+|\s+$/g,"");
  6.  
  7.         $(chatboxtextarea).val('');
  8.         $(chatboxtextarea).focus();
  9.         $(chatboxtextarea).css('height','44px');
  10.         if (message != '') {
  11.             $.post("chat.php?action=sendchat", {to: chatid, message: message} , function(data){
  12.                 message = message.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;");
  13.                 $("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxmessagefrom">'+username+':&nbsp;&nbsp;</span><span class="chatboxmessagecontent">'+message+'</span></div>');
  14.                 $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
  15.             });
  16.         }
  17.         chatHeartbeatTime = minChatHeartbeat;
  18.         chatHeartbeatCount = 1;
  19.  
  20.         return false;
  21.     }
  22.  
  23.     var adjustedHeight = chatboxtextarea.clientHeight;
  24.     var maxHeight = 94;
  25.  
  26.     if (maxHeight > adjustedHeight) {
  27.         adjustedHeight = Math.max(chatboxtextarea.scrollHeight, adjustedHeight);
  28.         if (maxHeight)
  29.             adjustedHeight = Math.min(maxHeight, adjustedHeight);
  30.         if (adjustedHeight > chatboxtextarea.clientHeight)
  31.             $(chatboxtextarea).css('height',adjustedHeight+8 +'px');
  32.     } else {
  33.         $(chatboxtextarea).css('overflow','auto');
  34.     }
  35.      
  36. }
  37.  
  38. function startChatSession(){  
  39.     $.ajax({
  40.       url: "chat.php?action=startchatsession",
  41.       cache: false,
  42.       dataType: "json",
  43.       success: function(data) {
  44.  
  45.         username = data.username;
  46.  
  47.         $.each(data.items, function(i,item){
  48.             if (item)   { // fix strange ie bug
  49.  
  50.                 chatboxtitle = item.f;
  51.  
  52.                 if ($("#chatbox_"+chatboxtitle).length <= 0) {
  53.                     createChatBox(chatid,1);
  54.                 }
  55.                
  56.                 if (item.s == 1) {
  57.                     item.f = username;
  58.                 }
  59.  
  60.                 if (item.s == 2) {
  61.                     $("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxinfo">'+item.m+'</span></div>');
  62.                 } else {
  63.                     $("#chatbox_"+chatboxtitle+" .chatboxcontent").append('<div class="chatboxmessage"><span class="chatboxmessagefrom">'+item.f+':&nbsp;&nbsp;</span><span class="chatboxmessagecontent">'+item.m+'</span></div>');
  64.                 }
  65.             }
  66.         });
  67.        
  68.         for (i=0;i<chatBoxes.length;i++) {
  69.             chatboxtitle = chatBoxes[i];
  70.             $("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
  71.             setTimeout('$("#chatbox_"+chatboxtitle+" .chatboxcontent").scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);', 100); // yet another strange ie bug
  72.         }
  73.    
  74.     setTimeout('chatHeartbeat();',chatHeartbeatTime);
  75.        
  76.     }});
  77. }
  78.  
  79.  
  80. jQuery.cookie = function(name, value, options) {
  81.     if (typeof value != 'undefined') { // name and value given, set cookie
  82.         options = options || {};
  83.         if (value === null) {
  84.             value = '';
  85.             options.expires = -1;
  86.         }
  87.         var expires = '';
  88.         if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  89.             var date;
  90.             if (typeof options.expires == 'number') {
  91.                 date = new Date();
  92.                 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  93.             } else {
  94.                 date = options.expires;
  95.             }
  96.             expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
  97.         }
  98.         var path = options.path ? '; path=' + (options.path) : '';
  99.         var domain = options.domain ? '; domain=' + (options.domain) : '';
  100.         var secure = options.secure ? '; secure' : '';
  101.         document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  102.     } else { // only name given, get cookie
  103.         var cookieValue = null;
  104.         if (document.cookie && document.cookie != '') {
  105.             var cookies = document.cookie.split(';');
  106.             for (var i = 0; i < cookies.length; i++) {
  107.                 var cookie = jQuery.trim(cookies[i]);
  108.                 // Does this cookie string begin with the name we want?
  109.                 if (cookie.substring(0, name.length + 1) == (name + '=')) {
  110.                     cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  111.                     break;
  112.                 }
  113.             }
  114.         }
  115.         return cookieValue;
  116.     }
  117. };
y esta es la continuacion, alguien sabe a que es debido esto??? les agradeceria mucho la ayuda.