欢迎来到福编程网,本站提供各种互联网专业知识!

PPJOKE 0.1 (网页嵌入聊天)提供下载

发布时间:2006-10-16 作者: 来源:转载
PPJOKE是一套基于AJAX技术网页嵌入聊天程序,目前提供asp版下载,.Net版本的负载量更高,不过还在调试中,拖了很长时间了,最近一直忙着学习,没有更新,这里先提供下载。此外最近一直在研究持续连接技术,也就是所谓的推技术,还有jssocket等企业级的类AJAX
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中即可
复制代码 代码如下:

document.write("正在加载....

");
varstyle=document.createElement("link");
style.rel="stylesheet";
style.type="text/css";
style.href='ppjoke/ppjoke.css';
style.title='ppjoke';
varhead=document.getElementsByTagName("head")[0];
head.appendChild(style);

vartalktime=3500;//设置获取内容时间间隔
vartalkpath='ppjoke/ppjoke.asp';
vartalkcolor='blue';
varinfo_shaping='请勿刷屏';
varinfo_talkfail='发送失败';
varbarinf_logining='正在登录';
varbarinf_regging='正在注册';
varbarinf_neterro='数据传输错误';
varbarinf_loginready='登陆成功';
varbarinf_loginerro='密码错误';
varbarinf_blank='请输入聊天内容';
varbarinf_logoutok='注销成功';
varbarinf_logouterro='注销失败';
varbarinf_regerro='用户名已存在';
varbarinf_regok='注册成功,自动登陆';
varbarinf_checkuser='自动登陆中';
varbarinf_checkbad='非法身份,请自行登陆';
varcolorArr=['red','blue','green','darkorange','black','teal','deeppink','blueviolet','springgreen'];
varAnonymous='匿名';

varcount=0;
varlastworld='';
varlastalk='';
varlastWorldTime=false;
vargetMsgTime;
varnoMemoTimes=0;
varcookiename;
varcookiepass;

//Event.observe(window,'load',ppjokeinit,false);

functionppjokeinit(){
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');
newDraggable('ppjoke_main',{handle:'ppjoke_topbar'});
createFaceList();
GetCookie();
logined();
}

varppjokeWs={
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';
}
}

functionkeyDownAll(event){
vare=event||window.event;
if(e.keyCode==13){sendMsg()}
}

functionlogined(){
functionloginok(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){
vartimestamps=newDate().getTime()+Math.random();
creatInfo(barinf_checkuser);
varsendAjax=newAjax.Request(talkpath+'?act=login×tamp='+timestamps,{method:'post',parameters:'regname='+cookiename+"®pass="+cookiepass,onComplete:loginok});
}
}

//获取信息
functiongetMsg(){
vartimestamps=newDate().getTime()+Math.random();
vargetAjax=newAjax.Request(talkpath+'?act=getMsg×tamps='+timestamps,{method:'get',parameters:'',onSuccess:showMsg});

functionshowMsg(req){

window.setTimeout(getMsg,talktime);

varnewMsg=eval('('+req.responseText+')');

functionappendtime(){
$('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++;
varp=document.createElement('p');
if(count%2==0){
Element.addClassName(p,'p1');
}else{
Element.addClassName(p,'p2');
}
varuserspan=document.createElement('span');
varusertext=document.createTextNode(data.u+':');
if(data.v=="True"){
userspan.appendChild(usertext);
}else{
userspan.style.color='#CACACA';
userspan.appendChild(usertext);
}
varmsgspan=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;
}
}

//发送聊天信息,处理本地消息
functionsendMsg(){
if(!Field.present('talk','name','email')){
creatInfo(barinf_blank);
return;
}

if(lastworld==Form.serialize('talkform')){
sysinf(info_shaping);
}else{

if($('thelastTime')){Element.remove('thelastTime');}

vartimestamps=newDate().getTime()+Math.random();
varsendAjax=newAjax.Request(talkpath+'?act=sendMsg&color='+talkcolor+'×tamp='+timestamps,{method:'post',parameters:Form.serialize('talkform'),onFailure:ajaxErro});
lastworld=Form.serialize('talkform');
lastalk=$F('talk');

count++;
varp=document.createElement('p');
if(count%2==0){
Element.addClassName(p,'p1');
}else{
Element.addClassName(p,'p2');
}
varuserspan=document.createElement('span');
varusertext=document.createTextNode($F('name')+':');
if($('name').disabled==true){
userspan.appendChild(usertext);
}else{
userspan.style.color='#CACACA';
userspan.appendChild(usertext);
}
varmsgspan=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;

functionajaxErro(){
sysinf(info_talkfail);
}
}

//发送登陆信息
functionsendLogin(){
vartimestamps=newDate().getTime()+Math.random();
creatInfo(barinf_logining);
varsendAjax=newAjax.Request(talkpath+'?act=login×tamp='+timestamps,{method:'post',parameters:Form.serialize('logform'),onComplete:sendLoginOk});
functionsendLoginOk(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);
}
}
}

//发送注册信息
functionsendReg(){
vartimestamps=newDate().getTime()+Math.random();
creatInfo(barinf_regging);
varsendAjax=newAjax.Request(talkpath+'?act=reg×tamp='+timestamps,{method:'post',parameters:Form.serialize('logform'),onComplete:sendRegOk});
functionsendRegOk(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);
}
}
}

//发送注销信息
functionsendLogout(){
vartimestamps=newDate().getTime()+Math.random();
varsendAjax=newAjax.Request(talkpath+'?act=logout×tamp='+timestamps,{method:'get',parameters:'',onComplete:sendLogOutOk});
functionsendLogOutOk(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);
}
}
}

functionmsg2face(msg,element){
varmsgtext=$A(msg.match(/([^[]*)([dd])?/gim));
if(msgtext[0]){
msgtext.each(function(word){
varsection=word.match(/([^[]*)[?(dd)?]?/i);
if(section[1]){
varmsgtext=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));
}
}

functioncreatInfo(text){
$('ppjoke_otherinf').innerHTML=text;
window.setTimeout(function(){$('ppjoke_otherinf').innerHTML=""},5000);
}

functionsysinf(text){
varp=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();
}
}
}
);

functioncreateFaceList(){
for(i=1;i<=24;i++){
varj=i
if(j<10){j='0'+i}
vara=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');returnfalse;};
varli=Builder.node('li',{},[a]);
$('ppjoke_facelist').appendChild(li);
}
}

functionchangeColor(color){
talkcolor=color;
}

functionCreactCookie(){
varmydate=newDate();
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();
}

functionGetCookie(){
varvalue=unescape(document.cookie);
varnamepos=value.indexOf("ppjokeusername=");
if(namepos!=-1){
varstart=namepos+14;
varend=value.indexOf(";",start);
if(end==-1)end=value.length;
cookiename=value.substring(start,end);
}
varpasspos=value.indexOf("ppjokepass=");
if(passpos!=-1){
varstart=passpos+10;
varend=value.indexOf(";",start);
if(end==-1)end=value.length;
cookiepass=value.substring(start,end);
}
}

functionDelCookie(sName,sValue){
document.cookie=sName+"="+escape(sValue)+";expires=Fri,31Dec199923:59:59GMT;";
}

functionclearChat(){
varps=$A($('ppjoke_msgbox').getElementsByTagName('p'));
ps.each(function(p){
Element.remove(p);
}
);
}


XBF










清屏
登录
注销
:)








确定
注册









ppjokeinit();


相关推荐