Jump to content
Sign in to follow this  


Recommended Posts


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:



 <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() {


     // 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) {  
     // 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); 

                   } else {

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



 <!-- 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;

<body onload="setInterval('chat.update()', 1000)">
 <div id="main">
     <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>
       <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>
             <li><a href="#">1</a></li>
             <li><a href="#">2</a>
                 <li><a href="#">3</a></li>
                 <li><a href="#">4</a></li>
                 <li><a href="#">5</a></li>
             <li><a href="#">6</a></li>
             <li><a href="#">7</a></li>
             <li><a href="#">8</a></li>
         <li class="selected"><a href="">Chat</a></li>
         <li><a href="contactos.html">Contactos</a></li>

       <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>

 <!-- 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() {
       max : 600,
       spacing : 2

Edited by anolsi
Adição do Geshi

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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.