ดูโค้ดห้องแชทให้หน่อยครับ
<!--{block return}-->
<!-- SiamDiscuz Shoutbox v0.1 -->
<style type="text/css">
#um p {text-align:right !important; float:none}
#sdc_chat{background-color:{$cf[bordercolor]}; border-collapse:inherit}
#sdc_chat b.img img{ height:16px; vertical-align:text-bottom}
#sdc_chat b.img2 img{ height:38px; width:38px; vertical-align:text-bottom; float:left; margin:2px 5px 2px 0px}
#sdc_chat td{background-color:{$cf[bgcolor]}}
#sdc_chat a b{font-weight:normal}
#ch,#nl{padding:3px;background-color: $cf[bgcolor];font:10px;height: {$cf[height]}px;overflow:auto;}
#nl{background-color: $cf[nickcolor];}
#ch div{min-height:20px; line-height:20px;}
#ch i{cursor:pointer; font-style:normal}
#ch div{clear:both}
#cbmessage { width: 100%;margin-top: 1px; font-size:14px; height:20px; line-height:20px; border:1px inset {$cf[bordercolor]};background-color: $cf[nickcolor]; }
.ccolor{margin:3px; width:10px; height:10px; overflow:hidden;display:block; float:right;}
.ccolor2{margin:0px; border:3px solid #333333;width:10px; height:10px; overflow:hidden;display:block; float:right;}
* html .ccolor2{width:16px; height:16px; }
#clearcheck,#scollcheck,#fullwinddow{cursor:pointer;}
#clearcheck{ margin-right:15px;}
</style>
<div>
<table cellpadding="2" cellspacing="3" border="0" width="100%" id="sdc_chat">
<tbody><tr><td valign="top"><div id="ch"></div></td><td valign="top" width="150"><div id="nl"></div></td>
</tr></tbody>
<tbody><tr><td colspan="2">
<embed src="source/plugin/sdc_chat/chat.swf" quality="high" wmode="transparent" loop="false" id="sdcswfchat" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="1" height="1"></embed>
<input name="cbmessage" type="text" id="cbmessage" maxlength="500" onKeyDown="siamdiscuz.chat.sendmsg(event)">
<div style="background-color:{$cf[bordercolor]};padding-top:3px">
<div align="right" style="height:16px; overflow:hidden; line-height:16px; vertical-align:text-top">
<!--{if $cf[uver]}--><a href="http://www.siamdiscuz.com" target="_blank" style="float:right; margin-left:5px; font-size:10px">v. 0.7</a><!--{/if}-->
<a href="http://www.siamdiscuz.com" target="_blank" style="float:right; margin-left:20px; font-size:10px">©</a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('000000')" id="c000000" class="ccolor" style="background:#000000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('000055')" id="c000055" class="ccolor" style="background:#000055"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('008000')" id="c008000" class="ccolor" style="background:#008000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FF0000')" id="cFF0000" class="ccolor" style="background:#FF0000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('800000')" id="c800000" class="ccolor" style="background:#800000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('800080')" id="c800080" class="ccolor" style="background:#800080"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FF5500')" id="cFF5500" class="ccolor" style="background:#FF5500"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FFFF00')" id="cFFFF00" class="ccolor" style="background:#FFFF00"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('008080')" id="c008080" class="ccolor" style="background:#008080"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('00FFFF')" id="c00FFFF" class="ccolor" style="background:#00FFFF"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('0000FF')" id="c0000FF" class="ccolor" style="background:#0000FF"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('7F7F7F')" id="c7F7F7F" class="ccolor" style="background:#7F7F7F"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('D2D2D2')" id="cD2D2D2" class="ccolor" style="background:#D2D2D2"><img src="source/plugin/sdc_chat/trans.gif"></a>
<span style="clear:both"></span><span id="whisper"></span>
<a href="javascript:;" class="fsml" id="cbsml" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});doane(event)"><img src="source/plugin/sdc_chat/emo.gif" title="อีโมชั่น" /></a>
<script type="text/javascript" src="data/cache/common_smilies_var.js?{VERHASH}" reload="1"></script>
<script type="text/javascript" reload="1">smilies_show('cbsmiliesdiv', $_G['setting']['smcols'], 'cb');</script>
{if CURSCRIPT != 'plugin'}<a href="plugin.php?id=sdc_chat"><img src="static/image/common/zoomin.gif" id="fullwinddow" title="แสดงหน้าสนทนาแบบเต็ม" alt="แสดงหน้าสนทนาแบบเต็ม" onclick="siamdiscuz.chat.fullwinddow()" /></a>{/if}
<img src="static/image/common/data_valid.gif" id="scollcheck" title="ข้อความเลื่อนลงอัตโนมัติ" alt="ข้อความเลื่อนลงอัตโนมัติ" onclick="siamdiscuz.chat.scollcheck()" />
<img src="static/image/common/frame_on.gif" id="clearcheck" title="เคลียข้อความ" alt="เคลียข้อความ" onclick="$('ch').innerHTML=''" />
</div>
<div style="clear:both"></div>
</div>
</td></tr></tbody></table>
</div>
<script type="text/javascript">
if(typeof(siamdiscuz)=='undefined')siamdiscuz=new Object;
if(typeof(siamdiscuz.ajax)=='undefined')siamdiscuz.ajax={
go:function(sURL,sFunction,aArgs)
{
var xmlhttp,value;this.c=false;
try{xmlhttp=new XMLHttpRequest();this.c=true;}catch(e){this.b=['Msxml2.XMLHTTP','Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0']; for(this.d=0;(this.d<this.b.length)&&(!this.c);this.d++){try{xmlhttp=new ActiveXObject(this.b[this.d]);this.c=true;}catch(e){alert('NO AJAX');}}};
if(!this.c){alert('not support AJAX!');return;};
this.data='ajaxplus='+sFunction;
if(aArgs){for(i=0;i<aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object") value=this.objectToXML(value);this.data+="&plusargs[]="+encodeURIComponent(value);}};
xmlhttp.open("POST",sURL,true);
try{xmlhttp.setRequestHeader("Method","POST "+sURL+" HTTP/1.1");xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(e){alert("蠟腔銡擬祥盓堔POST.");return;};
xmlhttp.send(this.data);
xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){siamdiscuz.ajax.xml(xmlhttp);}else if(xmlhttp.status==404){alert("ไม่มี URL นี้ในระบบ!");};}return true;}
},
objectToXML:function(obj){var sXml="<plusobj>";for(i in obj){try{if(i=='constructor') continue;if(obj[i]&&typeof(obj[i])=='function') continue;var key=i;var value=obj[i];if(value&&typeof(value)=="object"&&this.depth <=50){this.depth++;value=this.objectToXML(value);this.depth--;};sXml+="<e><k>"+key+"</k><v>"+value+"</v></e>";}catch(e){if(xajaxDebug)this.DebugMessage(e.name+": "+e.message);}};sXml+="</plusobj>";return sXml;},
xml:function(x){var t=x.responseXML;if(t==null) return;window.status='Processing...';this.t=t.documentElement;if(this.t==null){window.status='XML response processing error';return;};
var i,j;for(i=0;i<this.t.childNodes.length;i++){if(this.t.childNodes[i].nodeName=="cmd"){ for(j=0;j<this.t.childNodes[i].attributes.length;j++){eval('this.'+this.t.childNodes[i].attributes[j].name+'=this.t.childNodes[i].attributes[j].value');};
this.d=(this.t.childNodes[i].firstChild?this.t.childNodes[i].firstChild.nodeValue:'');
switch(this.a){
case "al":alert(this.d);break;
case "rm":this.remove(this.d);break;
case "ap":eval("$(this.s)."+this.p+"+=this.d;");break;
case "as":eval("$(this.s)."+this.p+"=this.d;");break;
case "js":eval(this.d);break;
}}};delete this.t;},
remove:function(sId){objElement = $(sId);if(objElement&&objElement.parentNode && objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement);}} ,
getForm:function(frm){var objForm;var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true) submitDisabledElements=true;var prefix="";if(arguments.length > 2) prefix=arguments[2];if(typeof(frm)=="string") objForm=$(frm);else objForm=frm;var sXml="<plusquery><q>";if(objForm&&objForm.tagName=='FORM'){var formElements=objForm.elements;for(var i=0;i < formElements.length;i++){if(!formElements[i].name) continue;if(formElements[i].name.substring(0,prefix.length)!=prefix) continue;if(formElements[i].type&&(formElements[i].type=='radio'||formElements[i].type=='checkbox')&&formElements[i].checked==false) continue;if(formElements[i].disabled&&formElements[i].disabled==true&&submitDisabledElements==false) continue;var name=formElements[i].name;if(name){if(sXml!='<plusquery><q>') sXml+='&';if(formElements[i].type=='select-multiple'){for(var j=0;j < formElements[i].length;j++){if(formElements[i].options[j].selected==true) sXml+=name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";}}else{sXml+=name+"="+encodeURIComponent(formElements[i].value);}}}};sXml+="</q></plusquery>";return sXml;}
};
siamdiscuz.chat={
a:'',tmp:'',tm:0,strUser:'',strPass:'',tm_ref:'',curc:'',whis2:'',tmsc:'',scolling:true,bgcolor:new Array('{$cf[color1]}','{$cf[color2]}'),bgindex:0,
sendmsg:function(e)
{
var key=(e.keyCode?e.keyCode:e.which);var ms=$('cbmessage');
if(key==13&&ms.value.length>0)
{
if(ms.value.indexOf('@')==0) this.send(ms.value);
else this.send("[color=#"+this.curc+"]"+ms.value+"");
ms.value='';ms.focus();
}
},
setcolor:function(c){if(this.curc)$('c'+this.curc).className='ccolor';$('c'+c).className='ccolor2';this.curc=c;if($('cbmessage'))$('cbmessage').focus();},
whis:function(nick){this.whis2=nick;$('whisper').innerHTML=" [ กระซิบ : "+nick+" (<a href='javascript:;' onclick='siamdiscuz.chat.whiss()'>ยกเลิก</a>)] ";},
whiss:function(){this.whis2='';$('whisper').innerHTML='';},
send:function(t) {clearTimeout(this.tm_ref);this.sock(this.tm,t,this.whis2);this.tm=this.tm+0.000001;this.tm_ref=setTimeout("siamdiscuz.chat.send('')",{$updatetime});},
getmsg:function(obj){
var c=prompt("กรุณากรอกข้อความที่คุณต้องการจะตอบ","กรอกข้อความที่นี่");
if (c=="กรอกข้อความที่นี่"||c=='')alert("คุณยังไม่ได้กรอกข้อความใดๆ เลย");
else if(c!=null)this.send((document.all?obj.parentNode.innerText:obj.parentNode.textContent)+" <--- "+"[color=#"+this.curc+"]"+c+"");
$('cbmessage').focus();
},
set:function(obj){obj.style.color='{$cf[mtxtcolor]}';obj.style.backgroundColor='$cf[mbgcolor]'},
unset:function(obj){obj.style.color='';obj.style.backgroundColor=''},
scollcheck:function(){siamdiscuz.chat.scolling=!siamdiscuz.chat.scolling;$('scollcheck').src='static/image/common/'+(siamdiscuz.chat.scolling?'data_valid':'data_invalid')+'.gif'},
sock:function(){siamdiscuz.ajax.go('plugin.php?id=sdc_chat:sock','sock',arguments);},
autoscoll:function(){clearTimeout(this.tm_sc);if(siamdiscuz.chat.scolling) $('ch').scrollTop+=$('ch').offsetHeight+100;this.tm_sc=setTimeout("siamdiscuz.chat.autoscoll()",1000);},
replacenick:function(n,m)
{
var nic=$('nl').getElementsByTagName('DIV');
for(var i=0;i<nic.length;i++)
{
if(nic[i].getAttribute('nick')==n)
{
nic[i].setAttribute('lasttime',this.tm);
return;
}
}
var nick=document.createElement("DIV");
nick.setAttribute("nick",n);
nick.setAttribute("lasttime",this.tm);
nick.innerHTML=m;
$('nl').appendChild(nick);
},
deletenick:function()
{
var nic=$('nl').getElementsByTagName('DIV');
for(var i=nic.length-1;i>=0;i--)
{
if(Math.floor(nic[i].getAttribute('lasttime'))+10<this.tm)$('nl').removeChild(nic[i]);
}
},
newmsg:function(msg)
{
var div=document.createElement("DIV");
div.innerHTML=msg;
var b=this.bgcolor[this.bgindex % 2];
if(b!='')div.setAttribute('style','background-color:'+b);
$('ch').appendChild(div);
this.bgindex++;
}
};
_attachEvent(window, 'load', function(){siamdiscuz.chat.setcolor('7F7F7F');siamdiscuz.chat.send('');}, document);
</script>
<!-- sdc_chat end -->
<!--{/block}-->
เป็นบ้าง่สวนนะครับ
ปัญหาคือ เวลามีการส่งข้อความมันจะแสดงข้อความซ้ำๆๆ นะครับ
ต้อง refresh ข้อมความที่ซ้ำจึงจะหายไป ช่วยหน่อยครับ
<!-- SiamDiscuz Shoutbox v0.1 -->
<style type="text/css">
#um p {text-align:right !important; float:none}
#sdc_chat{background-color:{$cf[bordercolor]}; border-collapse:inherit}
#sdc_chat b.img img{ height:16px; vertical-align:text-bottom}
#sdc_chat b.img2 img{ height:38px; width:38px; vertical-align:text-bottom; float:left; margin:2px 5px 2px 0px}
#sdc_chat td{background-color:{$cf[bgcolor]}}
#sdc_chat a b{font-weight:normal}
#ch,#nl{padding:3px;background-color: $cf[bgcolor];font:10px;height: {$cf[height]}px;overflow:auto;}
#nl{background-color: $cf[nickcolor];}
#ch div{min-height:20px; line-height:20px;}
#ch i{cursor:pointer; font-style:normal}
#ch div{clear:both}
#cbmessage { width: 100%;margin-top: 1px; font-size:14px; height:20px; line-height:20px; border:1px inset {$cf[bordercolor]};background-color: $cf[nickcolor]; }
.ccolor{margin:3px; width:10px; height:10px; overflow:hidden;display:block; float:right;}
.ccolor2{margin:0px; border:3px solid #333333;width:10px; height:10px; overflow:hidden;display:block; float:right;}
* html .ccolor2{width:16px; height:16px; }
#clearcheck,#scollcheck,#fullwinddow{cursor:pointer;}
#clearcheck{ margin-right:15px;}
</style>
<div>
<table cellpadding="2" cellspacing="3" border="0" width="100%" id="sdc_chat">
<tbody><tr><td valign="top"><div id="ch"></div></td><td valign="top" width="150"><div id="nl"></div></td>
</tr></tbody>
<tbody><tr><td colspan="2">
<embed src="source/plugin/sdc_chat/chat.swf" quality="high" wmode="transparent" loop="false" id="sdcswfchat" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="1" height="1"></embed>
<input name="cbmessage" type="text" id="cbmessage" maxlength="500" onKeyDown="siamdiscuz.chat.sendmsg(event)">
<div style="background-color:{$cf[bordercolor]};padding-top:3px">
<div align="right" style="height:16px; overflow:hidden; line-height:16px; vertical-align:text-top">
<!--{if $cf[uver]}--><a href="http://www.siamdiscuz.com" target="_blank" style="float:right; margin-left:5px; font-size:10px">v. 0.7</a><!--{/if}-->
<a href="http://www.siamdiscuz.com" target="_blank" style="float:right; margin-left:20px; font-size:10px">©</a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('000000')" id="c000000" class="ccolor" style="background:#000000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('000055')" id="c000055" class="ccolor" style="background:#000055"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('008000')" id="c008000" class="ccolor" style="background:#008000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FF0000')" id="cFF0000" class="ccolor" style="background:#FF0000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('800000')" id="c800000" class="ccolor" style="background:#800000"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('800080')" id="c800080" class="ccolor" style="background:#800080"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FF5500')" id="cFF5500" class="ccolor" style="background:#FF5500"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('FFFF00')" id="cFFFF00" class="ccolor" style="background:#FFFF00"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('008080')" id="c008080" class="ccolor" style="background:#008080"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('00FFFF')" id="c00FFFF" class="ccolor" style="background:#00FFFF"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('0000FF')" id="c0000FF" class="ccolor" style="background:#0000FF"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('7F7F7F')" id="c7F7F7F" class="ccolor" style="background:#7F7F7F"><img src="source/plugin/sdc_chat/trans.gif"></a>
<a href="javascript:;" onClick="siamdiscuz.chat.setcolor('D2D2D2')" id="cD2D2D2" class="ccolor" style="background:#D2D2D2"><img src="source/plugin/sdc_chat/trans.gif"></a>
<span style="clear:both"></span><span id="whisper"></span>
<a href="javascript:;" class="fsml" id="cbsml" onclick="showMenu({'ctrlid':this.id,'evt':'click','layer':2});doane(event)"><img src="source/plugin/sdc_chat/emo.gif" title="อีโมชั่น" /></a>
<script type="text/javascript" src="data/cache/common_smilies_var.js?{VERHASH}" reload="1"></script>
<script type="text/javascript" reload="1">smilies_show('cbsmiliesdiv', $_G['setting']['smcols'], 'cb');</script>
{if CURSCRIPT != 'plugin'}<a href="plugin.php?id=sdc_chat"><img src="static/image/common/zoomin.gif" id="fullwinddow" title="แสดงหน้าสนทนาแบบเต็ม" alt="แสดงหน้าสนทนาแบบเต็ม" onclick="siamdiscuz.chat.fullwinddow()" /></a>{/if}
<img src="static/image/common/data_valid.gif" id="scollcheck" title="ข้อความเลื่อนลงอัตโนมัติ" alt="ข้อความเลื่อนลงอัตโนมัติ" onclick="siamdiscuz.chat.scollcheck()" />
<img src="static/image/common/frame_on.gif" id="clearcheck" title="เคลียข้อความ" alt="เคลียข้อความ" onclick="$('ch').innerHTML=''" />
</div>
<div style="clear:both"></div>
</div>
</td></tr></tbody></table>
</div>
<script type="text/javascript">
if(typeof(siamdiscuz)=='undefined')siamdiscuz=new Object;
if(typeof(siamdiscuz.ajax)=='undefined')siamdiscuz.ajax={
go:function(sURL,sFunction,aArgs)
{
var xmlhttp,value;this.c=false;
try{xmlhttp=new XMLHttpRequest();this.c=true;}catch(e){this.b=['Msxml2.XMLHTTP','Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0']; for(this.d=0;(this.d<this.b.length)&&(!this.c);this.d++){try{xmlhttp=new ActiveXObject(this.b[this.d]);this.c=true;}catch(e){alert('NO AJAX');}}};
if(!this.c){alert('not support AJAX!');return;};
this.data='ajaxplus='+sFunction;
if(aArgs){for(i=0;i<aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object") value=this.objectToXML(value);this.data+="&plusargs[]="+encodeURIComponent(value);}};
xmlhttp.open("POST",sURL,true);
try{xmlhttp.setRequestHeader("Method","POST "+sURL+" HTTP/1.1");xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}catch(e){alert("蠟腔銡擬祥盓堔POST.");return;};
xmlhttp.send(this.data);
xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){siamdiscuz.ajax.xml(xmlhttp);}else if(xmlhttp.status==404){alert("ไม่มี URL นี้ในระบบ!");};}return true;}
},
objectToXML:function(obj){var sXml="<plusobj>";for(i in obj){try{if(i=='constructor') continue;if(obj[i]&&typeof(obj[i])=='function') continue;var key=i;var value=obj[i];if(value&&typeof(value)=="object"&&this.depth <=50){this.depth++;value=this.objectToXML(value);this.depth--;};sXml+="<e><k>"+key+"</k><v>"+value+"</v></e>";}catch(e){if(xajaxDebug)this.DebugMessage(e.name+": "+e.message);}};sXml+="</plusobj>";return sXml;},
xml:function(x){var t=x.responseXML;if(t==null) return;window.status='Processing...';this.t=t.documentElement;if(this.t==null){window.status='XML response processing error';return;};
var i,j;for(i=0;i<this.t.childNodes.length;i++){if(this.t.childNodes[i].nodeName=="cmd"){ for(j=0;j<this.t.childNodes[i].attributes.length;j++){eval('this.'+this.t.childNodes[i].attributes[j].name+'=this.t.childNodes[i].attributes[j].value');};
this.d=(this.t.childNodes[i].firstChild?this.t.childNodes[i].firstChild.nodeValue:'');
switch(this.a){
case "al":alert(this.d);break;
case "rm":this.remove(this.d);break;
case "ap":eval("$(this.s)."+this.p+"+=this.d;");break;
case "as":eval("$(this.s)."+this.p+"=this.d;");break;
case "js":eval(this.d);break;
}}};delete this.t;},
remove:function(sId){objElement = $(sId);if(objElement&&objElement.parentNode && objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement);}} ,
getForm:function(frm){var objForm;var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true) submitDisabledElements=true;var prefix="";if(arguments.length > 2) prefix=arguments[2];if(typeof(frm)=="string") objForm=$(frm);else objForm=frm;var sXml="<plusquery><q>";if(objForm&&objForm.tagName=='FORM'){var formElements=objForm.elements;for(var i=0;i < formElements.length;i++){if(!formElements[i].name) continue;if(formElements[i].name.substring(0,prefix.length)!=prefix) continue;if(formElements[i].type&&(formElements[i].type=='radio'||formElements[i].type=='checkbox')&&formElements[i].checked==false) continue;if(formElements[i].disabled&&formElements[i].disabled==true&&submitDisabledElements==false) continue;var name=formElements[i].name;if(name){if(sXml!='<plusquery><q>') sXml+='&';if(formElements[i].type=='select-multiple'){for(var j=0;j < formElements[i].length;j++){if(formElements[i].options[j].selected==true) sXml+=name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";}}else{sXml+=name+"="+encodeURIComponent(formElements[i].value);}}}};sXml+="</q></plusquery>";return sXml;}
};
siamdiscuz.chat={
a:'',tmp:'',tm:0,strUser:'',strPass:'',tm_ref:'',curc:'',whis2:'',tmsc:'',scolling:true,bgcolor:new Array('{$cf[color1]}','{$cf[color2]}'),bgindex:0,
sendmsg:function(e)
{
var key=(e.keyCode?e.keyCode:e.which);var ms=$('cbmessage');
if(key==13&&ms.value.length>0)
{
if(ms.value.indexOf('@')==0) this.send(ms.value);
else this.send("[color=#"+this.curc+"]"+ms.value+"");
ms.value='';ms.focus();
}
},
setcolor:function(c){if(this.curc)$('c'+this.curc).className='ccolor';$('c'+c).className='ccolor2';this.curc=c;if($('cbmessage'))$('cbmessage').focus();},
whis:function(nick){this.whis2=nick;$('whisper').innerHTML=" [ กระซิบ : "+nick+" (<a href='javascript:;' onclick='siamdiscuz.chat.whiss()'>ยกเลิก</a>)] ";},
whiss:function(){this.whis2='';$('whisper').innerHTML='';},
send:function(t) {clearTimeout(this.tm_ref);this.sock(this.tm,t,this.whis2);this.tm=this.tm+0.000001;this.tm_ref=setTimeout("siamdiscuz.chat.send('')",{$updatetime});},
getmsg:function(obj){
var c=prompt("กรุณากรอกข้อความที่คุณต้องการจะตอบ","กรอกข้อความที่นี่");
if (c=="กรอกข้อความที่นี่"||c=='')alert("คุณยังไม่ได้กรอกข้อความใดๆ เลย");
else if(c!=null)this.send((document.all?obj.parentNode.innerText:obj.parentNode.textContent)+" <--- "+"[color=#"+this.curc+"]"+c+"");
$('cbmessage').focus();
},
set:function(obj){obj.style.color='{$cf[mtxtcolor]}';obj.style.backgroundColor='$cf[mbgcolor]'},
unset:function(obj){obj.style.color='';obj.style.backgroundColor=''},
scollcheck:function(){siamdiscuz.chat.scolling=!siamdiscuz.chat.scolling;$('scollcheck').src='static/image/common/'+(siamdiscuz.chat.scolling?'data_valid':'data_invalid')+'.gif'},
sock:function(){siamdiscuz.ajax.go('plugin.php?id=sdc_chat:sock','sock',arguments);},
autoscoll:function(){clearTimeout(this.tm_sc);if(siamdiscuz.chat.scolling) $('ch').scrollTop+=$('ch').offsetHeight+100;this.tm_sc=setTimeout("siamdiscuz.chat.autoscoll()",1000);},
replacenick:function(n,m)
{
var nic=$('nl').getElementsByTagName('DIV');
for(var i=0;i<nic.length;i++)
{
if(nic[i].getAttribute('nick')==n)
{
nic[i].setAttribute('lasttime',this.tm);
return;
}
}
var nick=document.createElement("DIV");
nick.setAttribute("nick",n);
nick.setAttribute("lasttime",this.tm);
nick.innerHTML=m;
$('nl').appendChild(nick);
},
deletenick:function()
{
var nic=$('nl').getElementsByTagName('DIV');
for(var i=nic.length-1;i>=0;i--)
{
if(Math.floor(nic[i].getAttribute('lasttime'))+10<this.tm)$('nl').removeChild(nic[i]);
}
},
newmsg:function(msg)
{
var div=document.createElement("DIV");
div.innerHTML=msg;
var b=this.bgcolor[this.bgindex % 2];
if(b!='')div.setAttribute('style','background-color:'+b);
$('ch').appendChild(div);
this.bgindex++;
}
};
_attachEvent(window, 'load', function(){siamdiscuz.chat.setcolor('7F7F7F');siamdiscuz.chat.send('');}, document);
</script>
<!-- sdc_chat end -->
<!--{/block}-->
เป็นบ้าง่สวนนะครับ
ปัญหาคือ เวลามีการส่งข้อความมันจะแสดงข้อความซ้ำๆๆ นะครับ
ต้อง refresh ข้อมความที่ซ้ำจึงจะหายไป ช่วยหน่อยครับ