<?php
include 'checkUser.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>????棰???妗?lt;/title>
<style>
#chatContent{
width:500px;
height:300px;
background-color:#FFFF99;
text-align:left;
overflow:scroll;
}
table{
margin:auto auto;
background-color:#999999;
}
td,tr{
border:#CC0000 1px solid;
text-align:center;
}
#send_btn{
width:65px;
height:65px;
color:#0000FF;
}
#sp{font-size:14px;}
</style>
<script language="javascript" type="text/javascript" src="include/ajaxUtil.js"></script>
<script language="javascript" type="text/javascript" src="include/fckeditorUtil.js"></script>
<script language="javascript" type="text/javascript">
//?????ㄦ?瘋?寸????瀹?
function sendMsg(){
var url="sendMsg.php";
var content=getEditorHtmlContents("content",true);
var params="nr="+encodeURI(content)+"&lis="+encodeURI($$('onlineuser').value)+"&name="+"<?php echo $_SESSION["username"];?>";
get(url,params,processSendMsg);
}
function processSendMsg(xhr){
if(xhr.responseText){
SetEditorContents("content","");
}else{
alert("????澶辮觸锛?");
}
}
var maxid=0;
//?峰????瀹癸?骞朵??劇ず?烘??
function getContent(){
var url="getContent.php";
var params="maxid="+maxid;
get(url,params,processGetContent);
}
function processGetContent(xhr){
//??json?煎???瀛?绗?覆杞???涓哄?矽薄
var obj=eval("("+xhr.responseText+")");
//???烘????????澶╀俊??
var rows=obj.Msgs;
//???烘???ㄧ?ㄦ?蜂俊??
var users=obj.Users;
//--------------------?劇ず?ㄧ嚎?ㄦ??--------------------
//?峰???ㄧ嚎?ㄦ?風??select??瀵矽薄
var sel=$$("onlineuser");
//娓?绌哄?ㄧ嚎涓?娆℃?ヨ?㈠?ㄧ嚎淇℃??
sel.options.length=0;
for(var m=0;m<users.length;m++){
//浜х??涓?涓???椤?
var op=new Option(users[m].username+"@"+users[m].theip,users[m].id);
//????椤規坊???闆?ㄧ嚎?ㄦ?峰??琛ㄤ腑
sel.options.add(op);
}
//-----------------------?劇ず??澶╀俊??------------
var conStr=$$("chatContent").innerHTML;
//var conStr="";
for(var i=0;i<rows.length;i++){
conStr+=" "+rows[i].speaker+"["+rows[i].theip+"] ??amp;nbsp;"+rows[i].create_time+" 璇達?</span><br> "+rows[i].content+"<br>";
maxid=parseInt(rows[i].id);
}
//????澶х??id?艱??肩?maxid
//maxid=rows[i].id;
//灏???瀹規?劇ず??iv涓?
$$("chatContent").innerHTML=conStr;
//$$("chatContent").scrollTop=$$("chatContent").scrollHeight;
}
setInterval("getContent()",2000);
</script>
</head>
<body>
<table width="300" >
<caption>ajax+json+php+js+dom+mysql瀹??拌??澶╁??lt;br></caption>
? <tr>
? ? <td>娆㈣? <?php echo $_SESSION['username']; ?>锛?杩??ヨ??澶╁??lt;/td>
? ? <td>?ㄧ嚎?ㄦ?峰??琛?lt;/td>
? </tr>
? <tr>
? ? <td><div id="chatContent"></div></td>
? ? <td><select id="onlineuser" size="20" style="width:150px;">
<option>????浜?lt;/option>
</select>
</td>
? </tr>
? <tr>
? ? <td> </td>
? ? <td> </td>
? </tr>
? <tr>
? ? <td><?php?
//寮???CKeditor.php杩?涓???浠訛??烘????绫誨???版??缁????藉?ㄨ???
include ("fckeditor/fckeditor.php");
//??寤?CKeditor瀵矽薄??瀹?渚???myFCKeditor?蟲??浜ゅ??锛??ユ?舵?版??椤甸??_POST['myFCKeditor']浣跨??
$FCKeditor = new FCKeditor("content");
//FCKeditor???ㄧ??浣?缃?锛?杩???瀹???浣?缃?灏辨??'FCKeditor' ??浠跺す
$FCKeditor -> BasePath='./fckeditor/';
//宸ュ?鋒????璁劇疆
$FCKeditor -> ToolbarSet="ChatEditor";
//璁劇疆瀹???瀹藉害
$FCKeditor -> Width='500px';
//璁劇疆瀹???楂?搴?
$FCKeditor -> Height='120px';
$FCKeditor ->InstanceName ="content";
//????
$FCKeditor -> Create();
?></td>
? ? <td><input type="button" value="????" id="send_btn" 慰nclick="sendMsg()" /></td>
? </tr>
</table>
</body>
</html>