代码收集:http://www.xnei.net转载请注明/*
* 名 称:Yoyu留言板
* 版 本:4.1
* 创作时间:2006-10-28
* E_mail:staryxy@gmail.com
* 主要功能:在校内网个人留言板中,添加网络图片、QQ表情、链接的功能。有效范围在首页范围内
* 表情定义:可以参考http://group.xiaonei.com/GetThread.do?id=814029 帖子
* 使用说明:将下一行代码,添加到涂鸦板(建议将JS文件下载另行保存到网络空间,在修改下面的JS文件地址):
* <img style="display:none" src='javasc ript:var s2 = document.createElement("scr"+"ipt"); s2.src="YoyuTaler_3_2.js"; document.body.insertAdjacentElement("BeforeBegin",s2);'>
* 参考效果:http://xiaonei.com/getuser.do?id=64319898 (可能页面上的版本有所更新而与此不合)
* 修 改: 3.1根据XiaoNei赵明文(http://xiaonei.com/getuser.do?id=32663187) 的建议,将链接功能扩大,可以显示指定的字符
* 3.2实现了指定位置插入各种元素,恢复了所有表情(96种)显示,猥琐地添加了一个©信息,哈哈
* 3.3修改了一个Bug[Hsueh Billy(http://xiaonei.com/getuser.do?id=79126861)和赵明文(http://xiaonei.com/getuser.do?id=32663187)发现]:我给别人的留言后,会出现错误内容,导致别人无法直接回复
*/
var windowstatus='';
var userId='';
var FaceList=new Array(//标题(匹配字符) ,图片地址
new Array("幸福","http://img.xiaonei.com/photos/20060911/2040/orig74543.gif",/\[幸福\]/g ) ,
new Array("呵呵","http://img.xiaonei.com/photos/20060911/2050/orig74598.gif",/\[呵呵\]/g ) ,
new Array("晕哪","http://img.xiaonei.com/photos/20060911/2050/orig68672.gif",/\[晕哪\]/g ) ,
new Array("??","http://img.xiaonei.com/photos/20060911/2050/orig74755.gif",/\[??\]/g ) ,
new Array("激动","http://img.xiaonei.com/photos/20060911/2050/orig69189.gif",/\[激动\]/g ) ,
new Array("漂亮","http://img.xiaonei.com/photos/20060911/2220/orig74455.gif",/\[漂亮\]/g ) ,
new Array("开心","http://img.xiaonei.com/photos/20060911/2120/orig76717.gif",/\[开心\]/g ) ,
new Array("呀呀","http://img.xiaonei.com/photos/20060911/2130/orig71158.gif",/\[呀呀\]/g ) ,
new Array("886","http://img.xiaonei.com/photos/20060911/2130/orig77217.gif",/\[886\]/g ) ,
new Array("汗哪","http://img.xiaonei.com/photos/20060911/2210/orig80107.gif",/\[汗哪\]/g ) ,
new Array("哦!","http://img.xiaonei.com/photos/20060911/2210/orig74195.gif",/\[哦!\]/g ) ,
new Array("哈哈","http://img.xiaonei.com/photos/20060911/2230/orig225602.gif",/\[哈哈\]/g ) ,
new Array("嘻嘻","http://img.xiaonei.com/photos/20060911/2230/orig27617.gif",/\[嘻嘻\]/g )
);
//修改留言板内容
TalkSetted = false;
function SetTalk()
{
try
{
if(document.getElementById('talk')!=null && TalkSetted==false){
var html = talk.innerHTML;
var plFace = '';
//采用正则表达式方式提换[url]和[img]标签
var reImg = /\[img\]((http:(\/\/|\\\\)){1}((\w)+[.]){1,3}(((\/[\~]*|\\[\~]*)(\w)+)|[.](\w)+)*(\w)+[^\]]+)\[\/img\]/g; // '查找图片地址
var plImg = " <img src='$1'> ";
var reImg1= /\[img=([^\]]+)\]([^\]]+)\[\/img\]/g;
var plImg1= " <img src='$1' title='$2' alt='$2'> "
var reUrl = /\[url\]((http:(\/\/|\\\\)){1}((\w)+[.]){1,3}(((\/[\~]*|\\[\~]*)(\w)+)|[.](\w)+)*(\w)+[^\]]+)\[\/url\]/g;
var plUrl = " <a href='$1' target=_blank title='打开链接'>$1</a> "
var reUrl1= /\[url=([^\]]+)\]([^\]]+)\[\/url\]/g;
var plUrl1= " <a href='$1' target=_blank title='打开链接'>$2</a> "
html = html.replace(/alt=M-aple/g,"alt=上杉枫木");
html = html.replace(/>M-aple/g,"><a href=http://wpa.qq.com/msgrd?Uin=262235780 target=_blank><font title=上杉枫木 [校内网特约嘉宾]>上杉枫木 [校内网<font color=red>特约嘉宾</font>]</font></a>");
for(i=0;i<FaceList.length;++i)
{
plFace = '<img src="'+FaceList[i][1]+'" alt="'+FaceList[i][0]+'" " title="'+FaceList[i][0]+'">';
html = html.replace(FaceList[i][2],plFace);
}
html = html.replace(reImg,plImg);
html = html.replace(reImg1,plImg1);
html = html.replace(reUrl,plUrl);
html = html.replace(reUrl1,plUrl1);
talk.innerHTML = html;
window.status=windowstatus;
windowstatus = null;
html = null;
plFace=null;
reImg=null;
reImg1=null;
reUrl=null;
reUrl1=null;
plImg=null;
plImg1=null;
plUrl=null;
plUrl1=null;
TalkSetted = true;
}
}
catch(ex)
{window.status="M-aple:留言板不能正常显示......";}
return true;
}
//留言板中添加图片操作
function addImg()
{
if(document.getElementById("imgUrl").value==""){
document.getElementById("imgUrl").value="http:\/\/";
return;
}
if(document.getElementById("imgTitle").value==""){
insertAtCaret(document.getElementById("cmtbody") , '[img]'+document.getElementById("imgUrl").value+'[\/img]' );
}
else{
insertAtCaret(document.getElementById("cmtbody") , '[img='+document.getElementById("imgUrl").value+']'+document.getElementById("imgTitle").value+'[\/img]' );
}
document.getElementById("imgUrl").value = 'http:\/\/';
document.getElementById("imgTitle").value = '';
}
[1] [2] 下一页