Jump to content
Sign in to follow this  
michaelcarvalho

CHAT AJAX

Recommended Posts

michaelcarvalho

Boa tarde, estou a desenvolver um chat em ajax e ja tenho tudo operacional, so me falta a barra de status de quem está online na minha sala, alguem me pode ajudar ?

o código do meu chat é este:

<!DOCTYPE HTML>
<html>

<head>

 <title>-michaelcarvalho.</title>
 <meta name="description" content="website description" />
 <meta name="keywords" content="website keywords, website keywords" />
 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
 <link rel="stylesheet" type="text/css" href="css/style.css" />
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 



 <link rel="stylesheet" href="style.css" type="text/css" />    
 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script type="text/javascript" src="chat.js"></script>
 <script type="text/javascript">

       // ask user for name with popup prompt    
       var name = prompt("Introduza o seu nome:", "Anonimo");

       // default name is 'Guest'
    if (!name || name === ' ') {
       name = "Guest"; 
    }

    // strip tags
    name = name.replace(/(<([^>]+)>)/ig,"");

    // display name on page
    $("#name-area").html("You are: <span>" + name + "</span>");

    // kick off chat
       var chat =  new Chat();
    $(function() {

     chat.getState(); 

     // watch textarea for key presses
            $("#sendie").keydown(function(event) {  

                var key = event.which;  

                //all keys including return.  
                if (key >= 33) {

                    var maxLength = $(this).attr("maxlength");  
                    var length = this.value.length;  

                    // don't allow new content if length is maxed out
                    if (length >= maxLength) {  
                        event.preventDefault();  
                    }  
                 }  
      });
     // watch textarea for release of key press
     $('#sendie').keyup(function(e) { 

      if (e.keyCode == 13) { 

                   var text = $(this).val();
    var maxLength = $(this).attr("maxlength");  
                   var length = text.length; 

                   // send 
                   if (length <= maxLength + 1) { 

            chat.send(text, name); 
            $(this).val("");

                   } else {

    $(this).val(text.substring(0, maxLength));

    } 


      }
            });

    });
   </script>
 <!-- modernizr enables HTML5 elements and feature detects -->
 <script type="text/javascript" src="js/modernizr-1.5.min.js"></script>
 <style type="text/css">
<!--
.style2 {color: #0ED4DE}
.style6 {font-size: 10px}
.style7 {
font-weight: bold;
font-size: 36px;
}
-->
 </style>
</head>

<body onload="setInterval('chat.update()', 1000)">
 <div id="main">
   <header>
     <div id="logo">
       <div id="logo_text">
         <!-- class="logo_colour", allows you to change the colour of the text -->
         <h1><a href="index.html" class="style7"><span class="style2">m</span>ichael<span class="style2">c</span>arvalho<span class="style2">.</span></a></h1>

         <p align="center" class="style6">Victor Michael Ferreira Carvalho</p>
       </div>
     </div>
     <nav>
       <ul class="sf-menu" id="nav">
         <li><a href="index.html">Home</a></li>
         <li><a href="sobre.html">Sobre</a></li>
         <li><a href="hobbies.html">Hobbies</a></li>
         <li><a href="cv1.html">Curriculum Vitae</a></li>

         <li><a href="#">Portfólio</a>
           <ul>
             <li><a href="#">1</a></li>
             <li><a href="#">2</a>
               <ul>
                 <li><a href="#">3</a></li>
                 <li><a href="#">4</a></li>
                 <li><a href="#">5</a></li>
               </ul>
             </li>
             <li><a href="#">6</a></li>
             <li><a href="#">7</a></li>
             <li><a href="#">8</a></li>
           </ul>
         </li>
         <li class="selected"><a href="">Chat</a></li>
         <li><a href="contactos.html">Contactos</a></li>
       </ul>
     </nav>
   </header>
      <h2>Chat</h2>

       <p id="name-area"></p>

       <div id="chat-wrap"><div id="chat-area"></div></div>

       <form id="send-message-area">
           <p>Digite a sua mensagem: </p>
           <textarea id="sendie" maxlength = '100' ><textarea>
       </form>

   </div>
 <!-- javascript at the bottom for fast page loading -->
 <script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery.easing-sooper.js"></script>
 <script type="text/javascript" src="js/jquery.sooperfish.js"></script>
 <script type="text/javascript" src="js/jquery.kwicks-1.5.1.js"></script>
 <script type="text/javascript">
   $(document).ready(function() {
     $('#images').kwicks({
       max : 600,
       spacing : 2
     });
     $('ul.sf-menu').sooperfish();
   });
 </script>
</body>
</html>

Edited by anolsi
Adição do Geshi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.