PPJOKE 0.1 (网页嵌入聊天)提供下载
程序员文章站
2022-03-14 10:39:51
ppjoke是一套基于ajax技术网页嵌入聊天程序,目前提供asp版下载,.net版本的负载量更高,不过还在调试中,拖了很长时间了,最近一直忙着学习,没有更新,这里先提供下...
ppjoke是一套基于ajax技术网页嵌入聊天程序,目前提供asp版下载,.net版本的负载量更高,不过还在调试中,拖了很长时间了,最近一直忙着学习,没有更新,这里先提供下载。
此外最近一直在研究持续连接技术,也就是所谓的推技术,还有jssocket等企业级的类ajax技术,希望有经验的朋友交流。
屁屁聊天 ppjoke
功能/特点
基于ajax技术
运用了成熟稳定的prototype/scriptaculous框架
数据传送量小
页面嵌入聊天
自定义强突出个性化
支持换肤
支持表情
支持拖动 放大
更改颜色
ppjoke是根据我以前写的otalk重写的。演示地址,向右转--> 已经嵌入到了我blog中。
http://www.ppjoke.com
ppjoke整站提供下载。
修改界面颜色
见rar中'ppjoke/ppjoke.css'只要相应修改成网站配色就ok
网页集成说明
将rar中的ppjoke复制到要嵌入页面的目录中,将index.htm中的一下代码复制到网页中向嵌入的div中即可
<script type="text/javascript">
document.write("<div id ='load'>正在加载....</div>");
var style = document.createelement("link");
style.rel="stylesheet";
style.type="text/css";
style.href='ppjoke/ppjoke.css';
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.createelement('span');
msg2face($f('talk'),msgspan);
msgspan.style.color=talkcolor;
p.appendchild(userspan);
p.appendchild(msgspan);
$('ppjoke_msgbox').appendchild(p);
}
field.clear('talk');
field.select('talk');
$('ppjoke_msgbox').scrolltop=$('ppjoke_msgbox').scrollheight;
function ajaxerro(){
sysinf(info_talkfail);
}
}
//发送登陆信息
function sendlogin (){
var timestamps = new date().gettime()+math.random();
creatinfo(barinf_logining);
var sendajax = new ajax.request(talkpath+'?act=login×tamp='+timestamps,{method: 'post',parameters:form.serialize('logform'),oncomplete:sendloginok});
function sendloginok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_loginready);
$('alogin').style.display='none';
$('ppjoke_alogout').style.display='inline';
$('name').value=$f('regname');
$('name').blur();
$('name').disabled = 'true';
effect.slideup('ppjoke_logdiv',{duration:1.0});
field.select('talk');
creactcookie();
}else{
creatinfo(barinf_loginerro);
}
}
}
//发送注册信息
function sendreg (){
var timestamps = new date().gettime()+math.random();
creatinfo(barinf_regging);
var sendajax = new ajax.request(talkpath+'?act=reg×tamp='+timestamps,{method: 'post',parameters:form.serialize('logform'),oncomplete:sendregok});
function sendregok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_regok);
$('alogin').style.display='none';
$('ppjoke_alogout').style.display='inline';
$('name').value=$f('regname');
$('name').blur();
$('name').disabled = 'true';
effect.slideup('ppjoke_logdiv',{duration:1.0});
field.select('talk');
creactcookie();
}else{
creatinfo(barinf_regerro);
}
}
}
//发送注销信息
function sendlogout (){
var timestamps = new date().gettime()+math.random();
var sendajax = new ajax.request(talkpath+'?act=logout×tamp='+timestamps,{method: 'get',parameters:'',oncomplete:sendlogoutok});
function sendlogoutok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_logoutok);
$('ppjoke_logdiv').style.display='none';
$('alogin').style.display='inline';
$('ppjoke_alogout').style.display='none';
$('name').value=anonymous;
$('name').blur();
$('name').disabled = ''
field.select('talk');
clearchat() ;
}else{
creatinfo(barinf_logouterro);
}
}
}
function msg2face(msg,element){
var msgtext=$a(msg.match(/([^\[]*)(\[\d\d\])?/gim));
if(msgtext[0]){
msgtext.each(function(word){
var section = word.match(/([^\[]*)\[?(\d\d)?\]?/i);
if(section[1]){
var msgtext = document.createtextnode(section[1]);
element.appendchild(msgtext);
}
if(section[2]){
msgimg = document.createelement('img');
msgimg.setattribute('src','ppjoke/images/smilies/face_'+section[2]+'.gif');
element.appendchild(msgimg);
}
}
);
}else{
element.appendchild(document.createtextnode(msg));
}
}
function creatinfo(text){
$('ppjoke_otherinf').innerhtml=text;
window.settimeout(function(){$('ppjoke_otherinf').innerhtml=""},5000);
}
function sysinf(text){
var p = builder.node('p',{style:'background-color:yellow'},[builder.node('span',{style:'color:red'},'系统 '),builder.node('span',{style:'color:blue'},text)]);
$('ppjoke_msgbox').appendchild(p);
$('ppjoke_msgbox').scrolltop=$('ppjoke_msgbox').scrollheight;
}
ajax.responders.register(
{
oncreate: function(){
//creatinfo(nomemotimes);
$('ajaxing').show();
},
oncomplete: function() {
if(ajax.activerequestcount == 0){
$('ajaxing').hide();
}
}
}
);
function createfacelist(){
for (i=1;i<=24;i++){
var j=i
if(j<10){j='0'+i}
var a = builder.node('a', {href:'#'},[builder.node('img',{src:'ppjoke/images/smilies/face_'+j+'.gif'},[])]);
a.alt=j;
a.onclick=function(){$('talk').value=$f('talk')+'['+this.alt+']';field.focus('talk');return false;};
var li = builder.node('li', {},[a]);
$('ppjoke_facelist').appendchild(li);
}
}
function changecolor(color){
talkcolor=color;
}
function creactcookie(){
var mydate = new date();
mydate.settime(mydate.gettime() + 48*60*60*100);
document.cookie = "ppjokeusername="+escape($f('regname'))+";expires="+mydate.togmtstring();
document.cookie = "ppjokepass="+escape($f('regpass'))+";expires="+mydate.togmtstring();
}
function getcookie(){
var value = unescape(document.cookie);
var namepos = value.indexof("ppjokeusername=");
if(namepos!=-1){
var start = namepos + 14;
var end = value.indexof(";",start);
if (end == -1) end = value.length;
cookiename = value.substring(start,end);
}
var passpos = value.indexof("ppjokepass=");
if(passpos!=-1){
var start = passpos + 10;
var end = value.indexof(";",start);
if (end == -1) end = value.length;
cookiepass = value.substring(start,end);
}
}
function delcookie(sname,svalue){
document.cookie = sname + "=" + escape(svalue) + ";expires=fri, 31 dec 1999 23:59:59 gmt;";
}
function clearchat(){
var ps = $a($('ppjoke_msgbox').getelementsbytagname('p'));
ps.each(function(p){
element.remove(p);
}
);
}
</script>
<div id="ppjoke">
<div id="ppjoke_main">
<div id="ppjoke_topbar"><a href="javascript:void(0)" onclick="ppjokews.letback()">x</a><a href="javascript:void(0)" onclick="ppjokews.letbig()">b</a><a href="javascript:void(0)" onclick="void(0)">f</a></div>
<div id="ppjoke_msgbox"></div>
<div id="ppjoke_infbox">
<span id="ppjoke_otherinf"></span>
<span id="ajaxing"><img src="ppjoke/images/ajaxing.gif" alt="doing" /></span>
</div>
<div id="ppjoke_operbox">
<div id="ppjoke_sendbox">
<form id="talkform" action="#">
<input type="text" name="name" class="smallinput" id = "name" value="匿名" />
<input type="text" name="email" class="smallinput" id="email" value="email" />
<input type="text" name="talk" class="longinput" id="talk" />
</form>
<a class="aex" href="#" onclick="clearchat(); return false;" >清屏</a>
<a id="alogin" class="aex" href="#" onclick="effect.toggle('ppjoke_logdiv','slide'); return false;" >登录</a>
<a id="ppjoke_alogout" class="aex" href="#" onclick="sendlogout(); return false;" >注销</a>
<a class="aex" href="#" onclick="effect.toggle('ppjoke_facediv','slide'); return false;" >:)</a>
<a class="aex" href="#" onclick="effect.toggle('ppjoke_colordiv','slide'); return false;" >色</a>
</div>
<div id="ppjoke_facediv" style="display:none;">
<ul id="ppjoke_facelist">
</ul>
</div>
<div id="ppjoke_logdiv" style="display:none;">
<form id="logform" action="#">
<input type="text" name="regname" class="smallinput" id = "regname" value="username" />
<input type="password" name="regpass" class="smallinput" id="regpass" value="pass" />
<a href="#" class="aex" onclick="sendlogin();return false;" >确定</a>
<a href="#" class="aex" onclick="sendreg();return false;" >注册</a>
</form>
</div>
<div id="ppjoke_colordiv" style="display:none;">
<ul >
<li><a style="color:red" href="#" onclick="changecolor('red');return false;">■</a></li>
<li><a style="color:blue" href="#" onclick="changecolor('blue');return false;">■</a></li>
<li><a style="color:green" href="#" onclick="changecolor('green');return false;">■</a></li>
<li><a style="color:darkorange" href="#" onclick="changecolor('darkorange');return false;">■</a></li>
<li><a style="color:black" href="#" onclick="changecolor('black');return false;">■</a></li>
<li><a style="color:teal" href="#" onclick="changecolor('teal');return false;">■</a></li>
<li><a style="color:deeppink" href="#" onclick="changecolor('deeppink');return false;">■</a></li>
<li><a style="color:blueviolet" href="#" onclick="changecolor('blueviolet');return false;">■</a></li>
<li><a style="color:springgreen" href="#" onclick="changecolor('springgreen');return false;">■</a></li>
</ul>
</div>
<div id="ppjoke_exdiv" style="display:none;">
<ul id="ppjoke_onlinelist">
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript">
ppjokeinit();
</script>
此外最近一直在研究持续连接技术,也就是所谓的推技术,还有jssocket等企业级的类ajax技术,希望有经验的朋友交流。
屁屁聊天 ppjoke
功能/特点
基于ajax技术
运用了成熟稳定的prototype/scriptaculous框架
数据传送量小
页面嵌入聊天
自定义强突出个性化
支持换肤
支持表情
支持拖动 放大
更改颜色
ppjoke是根据我以前写的otalk重写的。演示地址,向右转--> 已经嵌入到了我blog中。
http://www.ppjoke.com
ppjoke整站提供下载。
修改界面颜色
见rar中'ppjoke/ppjoke.css'只要相应修改成网站配色就ok
网页集成说明
将rar中的ppjoke复制到要嵌入页面的目录中,将index.htm中的一下代码复制到网页中向嵌入的div中即可
复制代码 代码如下:
<script type="text/javascript">
document.write("<div id ='load'>正在加载....</div>");
var style = document.createelement("link");
style.rel="stylesheet";
style.type="text/css";
style.href='ppjoke/ppjoke.css';
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.createelement('span');
msg2face($f('talk'),msgspan);
msgspan.style.color=talkcolor;
p.appendchild(userspan);
p.appendchild(msgspan);
$('ppjoke_msgbox').appendchild(p);
}
field.clear('talk');
field.select('talk');
$('ppjoke_msgbox').scrolltop=$('ppjoke_msgbox').scrollheight;
function ajaxerro(){
sysinf(info_talkfail);
}
}
//发送登陆信息
function sendlogin (){
var timestamps = new date().gettime()+math.random();
creatinfo(barinf_logining);
var sendajax = new ajax.request(talkpath+'?act=login×tamp='+timestamps,{method: 'post',parameters:form.serialize('logform'),oncomplete:sendloginok});
function sendloginok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_loginready);
$('alogin').style.display='none';
$('ppjoke_alogout').style.display='inline';
$('name').value=$f('regname');
$('name').blur();
$('name').disabled = 'true';
effect.slideup('ppjoke_logdiv',{duration:1.0});
field.select('talk');
creactcookie();
}else{
creatinfo(barinf_loginerro);
}
}
}
//发送注册信息
function sendreg (){
var timestamps = new date().gettime()+math.random();
creatinfo(barinf_regging);
var sendajax = new ajax.request(talkpath+'?act=reg×tamp='+timestamps,{method: 'post',parameters:form.serialize('logform'),oncomplete:sendregok});
function sendregok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_regok);
$('alogin').style.display='none';
$('ppjoke_alogout').style.display='inline';
$('name').value=$f('regname');
$('name').blur();
$('name').disabled = 'true';
effect.slideup('ppjoke_logdiv',{duration:1.0});
field.select('talk');
creactcookie();
}else{
creatinfo(barinf_regerro);
}
}
}
//发送注销信息
function sendlogout (){
var timestamps = new date().gettime()+math.random();
var sendajax = new ajax.request(talkpath+'?act=logout×tamp='+timestamps,{method: 'get',parameters:'',oncomplete:sendlogoutok});
function sendlogoutok(req){
if(req.responsetext=="ok"){
creatinfo(barinf_logoutok);
$('ppjoke_logdiv').style.display='none';
$('alogin').style.display='inline';
$('ppjoke_alogout').style.display='none';
$('name').value=anonymous;
$('name').blur();
$('name').disabled = ''
field.select('talk');
clearchat() ;
}else{
creatinfo(barinf_logouterro);
}
}
}
function msg2face(msg,element){
var msgtext=$a(msg.match(/([^\[]*)(\[\d\d\])?/gim));
if(msgtext[0]){
msgtext.each(function(word){
var section = word.match(/([^\[]*)\[?(\d\d)?\]?/i);
if(section[1]){
var msgtext = document.createtextnode(section[1]);
element.appendchild(msgtext);
}
if(section[2]){
msgimg = document.createelement('img');
msgimg.setattribute('src','ppjoke/images/smilies/face_'+section[2]+'.gif');
element.appendchild(msgimg);
}
}
);
}else{
element.appendchild(document.createtextnode(msg));
}
}
function creatinfo(text){
$('ppjoke_otherinf').innerhtml=text;
window.settimeout(function(){$('ppjoke_otherinf').innerhtml=""},5000);
}
function sysinf(text){
var p = builder.node('p',{style:'background-color:yellow'},[builder.node('span',{style:'color:red'},'系统 '),builder.node('span',{style:'color:blue'},text)]);
$('ppjoke_msgbox').appendchild(p);
$('ppjoke_msgbox').scrolltop=$('ppjoke_msgbox').scrollheight;
}
ajax.responders.register(
{
oncreate: function(){
//creatinfo(nomemotimes);
$('ajaxing').show();
},
oncomplete: function() {
if(ajax.activerequestcount == 0){
$('ajaxing').hide();
}
}
}
);
function createfacelist(){
for (i=1;i<=24;i++){
var j=i
if(j<10){j='0'+i}
var a = builder.node('a', {href:'#'},[builder.node('img',{src:'ppjoke/images/smilies/face_'+j+'.gif'},[])]);
a.alt=j;
a.onclick=function(){$('talk').value=$f('talk')+'['+this.alt+']';field.focus('talk');return false;};
var li = builder.node('li', {},[a]);
$('ppjoke_facelist').appendchild(li);
}
}
function changecolor(color){
talkcolor=color;
}
function creactcookie(){
var mydate = new date();
mydate.settime(mydate.gettime() + 48*60*60*100);
document.cookie = "ppjokeusername="+escape($f('regname'))+";expires="+mydate.togmtstring();
document.cookie = "ppjokepass="+escape($f('regpass'))+";expires="+mydate.togmtstring();
}
function getcookie(){
var value = unescape(document.cookie);
var namepos = value.indexof("ppjokeusername=");
if(namepos!=-1){
var start = namepos + 14;
var end = value.indexof(";",start);
if (end == -1) end = value.length;
cookiename = value.substring(start,end);
}
var passpos = value.indexof("ppjokepass=");
if(passpos!=-1){
var start = passpos + 10;
var end = value.indexof(";",start);
if (end == -1) end = value.length;
cookiepass = value.substring(start,end);
}
}
function delcookie(sname,svalue){
document.cookie = sname + "=" + escape(svalue) + ";expires=fri, 31 dec 1999 23:59:59 gmt;";
}
function clearchat(){
var ps = $a($('ppjoke_msgbox').getelementsbytagname('p'));
ps.each(function(p){
element.remove(p);
}
);
}
</script>
<div id="ppjoke">
<div id="ppjoke_main">
<div id="ppjoke_topbar"><a href="javascript:void(0)" onclick="ppjokews.letback()">x</a><a href="javascript:void(0)" onclick="ppjokews.letbig()">b</a><a href="javascript:void(0)" onclick="void(0)">f</a></div>
<div id="ppjoke_msgbox"></div>
<div id="ppjoke_infbox">
<span id="ppjoke_otherinf"></span>
<span id="ajaxing"><img src="ppjoke/images/ajaxing.gif" alt="doing" /></span>
</div>
<div id="ppjoke_operbox">
<div id="ppjoke_sendbox">
<form id="talkform" action="#">
<input type="text" name="name" class="smallinput" id = "name" value="匿名" />
<input type="text" name="email" class="smallinput" id="email" value="email" />
<input type="text" name="talk" class="longinput" id="talk" />
</form>
<a class="aex" href="#" onclick="clearchat(); return false;" >清屏</a>
<a id="alogin" class="aex" href="#" onclick="effect.toggle('ppjoke_logdiv','slide'); return false;" >登录</a>
<a id="ppjoke_alogout" class="aex" href="#" onclick="sendlogout(); return false;" >注销</a>
<a class="aex" href="#" onclick="effect.toggle('ppjoke_facediv','slide'); return false;" >:)</a>
<a class="aex" href="#" onclick="effect.toggle('ppjoke_colordiv','slide'); return false;" >色</a>
</div>
<div id="ppjoke_facediv" style="display:none;">
<ul id="ppjoke_facelist">
</ul>
</div>
<div id="ppjoke_logdiv" style="display:none;">
<form id="logform" action="#">
<input type="text" name="regname" class="smallinput" id = "regname" value="username" />
<input type="password" name="regpass" class="smallinput" id="regpass" value="pass" />
<a href="#" class="aex" onclick="sendlogin();return false;" >确定</a>
<a href="#" class="aex" onclick="sendreg();return false;" >注册</a>
</form>
</div>
<div id="ppjoke_colordiv" style="display:none;">
<ul >
<li><a style="color:red" href="#" onclick="changecolor('red');return false;">■</a></li>
<li><a style="color:blue" href="#" onclick="changecolor('blue');return false;">■</a></li>
<li><a style="color:green" href="#" onclick="changecolor('green');return false;">■</a></li>
<li><a style="color:darkorange" href="#" onclick="changecolor('darkorange');return false;">■</a></li>
<li><a style="color:black" href="#" onclick="changecolor('black');return false;">■</a></li>
<li><a style="color:teal" href="#" onclick="changecolor('teal');return false;">■</a></li>
<li><a style="color:deeppink" href="#" onclick="changecolor('deeppink');return false;">■</a></li>
<li><a style="color:blueviolet" href="#" onclick="changecolor('blueviolet');return false;">■</a></li>
<li><a style="color:springgreen" href="#" onclick="changecolor('springgreen');return false;">■</a></li>
</ul>
</div>
<div id="ppjoke_exdiv" style="display:none;">
<ul id="ppjoke_onlinelist">
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript">
ppjokeinit();
</script>
上一篇: AJAX 进度条实现代码
下一篇: ajax 检测用户名是否被占用