本文主要是介绍论坛转帖专用工具源代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<HTML>
<HEAD>
<TITLE>论坛转帖专用工具</TITLE>
<SCRIPT language=JavaScript>
<!--
function SymError()
{
return true;
}
window.onerror = SymError;
//-->
</SCRIPT>
<SCRIPT language=JavaScript1.2>
function delnull()
{
var str=document.getElementById('text').value;
str=str.replace(/([/s]*/r/n[/s]*){2,}/gm,"/r/n");
document.getElementById('text').value=str;
}
function refix()
{
var str=document.getElementById('text').value;
str=str.replace(/([/s]*/r/n[/s]*){2,}/gm,"/r/n/r/n");
document.getElementById('text').value=str;
}
function url()
{
var str=document.getElementById('text').value;
str=str.replace(/^[ ]*(http:|^mms:|rtsp:|pnm:|ftp:|mmst:|mmsu:)([^/r/n]*)$/igm,"[url]$1$2[/url]");
document.getElementById('text').value=str;
}
function addbr()
{
var str=document.getElementById('text').value;
str=str.replace(//r/n/gm,"/r/n/r/n");
document.getElementById('text').value=str;
}
function html_trans(str) {
str = str.replace(//r/g,"");
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/<script[^>]*?>([/w/W]*?)<//script>/ig,"");
if(set.filtrate.checked)
{
str = str.replace(/[^<]*<([^>]*?)>[^<]*/ig,"<$1>");
tm=window.textfield.value;
if(tm.length<1){
var arr;
arr=str.match(/<img[^>]+src=[" ]?([^"]+)[" ]?[^>]*>/ig);
tm=arr[0].replace(/<img[^>]+src=[" ]?([^"]+)[" ]?[^>]*>/ig,"$1")+"/"";
i=tm.search(///[^//]+"/ig);
tm=tm.substr(0,i);
window.textfield.value=tm+"/";
}
if(tm.substr(tm.length-1,1)!="/") tm+="/";
var strtm="<img[^>]+src=[/"]?("+tm+"[^/"]+)[/"]?[^>]*>";
var re = new RegExp(strtm,"ig");
str = str.replace(re,"/n[img]$1[/img]/n");
}
else
{
if(set.stext.checked) str = str.replace(/[^<]*<([^>]*?)>[^<]*/ig,"<$1>");
if(!set.linka.checked) str = str.replace(/<a[^>]+href=[" ]?([^"]+)[" ]?[^>]*>(.*?)<//a>/ig,"[url=$1]$2[/url]");
if(!set.font_color.checked&&!set.stext.checked)
str = str.replace(/<font([^>]+)color=([^ >]+)([^>]*)>(.*?)<//font>/ig,"[color=$2]<font$1$3>$4</font>[/color]");
if(!set.font_size.checked&&!set.stext.checked)
str = str.replace(/<font([^>]+)size=([^ >]+)([^>]*)>(.*?)<//font>/ig,"[size=$2]<font$1$3>$4</font>[/size]");
if(!set.font_face.checked&&!set.stext.checked)
str = str.replace(/<font[^>]+face=([^ >]+)[^>]*>(.*?)<//font>/ig,"[font=$1]$2[/font]");
if(!set.img.checked) str = str.replace(/<img[^>]+src=[" ]?([^"]+)[" ]?[^>]*>/ig,"/n[img]$1[/img]/n");
if(!set.odj.checked){
//return str;
str = str.replace(/<object[^>]*classid=[" ]?clsid:D27CDB6E/-AE6D/-11cf/-96B8/-444553540000[" ]?[^>]*>(.*?)<param[^>]+name=[" ]?movie[" ]?[^>]+value=[" ]?([^"]+)[" ]?[^>]*>/ig,"/n[swf]$2[/swf]/n");
str = str.replace(/<embed[^>]*type=["]?application//x/-shockwave/-flash["]?[^>]*src=[" ]?([^"|^ ]+)[" ]?[^>]*>/ig,"/n[swf]$1[/swf]/n");
str = str.replace(/<embed[^>]*src=["]?([^"|^ ]+)["]?[^>]*type=["]?application//x/-shockwave/-flash["]?[^>]*>/ig,"/n[swf]$1[/swf]/n");
str = str.replace(/<object[^>]*classid=[" ]?clsid:CFCDAA03/-8BE4/-11cf/-B84B/-0020AFBBCCFA[" ]?[^>]*>.*<param[^>]+name="src"[^>]+value="([^"]+)">/ig,"/n[rm]$1[/rm]/n");
}
if(!set.font_b.checked&&!set.stext.checked){
str = str.replace(/<([//]?)b>/ig,"[$1b]");
str = str.replace(/<([//]?)strong>/ig,"[$1b]");}
if(!set.font_u.checked&&!set.stext.checked)
str = str.replace(/<([//]?)u>/ig,"[$1u]");
if(!set.font_i.checked&&!set.stext.checked)
str = str.replace(/<([//]?)i>/ig,"[$1i]");
str = str.replace(/ /g," ");
str = str.replace(/&/g,"&");
str = str.replace(/"/g,"/"");
str = str.replace(/</g,"<");
str = str.replace(/>/g,">");
}
str = str.replace(/<br>/ig,"/n");
str = str.replace(/<p[^>]*?>/ig,"/n/n");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(//[url=([^/]]+)/]/n(/[img/]/1/[//img/])/n/[//url/]/g,"$2");
str = str.replace(//n+/g,"/n");
return str;
}
function copycode(obj){
obj.select();
objcopy=obj.createTextRange();
objcopy.execCommand("Copy");
}
function trans(){
var str = "";
rtf.focus();
rtf.document.body.innerHTML = "";
rtf.document.execCommand("paste");
str = rtf.document.body.innerHTML;
if(str.length == 0) {
alert("剪贴版不存在超文本数据!");
return "";
}
return html_trans(str);
}
function preview(){
var prewin=window.open("","","");
prewin.document.write(rtf.document.body.innerHTML);
}
function zhen(str)
{
strfound=str.replace(ig,"");
strfound=strfound.replace(//[/ig,"//[");
strfound=strfound.replace(//]/ig,"//]");
strfound=strfound.replace(//{/ig,"//{");
strfound=strfound.replace(//}/ig,"//}");
strfound=strfound.replace(//|/ig,"//|");
strfound=strfound.replace(ig,"///");
strfound=strfound.replace(//^/ig,"//^");
strfound=strfound.replace(//./ig,"//.");
strfound=strfound.replace(//*/ig,"//*");
strfound=strfound.replace(//?/ig,"//?");
strfound=strfound.replace(//+/ig,"//+");
return strfound;
}
function replace_star()
{
var str=document.getElementById('text').value;
if(!reg.checked)
strfound=zhen(find_text.value);
else
strfound=find_text.value;
var re = new RegExp(strfound,"ig");
str=str.replace(re,replace_text.value);
document.getElementById('text').value=str;
}
</SCRIPT>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="css.css" type=text/css rel=stylesheet>
<STYLE type=text/css>
UNKNOWN {
SCROLLBAR-FACE-COLOR: #dbd8b0; FONT-SIZE: 9pt; SCROLLBAR-HIGHLIGHT-COLOR: #000000; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-3DLIGHT-COLOR: #c0c0c0; SCROLLBAR-ARROW-COLOR: #000000; SCROLLBAR-TRACK-COLOR: #dbd8b0; SCROLLBAR-DARKSHADOW-COLOR: #dbd8b0
}
A.a007:link {
FONT-SIZE: 10pt; COLOR: #ff0000; TEXT-DECORATION: none
}
A.a007:visited {
FONT-SIZE: 10pt; COLOR: #ff0000; TEXT-DECORATION: none
}
A.a007:active {
FONT-SIZE: 10pt; COLOR: #ff0000; TEXT-DECORATION: none
}
A.a007:hover {
FONT-SIZE: 10pt; COLOR: #000000; TEXT-DECORATION: underline
}
A.a006:link {
FONT-SIZE: 10pt; COLOR: #1b4e9a; TEXT-DECORATION: none
}
A.a006:visited {
FONT-SIZE: 10pt; COLOR: #0064a8; TEXT-DECORATION: none
}
A.a006:active {
FONT-SIZE: 10pt; COLOR: #1b4e9a; TEXT-DECORATION: none
}
A.a006:hover {
FONT-SIZE: 10pt; COLOR: #ff0000; TEXT-DECORATION: underline
}
A.a01:link {
FONT-SIZE: 9pt; COLOR: #205ab3; TEXT-DECORATION: none
}
A.a01:visited {
FONT-SIZE: 9pt; COLOR: #205ab3; TEXT-DECORATION: none
}
A.a01:active {
FONT-SIZE: 9pt; COLOR: #205ab3; TEXT-DECORATION: none
}
A.a01:hover {
FONT-SIZE: 9pt; COLOR: red; TEXT-DECORATION: underline
}
A.a02:link {
FONT-SIZE: 9pt; COLOR: #ffffff; TEXT-DECORATION: none
}
A.a02:visited {
FONT-SIZE: 9pt; COLOR: #ffffbb; TEXT-DECORATION: none
}
A.a02:hover {
FONT-SIZE: 9pt; COLOR: #ffff00; TEXT-DECORATION: underline
}
A:link {
COLOR: #000000; TEXT-DECORATION: none
}
A:visited {
COLOR: #000000; TEXT-DECORATION: none
}
A:active {
COLOR: #000000; TEXT-DECORATION: none
}
A:hover {
COLOR: red
}
.input {
BORDER-RIGHT: rgb(0,0,0) 1px solid; BORDER-TOP: rgb(0,0,0) 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 11pt; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-BOTTOM: rgb(0,0,0) 1px solid; FONT-FAMILY: "Arial"; BACKGROUND-COLOR: transparent
}
TD {
FONT-SIZE: 9pt
}
.text8 {
FONT-SIZE: 8pt
}
.text9 {
FONT-SIZE: 9pt
}
.text10 {
FONT-SIZE: 10pt
}
.text11 {
FONT-SIZE: 11pt
}
.text12 {
FONT-SIZE: 12pt
}
.fire {
FONT-SIZE: 9pt; FILTER: glow( color=#ffcc00,strengh=0); WIDTH: auto; POSITION: relative; HEIGHT: auto
}
.newfont7 {
FONT-SIZE: 9pt; FILTER: dropshadow(color=#ffffcc,offx=1,offy=1); COLOR: #333333; FONT-FAMILY: "宋体"
}
.comment_text {
FONT-SIZE: 14px; LINE-HEIGHT: 20px; LETTER-SPACING: 1px
}
.style3 {
COLOR: #990000
}
.style4 {
COLOR: #333333
}
.style5 {
COLOR: #ffffff
}
</STYLE>
</HEAD>
<BODY bgColor=#eeeeee leftMargin=0 topMargin=0>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=0></TD></TR></TBODY></TABLE>
<TABLE style="BORDER-COLLAPSE: collapse" height=459 cellSpacing=0 cellPadding=0
width=645 align=center border=0>
<TBODY>
<TR>
<TD align=middle width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="99%" border=0>
<TBODY>
<TR><TD bgcolor="#AD0000" height="40" width="99%"> <font color=#ffffff size=3><center><B>论坛转帖精灵</B></center></font></TD></TR>
<TR>
<TD align=middle bgColor=#f8f8f8>
<DIV align=center><TEXTAREA class=textarea onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}" id=text style="WIDTH: 640px; HEIGHT: 230px" cols=100></TEXTAREA> <IFRAME id=rtf
style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0
src="about:blank" scrolling=no></IFRAME><LABEL
for=x_paste></LABEL></DIV>
<TABLE borderColor=#cccccc cellSpacing=1 width=640 align=center
bgColor=#AD0000 border=0>
<TBODY>
<TR align=middle>
<TD width="25%">
<DIV align=left><INPUT style="WIDTH: 130px; HEIGHT: 40px" οnclick="document.getElementById('text').value += trans();" type=button value=追加转换剪贴板数据 name=button>
</DIV></TD>
<TD width="25%">
<P align=center><INPUT style="WIDTH: 130px; HEIGHT: 40px" οnclick=copycode(window.text) type=button value=将代码复制到剪贴板>
</P></TD>
<TD width="21%">
<DIV align=center>
<INPUT οnclick=preview() type=button value=" 预 览 帖 子 " style="WIDTH: 100px; HEIGHT: 20px" name=preview>
</DIV>
<DIV align=center><INPUT style="WIDTH: 100px; HEIGHT: 20px" οnclick="document.getElementById('text').value=''" type=button value="清 空 内 容">
</DIV>
</TD>
<TD width="29%">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR align=middle>
<TD>
<DIV align=center><INPUT title="自动分析所有超链接,并转换成超链接格式 注意:超链接必须单独在一行中!" style="WIDTH: 80px" οnclick=url() type=button value=分析超链接 name=Submit>
</DIV></TD>
<TD>
<DIV align=center><INPUT title=紧凑格式,删除所有空行 style="WIDTH: 80px" οnclick=delnull() type=button value=清除空行 name=Submit>
</DIV></TD></TR>
<TR align=middle>
<TD>
<DIV align=center><INPUT title=清除多余的空行,保持最一个空行 style="WIDTH: 80px" οnclick=refix() type=button value=清除多余 name=Submit>
</DIV></TD>
<TD>
<DIV align=center><INPUT title=为每一行(包括空行)增加一空行 style="WIDTH: 80px" οnclick=addbr() type=button value=增加空行 name=Submit>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<FORM name=set>
<TABLE height=40 cellSpacing=0 cellPadding=0 width="650"
border=0><TBODY>
<TR>
<TD title=转换的结果中将不含有图片信息 width="13%" height=20><LABEL
for=img><INPUT id=img type=checkbox> <SPAN
class=style4>屏蔽图片</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有链接信息 width="14%"><LABEL for=linka><INPUT
id=linka type=checkbox> <SPAN
class=style4>屏蔽超链接</SPAN></LABEL></TD>
<TD title=转换的结果中将不含音频、视频、FLASH等信息 width="14%"><LABEL
for=odj><INPUT id=odj type=checkbox> <SPAN
class=style4>屏蔽对象</SPAN></LABEL></TD>
<TD title=转换的结果中将不含文本信息,同时字体属性将被自动屏蔽 width="14%"><LABEL
for=stext><INPUT id=stext type=checkbox> <SPAN
class=style4>屏蔽文字</SPAN></LABEL></TD>
<TD title=为了方便帖子的阅读,强制把图片用空行隔开 width="14%"><LABEL
for=filtrate><INPUT id=filtrate
οnclick="if(this.checked)window.base_url.style.display='block';else window.base_url.style.display='none';"
type=checkbox> <SPAN class=style4>启用图片过滤</SPAN></LABEL></TD>
<TD title=屏蔽所有定字体相关的属性 width="14%"><LABEL for=font><INPUT
id=font
οnclick=font_color.checked=this.checked;font_size.checked=this.checked;font_face.checked=this.checked;font_b.checked=this.checked;font_i.checked=this.checked;font_u.checked=this.checked;
type=checkbox> <SPAN class=style4>屏蔽字体属性</SPAN></LABEL></TD></TR>
<TR>
<TD title=转换的结果中将不含有字体颜色信息><LABEL for=font_color><INPUT
id=font_color type=checkbox> <SPAN
class=style4>屏蔽字体颜色</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有字体尺寸信息><LABEL for=font_size><INPUT
id=font_size type=checkbox> <SPAN
class=style4>屏蔽字体尺寸</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有字体类型信息><LABEL for=font_face><INPUT
id=font_face type=checkbox> <SPAN
class=style4>屏蔽字体类型</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有粗体信息><LABEL for=font_b><INPUT id=font_b
type=checkbox> <SPAN class=style4>屏蔽粗体</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有斜体信息><LABEL for=font_i><INPUT id=font_i
type=checkbox> <SPAN class=style4>屏蔽斜体</SPAN></LABEL></TD>
<TD title=转换的结果中将不含有下划线信息><LABEL for=font_u><INPUT id=font_u
type=checkbox> <SPAN
class=style4>屏蔽下划线</SPAN></LABEL></TD></TR></TBODY></TABLE></FORM>
<TABLE borderColor=#efefef cellSpacing=2 cellPadding=2 width=640
bgColor=#AD0000 border=0>
<TBODY>
<TR>
<TD class=text11 align=middle width="82%"><SPAN
class="text9 style5">查找文字</SPAN> <INPUT id=find_text size=40
name=find_text> <INPUT οnclick="set.reset();find_text.value='';replace_text.value='';window.textfield.value='';" type=button value=全恢复默认 name=Submit>
</TD>
<TD class=text11 align=middle width="18%" rowSpan=2><LABEL
for=reg><INPUT id=reg type=checkbox CHECKED value=1 name=reg>
<SPAN class="text9 style5">使用正则语法</SPAN></LABEL> </TD></TR>
<TR>
<TD class=text11 align=middle><SPAN
class="text9 style5">替换文字</SPAN> <INPUT id=replace_text
size=40 name=replace_text> <INPUT οnclick=replace_star() type=button value=" 开始替换 " name=Submit></TD></TR></TBODY></TABLE><BR><BR></TD></TR>
<TR bgcolor=#f8f8f8><TD>
<B>使用说明:</B><BR>
1.在网页中拖动鼠标选中你想要的图片或文字,然后鼠标右键“复制(C)”或按Ctrl+C。<BR>
2.进入该页面,直接按下“追加转换剪贴板数据”。<BR>
3.复制文本筐中的数据,按下“将代码复制到剪贴板”。<BR>
4.进入论坛发贴页面,鼠标右键“粘贴(P)”或按Ctrl+V将帖子内容复制到帖子内容筐。
</TD></TR>
<TR bgcolor=#f8f8f8><TD align=center>
<BR><B>友情链接</B>
<BR><B><a href=http://blog.csdn.net/telnetor target=_blank><font color=blue>幻境重生</font></a></B><BR>
</TD></TR>
</TBODY></TABLE>
<SCRIPT>
rtf.document.designMode="On";
</SCRIPT>
</TD></TR>
</TBODY>
</TABLE>
<div>
<center></center>
</div>
</BODY>
</HTML>
这篇关于论坛转帖专用工具源代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!