<script type="text/javascript">
document.write("<div id ='load'>正在加载....</div>");
var style = document.createElement("link");
style.rel="stylesheet";
style.type="text/css";
style.href=>style.title='ppjoke';
var head=document.getElementsByTagName("head")[0];
head.appendChild(style);
</script>
<script language="JavaScript" type="text/javascript" src="ppjoke/lib/prototype.js"></script>
<script type="text/javascript" src="ppjoke/src/scriptaculous.js?load=effects,dragdrop,builder,controls,slider "></script>
<script language="JavaScript" type="text/javascript">
var talktime = 3500;//设置获取内容时间间隔
var talkpath = 'ppjoke/ppjoke.asp';
var talkcolor = 'blue';
var info_shaping ='请勿刷屏';
var info_talkfail ='发送失败';
var barinf_logining ='正在登录';
var barinf_regging = '正在注册';
var barinf_neterro = '数据传输错误';
var barinf_loginready = '登陆成功';
var barinf_loginerro = '密码错误';
var barinf_blank = '请输入聊天内容';
var barinf_logoutok = '注销成功';
var barinf_logouterro = '注销失败';
var barinf_regerro = '用户名已存在';
var barinf_regok = '注册成功,自动登陆';
var barinf_checkuser = '自动登陆中';
var barinf_checkbad = '非法身份,请自行登陆';
var colorArr = ['red','blue','green','darkorange','black','teal','deeppink','blueviolet','springgreen'];
var Anonymous = '匿名';
var count=0;
var lastworld='';
var lastalk='';
var lastWorldTime=false;
var getMsgTime;
var noMemoTimes = 0;
var cookiename;
var cookiepass;
//Event.observe(window, 'load', ppjokeinit, false);
function ppjokeinit(){
talkcolor = colorArr[Math.round(Math.random()*9)];
window.setTimeout(getMsg,talktime);
$('load').style.display='none';
$('ppjoke_main').style.display='block';
Event.observe('ppjoke_sendbox', 'keydown', keyDownAll, false);
Field.select('talk');
new Draggable('ppjoke_main',{handle:'ppjoke_topbar'});
createFaceList();
GetCookie();
logined();
}
var ppjokeWs = {
letBack:function(){
$('ppjoke_main').style.left='';
$('ppjoke_main').style.top='';
$('ppjoke_main').style.zIndex='';
$('ppjoke_main').style.width='150px';
$('ppjoke_msgbox').style.height='200px';
$('ppjoke_Facediv').style.height = '100px';
},
letBig:function(){
$('ppjoke_main').style.width = '580px';
$('ppjoke_msgbox').style.height = '400px';
$('ppjoke_Facediv').style.height = '25px';
}
}
function keyDownAll(event){
var e = event || window.event;
if(e.keyCode==13){sendMsg()}
}
function logined(){
function loginok(req){
if(req.responseText=="ok"){
$('name').value = cookiename;
$('alogin').style.display='none';
$('ppjoke_alogout').style.display='inline';
$('name').blur();
$('name').disabled = 'true';
Field.select('talk');
}else{
}
}
if(cookiename){
var timestamps = new Date().getTime()+Math.random();
creatInfo(barinf_checkuser);
var sendAjax = new Ajax.Request(talkpath+'?act=login×tamp='+timestamps,{method: 'post',parameters:'regname='+cookiename+"®pass="+cookiepass,onComplete:loginok});
}
}
//获取信息
function getMsg (){
var timestamps = new Date().getTime()+Math.random();
var getAjax = new Ajax.Request(talkpath+'?act=getMsg×tamps='+timestamps,{method: 'get',parameters:'',onSuccess:showMsg});
function showMsg(req){
window.setTimeout(getMsg,talktime);
var newMsg=eval('(' + req.responseText + ')');
function appendtime(){
$('ppjoke_msgbox').appendChild(Builder.node('p', {id:'thelastTime',style:'background-color:#FFCCFF'},'消息发送时间:'+lastWorldTime));
appendtimok=true;
}
if (noMemoTimes == 5 ){appendtime();noMemoTimes=0}
noMemoTimes?noMemoTimes++:noMemoTimes=0;
//处理聊天信息
newMsg.msg.each(function(data){
if(noMemoTimes >= 5){Element.remove('thelastTime');}
noMemoTimes = 1;
count++;
var p = document.createElement('p');
if(count%2==0){
Element.addClassName(p,'p1');
}else{
Element.addClassName(p,'p2');
}
var userspan = document.createElement('span');
var usertext = document.createTextNode(data.u+':');
if(data.v=="True"){
userspan.appendChild(usertext);
}else{
userspan.style.color='#CACACA';
userspan.appendChild(usertext);
}
var msgspan = document.createElement('span');
msg2face(data.m,msgspan);
msgspan.style.color=data.c;
p.appendChild(userspan);
p.appendChild(msgspan);
$('ppjoke_msgbox').appendChild(p);
lastWorldTime=data.t;
}
);
$('ppjoke_msgbox').scrollTop=$('ppjoke_msgbox').scrollHeight;
}
}
//发送聊天信息,处理本地消息
function sendMsg (){
if(!Field.present('talk','name','email')){
creatInfo(barinf_blank);
return;
}
if(lastworld==Form.serialize('talkform')){
sysinf(info_shaping);
}else{
if($('thelastTime')){Element.remove('thelastTime');}
var timestamps = new Date().getTime()+Math.random();
var sendAjax = new Ajax.Request(talkpath+'?act=sendMsg&color='+talkcolor+'×tamp='+timestamps,{method: 'post',parameters:Form.serialize('talkform'),onFailure:ajaxErro});
lastworld=Form.serialize('talkform');
lastalk=$F('talk');
count++;
var p = document.createElement('p');
if(count%2==0){
Element.addClassName(p,'p1');
}else{
Element.addClassName(p,'p2');
}
var userspan = document.createElement('span');
var usertext = document.createTextNode($F('name')+':');
if($('name').disabled == true){
userspan.appendChild(usertext);
}else{
userspan.style.color='#CACACA';
userspan.appendChild(usertext);
}
var msgspan = document.crea
上一个:ajax实现标签导航
下一个:ajax的 responseXML返回接受 asp