wollte es so wie hier :
http://wir-wollen-chatten.com/chat_5/
mostlc.class.js
// JavaScript Document
// class: most_little_chat
// Create a little Chat without mySQL or files
// Dixán Santiesteban Feria, CUBA
// email: dixan_sant@yahoo.es
most_little_chat = function(ouser,blogin,ouserlist,omessages,ob_themess,ob_send2){
var onwrite = omessages;
var ob_themess1=ob_themess;
var userlist1=ouserlist;
var messages1=omessages;
var user1=ouser;
var self=this;
var ping=null;
$(document.body).append('<input type="hidden" name="user" id="user"><input type="hidden" name="last" id="last">');
$(ob_send2).click(function(){
self.clicksend();
})
$(blogin).click(function(){
self.send({ action : 'login',
user : $(user1).val()
});
})
this.send = function (data){
$.post('mostlc.php',data, function(recdata){
eval(recdata);
})
}
this.start = function (selfnick,userslist){
$(ob_themess1).val('').attr('disabled',false).focus();
var str='';
$('#user').val(selfnick);
var users=userslist.split(',');
for(var t=0; t<users.length; ++t){
str+='<a id="u_'+users[t]+'"><b>●</b> ';
str+=users[t]+"</a>";
}
$(userlist1).html(str);
ping=setTimeout(function(){self.sendmessage()},5000);
}
this.clicksend = function (){
var msg=$.trim($(ob_themess1).val());
if (msg!='') this.sendmessage(msg);
$(ob_themess1).val('').focus();
}
this.sendmessage = function (msg){
clearTimeout(ping);
this.send({ action : 'ping',
user : $('#user').val(),
last : $('#last').val(),
message : msg
});
ping=setTimeout(function(){self.sendmessage()},5000);
}
this.enter = function (user){
this.writemess('*** entra: <b>'+user+'</b>');
var str='<a id="u_'+user+'"><b>●</b> ';
str+=user+"</a>";
$(userlist1).append(str);
}
this.remove = function (user){
$('#u_'+user).remove();
this.writemess('*** sale: <b>'+user+'</b>');
}
this.writemess = function (txt){
$(onwrite).children().first().before("<p>"+txt+"</p>");
}
this.message = function (user,message){
this.writemess('<b>'+user+': </b>'+message);
}
}
mostlc.php
<?
extract($_POST);
session_id('mostlittlechat');
session_start();
$_SESSION['lastmessage']=!isset($_SESSION['lastmessage'])?0:$_SESSION['lastmessage'];
$_SESSION['msgs']=!isset($_SESSION['msgs'])?array():$_SESSION['msgs'];
$_SESSION['users']=!isset($_SESSION['users'])?array():$_SESSION['users'];
switch($action){
case "login":
$arr=$_SESSION['users'];
foreach($arr as $us){
if ($us==$user) die("alert('user in use');");
}
$listusers = implode(",", $_SESSION['users']);
$last=$_SESSION['lastmessage'];
$ret.="self.start('$user','$listusers');\r\n";
array_push($_SESSION['users'],$user);
addmess("self.enter('$user');");
case "ping":
$_SESSION["$user.time"]=time();
$arr=$_SESSION['users'];
foreach($arr as $us){
if ($_SESSION["$us.time"]<(time()-10)){
removefromusers($us);
addmess("self.remove('$us');\r\n");
}
}
if(isset($message)){
$message=htmlentities($message);
addmess("self.message('$user','$message');");
}
//$last++;
while(intval($last)!=intval($_SESSION['lastmessage'])){
$ret.=$_SESSION['msgs'][$last]."\r\n";
$last++; if ($last>99) $last=0;
}
$ret.="$('#last').val($last);\r\n";
break;
}
echo $ret;
function removefromusers($who){
$ret=array();
$arr=$_SESSION['users'];
foreach($arr as $us){
if ($us!=$who) array_push($ret,$us);
} $_SESSION['users']=$ret;
}
function addmess($msg){
if (count($_SESSION['msgs'])<100) {
array_push($_SESSION['msgs'],$msg);
$_SESSION['lastmessage']=count($_SESSION['msgs']);
} else {
$_SESSION['lastmessage']++;
if ($_SESSION['lastmessage']>99) $_SESSION['lastmessage']=0;
$_SESSION['msgs'][$_SESSION['lastmessage']]=$msg;
}
}
?>
index.html
<script language="javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script language="javascript" src="mostlc.class.js"></script>
<style>
body,TD { font-size:12px; font-family:Georgia, "Times New Roman", Times, serif}
#blockquote_userlist A {display:block;}
#blockquote_userlist B {color:#006600;}
P { margin:0px;}
</style>
<table width="100%" height="100%" border="0">
<tr>
<td width="73%" height="51" valign="middle" bgcolor="#F3F3F3" style="border-right:1px solid #CCCCCC;"><blockquote>
<p>Nachricht:
<input name="ob_themess" type="text" id="ob_themess" value="Please, enter your nickname... --->" size="80" maxlength="200" disabled="disabled" />
<input type="submit" name="ob_send" id="ob_send" value="OK" />
</p>
</blockquote></td>
<td width="27%" rowspan="2" valign="top">
<blockquote id="blockquote_userlist">
<p>Nickname:
<input type="text" name="txuser" id="txuser">
<input type="submit" name="buttonsend" id="buttonsend" value="Eintragen">
</p>
</blockquote>
<label></label></td>
</tr>
<tr>
<td id="ob_allmessages" valign="top" style="border-right:1px solid #CCCCCC;"><p>----------------------------------------------------------------------------------<br />
Willkommen Im Chat Du must dein nickname eingeben um schreiben zu können</p>
</td>
</tr>
</table>
<div title="ventana" id="ventana">
</div>
</body>
<script>
/* #txuser : Login user (text);
#buttonsend : Login submit
#blockquote_userlist : User list (anything object)
#ob_allmessages : zone to write all messages on chat
#ob_themess : text to type words
#ob_send : object to submit the words to chat */
var xx=new most_little_chat('#txuser','#buttonsend','#blockquote_userlist','#ob_allmessages','#ob_themess','#ob_send');
</script>