当前位置:  编程技术>其它

ubb js

    来源: 互联网  发布时间:2014-10-12

    本文导语:  strIcons = "1"  //允许笑脸转换strSmile="1"   //同上ImgName="em"picurl="/images/emot/" function UBBCode(content,html){    content=content.replace("\r","");    content=content.replace("\n","");    return (trans(content));} function trans(strContent){    var re;  re=/[IMG](.+?...

strIcons = "1"  //允许笑脸转换
strSmile="1"   //同上
ImgName="em"
picurl="/images/emot/"

function UBBCode(content,html){
    content=content.replace("\r","");
    content=content.replace("\n","");
    return (trans(content));
}


function trans(strContent){
    var re;

 re=/[IMG](.+?)[/IMG]/ig;
 strContent=strContent.replace(re,"

按此在新窗口浏览图片
");
 re=/[DIR=*([0-9]*),*([0-9]*)](.*?)[/DIR]/ig
 strContent=strContent.replace(re,"")
 re=/[QT=*([0-9]*),*([0-9]*)](.*?)[/QT]/ig
 strContent=strContent.replace(re,"")
 re=/[MP=*([0-9]*),*([0-9]*)](.*?)[/MP]/ig
 strContent=strContent.replace(re,"")
 re=/[RM=*([0-9]*),*([0-9]*)](.*?)[/RM]/ig
 strContent=strContent.replace(re,"
")


 re=/([FLASH])(.*?)([/FLASH])/ig
 strContent= strContent.replace(re,"$2")
 re=/([FLASH=*([0-9]*),*([0-9]*)])(.*?)([/FLASH])/ig
 strContent= strContent.replace(re,"点击开新窗口欣赏该FLASH动画! [全屏欣赏]

$4")

 re=/([UPLOAD=gif])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片")
 re=/([UPLOAD=jpg])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片")
 re=/([UPLOAD=png])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
此主题相关图片如下:
按此在新窗口浏览图片")

 re=/([UPLOAD=swf])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
点击开新窗口欣赏该FLASH动画! [全屏欣赏]

$2")

 re=/([UPLOAD=asf])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")
 re=/([UPLOAD=avi])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")
 re=/([UPLOAD=mpg])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")
 re=/([UPLOAD=wmv])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")

 re=/([UPLOAD=mp3])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")
 re=/([UPLOAD=wav])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")
 re=/([UPLOAD=mid])(.*?)([/UPLOAD])/ig
 strContent= strContent.replace(re,"
")

    re=/([UPLOAD=(.[^[]*)])(.*?)([/UPLOAD])/ig
    strContent= strContent.replace(re,"
点击浏览该文件")

    re=/([refer=(d{1,}),(.*?)])(.*?)([/refer])/ig
    strContent=strContent.replace(re,"回复$2楼$3发表: $4 ");

 re=/([URL])(.*?)([/URL])/ig
 strContent= strContent.replace(re,"$2")
 re=/([URL=(.[^[]*)])(.*?)([/URL])/ig
 strContent= strContent.replace(re,"$3")

 re=/([EMAIL])(.*?)([/EMAIL])/ig
 strContent= strContent.replace(re,"$2")
 re=/([EMAIL=(.[^[]*)])(.*?)([/EMAIL])/ig
 strContent= strContent.replace(re,"$3")

 re =/^(http://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/(http://[A-Za-z0-9./=?%-&_~`@':+!]+)$/ig
 strContent = strContent.replace(re,"$1")
 re =/[^>=""](http://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/^(ftp://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/(ftp://[A-Za-z0-9./=?%-&_~`@':+!]+)$/ig
 strContent = strContent.replace(re,"$1")
 re =/[^>=""](ftp://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/^(rtsp://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/(rtsp://[A-Za-z0-9./=?%-&_~`@':+!]+)$/ig
 strContent = strContent.replace(re,"$1")
 re =/[^>=""](rtsp://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/^(mms://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")
 re =/(mms://[A-Za-z0-9./=?%-&_~`@':+!]+)$/ig
 strContent = strContent.replace(re,"$1")
 re =/[^>=""](mms://[A-Za-z0-9./=?%-&_~`@':+!]+)/ig
 strContent = strContent.replace(re,"$1")

 if(strIcons == "1"){                       //笑脸转换
 re=/([em(.*?)])/ig
 strContent=strContent.replace(re," ")
 }

 if(strSmile == "1"){                       //笑脸转换
 re=/([s(d{1,2})])/ig
 strContent=strContent.replace(re," ")
 }

 re=/([color=(.[^[]*)])(.*?)([/color])/ig
 strContent=strContent.replace(re,"$3")
 re=/([face=(.[^[]*)])(.*?)([/face])/ig
 strContent=strContent.replace(re,"$3")
 re=/([align=(.[^[]*)])(.*?)([/align])/ig
 strContent=strContent.replace(re,"

$3
")
//循环转换quote
 re=/([quote])(.*?)([/quote])/ig
 while(strContent.indexOf("[quote]")>-1 && strContent.indexOf("[/quote]")>0){
 strContent=strContent.replace(re,"引用:$2")
 }
 re=/([fly])(.*?)([/fly])/ig
 strContent=strContent.replace(re,"$2")
 re=/([move])(.*?)([/move])/ig
 strContent=strContent.replace(re,"$2") 
 re=/[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.*?)[/GLOW]/ig
 strContent=strContent.replace(re,"$4")
 re=/[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)](.*?)[/SHADOW]/ig
 strContent=strContent.replace(re,"$4")

 re=/([i])(.*?)([/i])/ig
 strContent=strContent.replace(re,"$2")
 re=/([u])(.*?)([/u])/ig
 strContent=strContent.replace(re,"$2")
 re=/([b])(.*?)([/b])/ig
 strContent=strContent.replace(re,"$2")

 re=/([size=1])(.*?)([/size])/ig
 strContent=strContent.replace(re,"$2")
 re=/([size=2])(.*?)([/size])/ig
 strContent=strContent.replace(re,"$2")
 re=/([size=3])(.*?)([/size])/ig
 strContent=strContent.replace(re,"$2")
 re=/([size=4])(.*?)([/size])/ig
 strContent=strContent.replace(re,"$2")

 re=/[size=([+|-]?[0-7])](.*?)([/size])/ig
 strContent=strContent.replace(re,"$2")

 re=/([list])(.+?)([/list])/ig;
    strContent=strContent.replace(re,"

    $2
");
    re=/([list=)(A|1)(])(.+?)([/list])/ig;
    strContent=strContent.replace(re,"$4");
    re=/([*])/ig;
    strContent=strContent.replace(re,"
  • ");

     re=/([center])(.*?)([/center])/ig
     strContent=strContent.replace(re,"$2")

    return(strContent);
    }


  •     
     
     

    您可能感兴趣的文章:

     
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3