转贴工具代码 

2007-3-5 chenmo 网站建设

<html>
<head><title>转贴工具--爱上BBS论坛专用工具</title>
<meta name="Keywords" content="爱上BBS论坛专用工具">
<meta name="Description" content="爱上BBS论坛专用工具">
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
.STYLE2 {font-size: 12px}
.STYLE4 {font-size: 14; }
body {}
-->
</style>
<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,"$1$2");
 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.fontbash.checked)
{
 str = str.replace(/<span[^>]*?display\s*?:\s*?none[^>]*?>([\w\W]*?)<\/span>/ig,"");
 str = str.replace(/<span[^>]*?font\s*?-\s*?size\s*?:\s*(0px|0pt)[^>]*?>([\w\W]*?)<\/span>/ig,"");
 str = str.replace(/<font([^>]+)(0px|0pt)+([^>]*)>([\w\W]*?)<\/font>/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\n");
}
else
{
 if(set.stext.checked) str = str.replace(/[^<]*<([^>]*?)>[^<]*/ig,"<$1>");

 if(!set.linka.checked) str = str.replace(/<a[^>]+href=[" ]?([^"]+)[" ]?[^>]*>(.*?)<\/a>/ig,"$2");
 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\n");

 if(!set.odj.checked){
  //return str;
  str = str.replace(/<object[^>]*?6BF52A52\-394A\-11d3\-B153\-00C04F79FAA6[^>]*?>.*<param[^>]+name\s*=\s*["](url|src)["][^>]+value=[" ]?([^"]+)[" ][^>]*>.*<\/object>/ig,"\n\n");
  str = str.replace(/<object[^>]*?D27CDB6E\-AE6D\-11cf\-96B8\-444553540000[^>]*?>.*<param[^>]+name\s*=\s*["](url|src)["][^>]+value=[" ]?([^"]+)[" ][^>]*>.*<\/object>/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[^>]*?CFCDAA03\-8BE4\-11cf\-B84B\-0020AFBBCCFA[^>]*?>.*<param[^>]+name\s*=\s*["](url|src)["][^>]+value=[" ]?([^"]+)[" ][^>]*>.*<\/object>/ig,"\n\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(/&nbsp;/g," ");
 str = str.replace(/&amp;/g,"&");
 str = str.replace(/&quot;/g,"\"");
 str = str.replace(/&lt;/g,"<");
 str = str.replace(/&gt;/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>
<table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" align="center" style="table-layout: fixed">

</table>
</div>
<div class="maintable">
<TABLE cellspacing="{INNERBORDERWIDTH}" cellpadding="{TABLESPACE}" width="{TABLEWIDTH}" align="center" class="tableborder">
        <TBODY>
  
        <TR background="#F5F9FD">
          <TD align="center">
            <TABLE class="newslink" style="background-color: #D1DCEB; border: 1px solid #072A66; width=100%" height=50 cellSpacing=5 cellPadding=0 border=0><tr><td>

            <DIV align="center">
              <textarea name="textarea" cols=100  class="textarea" id=text style="background: #FFF; border: 1px solid #4C77B6; color: #000; margin: 5px; padding: 2px; vertical-align: middle; WIDTH: 720px; HEIGHT: 300px"
onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}"></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>
</td></tr></TABLE>

<div>
<table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" height="5" align="center" class="outertxt">
<tr><td class="smalltxt"></td></tr></table>
</div>

            <TABLE style="background-color: #D1DCEB; border: 1px solid #072A66" width=100% cellSpacing=1 align="center" border="0"><tr><td>
            <TABLE width=720 cellSpacing=1 align="center" border="0">
              <!--DWLayoutTable-->
              <TBODY>
              <TR align=middle valign="middle">
                <TD width="15%" height="44">
                  <DIV align=left class="STYLE4"><INPUT style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 130px; HEIGHT: 40px" onClick="document.getElementById('text').value += trans();" type=button value=转换(追加) name=button>
                  </DIV></TD>
                <TD width="15%">
                  <P align=center class="STYLE4"><input name=button type=button style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 130px; HEIGHT: 40px" onClick="document.getElementById('text').value = trans()" value=转换(覆盖)>
                  </P></TD>
                <TD width="15%">
                  <P align=center class="STYLE4"><INPUT style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 130px; HEIGHT: 40px" onclick=copycode(window.text) type=button value=复制到剪贴板>
                  </P></TD>
                <TD width="35%">
     <table width="0" border="0" cellspacing="2" cellpadding="0">
  <tr>
    <td><INPUT onclick=preview() type=button value=" 预 览 帖 子 " style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 100px; HEIGHT: 20px" name=preview></td>
  </tr>
  <tr>
    <td><INPUT style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 100px; HEIGHT: 20px" onClick="document.getElementById('text').value=''" type=button value="清 空 内 容"> </td>
  </tr>
</table>
</TD>
                <TD width="25%">
                  <TABLE cellSpacing=2 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR align=middle>
                      <TD class="STYLE4">
                        <DIV align=center><INPUT title="自动分析所有超链接,并转换成超链接格式&#13;&#10;注意:超链接必须单独在一行中!" style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 80px" onclick=url() type=button value=分析超链接 name=Submit>
                        </DIV></TD>
                      <TD>
                        <DIV align=center><INPUT title=紧凑格式,删除所有空行 style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 80px" onclick=delnull() type=button value=清除空行 name=Submit>
                        </DIV></TD></TR>
                    <TR align=middle>
                      <TD>
                        <DIV align=center><INPUT title=清除多余的空行,保持最一个空行 style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 80px" onclick=refix() type=button value=清除多余 name=Submit>
                        </DIV></TD>
                      <TD>
                        <DIV align=center><INPUT title=为每一行(包括空行)增加一空行 style="background-color: #EBEBEB; border: 1px solid #4C77B6; WIDTH: 80px" onclick=addbr() type=button value=增加空行 name=Submit>
                        </DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY><tr><td></TABLE></TABLE>

<div>
<table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" height="5" align="center" class="outertxt">
<tr><td class="smalltxt"></td></tr></table>
</div>

            <FORM name=set>
            <TABLE style="background-color: #D1DCEB; border: 1px solid #072A66; width=100%" cellSpacing=1 align="center" border="0"><tr><td>
            <TABLE style="padding: 2px" height=50 cellSpacing=5 cellPadding=0 width=785 border=0 align="center">
              <TBODY>
              <TR>
                <TD title=转换的结果中将不含有图片信息 width="13%" height=20><span class="STYLE2">
                  <LABEL
                  for=img>
                  <INPUT style="background-color: #D1DCEB" id=img type=checkbox>
                  屏蔽图片</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有链接信息 width="14%"><span class="STYLE2">
                  <LABEL for=linka>
                  <INPUT  style="background-color: #D1DCEB"
                  id=linka type=checkbox>
                  屏蔽超链接</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含音频、视频、FLASH等信息 width="14%"><span class="STYLE2">
                  <LABEL
                  for=odj>
                  <INPUT style="background-color: #D1DCEB" id=odj type=checkbox>
                  屏蔽对象</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含文本信息,同时字体属性将被自动屏蔽 width="14%"><span class="STYLE2">
                  <LABEL
                  for=stext>
                  <INPUT style="background-color: #D1DCEB" id=stext type=checkbox>
                  屏蔽文字</LABEL>
                </span></TD>
                <TD title=为了方便帖子的阅读,强制把图片用空行隔开 width="14%"><span class="STYLE2">
                  <LABEL
                  for=filtrate>
                  <INPUT style="background-color: #D1DCEB" id=filtrate
                  onclick="if(this.checked)window.base_url.style.display='block';else window.base_url.style.display='none';"
                  type=checkbox>
                  启用图片过滤</LABEL>
                </span></TD>
                <TD title=屏蔽所有定字体相关的属性 width="14%"><span class="STYLE2">
                  <LABEL for=font>
                  <INPUT  style="background-color: #D1DCEB"
                  id=font
                  onclick=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>
                  屏蔽字体属性</LABEL>
                </span></TD>
                <TD title=屏蔽所有定字体相关的属性 width="14%"><span class="STYLE2">
                  <label>
                  <input style="background-color: #D1DCEB" type="checkbox" id="fontbash" value="checkbox" checked="checked" />
                  <span class="STYLE1">                屏蔽干扰码</span></label>
                </span></TD>
              </TR>
              <TR>
                <TD title=转换的结果中将不含有字体颜色信息><span class="STYLE2">
                  <LABEL for=font_color>
                  <INPUT  style="background-color: #D1DCEB"
                  id=font_color type=checkbox>
                  屏蔽字体颜色</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有字体尺寸信息><span class="STYLE2">
                  <LABEL for=font_size>
                  <INPUT style="background-color: #D1DCEB"
                  id=font_size type=checkbox>
                  屏蔽字体尺寸</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有字体类型信息><span class="STYLE2">
                  <LABEL for=font_face>
                  <INPUT style="background-color: #D1DCEB"
                  id=font_face type=checkbox>
                  屏蔽字体类型</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有粗体信息><span class="STYLE2">
                  <LABEL for=font_b>
                  <INPUT style="background-color: #D1DCEB" id=font_b
                  type=checkbox>
                  屏蔽粗体</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有斜体信息><span class="STYLE2">
                  <LABEL for=font_i>
                  <INPUT style="background-color: #D1DCEB" id=font_i
                  type=checkbox>
                  屏蔽斜体</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有下划线信息><span class="STYLE2">
                  <LABEL for=font_u>
                  <INPUT style="background-color: #D1DCEB" id=font_u
                  type=checkbox>
                  屏蔽下划线</LABEL>
                </span></TD>
                <TD title=转换的结果中将不含有下划线信息><span class="STYLE2"></span></TD>
              </TR></TBODY></TABLE><tr><td></TABLE>
            </FORM>

<div>
<table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" height="5" align="center" class="outertxt">
<tr><td class="smalltxt"></td></tr></table>
</div>
            <TABLE style="background-color: #D1DCEB; border: 1px solid #072A66" width=100% cellSpacing=1 align="center" border="0"><tr><td>

            <TABLE align="center" cellSpacing=8 cellPadding=0 width=720 border=0>
              <TBODY>
              <TR>
                <TD class=text11 align=middle width="82%"><SPAN
                  class="text9 style5">&nbsp;查找文字</SPAN> <INPUT style="background-color: #FFF; border: 1px solid #4C77B6; vertical-align: middle; HEIGHT: 25px" id=find_text size=50
                  name=find_text>
                <INPUT style="background-color: #EBEBEB; border: 1px solid #4C77B6; vertical-align: middle; HEIGHT: 25px" onClick="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 style="background-color: #FFF; border: 1px solid #4C77B6; vertical-align: middle; HEIGHT: 25px" id=replace_text
                  size=50 name=replace_text>
                <INPUT style="background-color: #EBEBEB; border: 1px solid #4C77B6; vertical-align: middle; HEIGHT: 25px" onclick=replace_star() type=button value=" 开始替换 " name=Submit></TD></TR></TBODY></TABLE><tr><td></TABLE>

<div>
<table cellspacing="0" cellpadding="0" border="0" width="{TABLEWIDTH}" height="5" align="center" class="outertxt">
<tr><td class="smalltxt"></td></tr></table>
</div>
            <TABLE style="background-color: #D1DCEB; border: 1px solid #072A66" width=100% cellSpacing=5 align="center" border="0"><tr><td>
      <table style="background-color: #F9F9F9; border: 1px solid #4C77B6" width="720" border="0" align="center" cellpadding="10" cellspacing="0">
                    <tr>
                      <td><p><b>使用说明:</b><br>
  &nbsp;1.在网页中拖动鼠标选中你想要的图片或文字,然后鼠标右键“复制(C)”或按Ctrl+C。<br>
  &nbsp;2.进入该页面,直接按下“追加转换剪贴板数据”。<br>
  &nbsp;3.复制文本筐中的数据,按下“将代码复制到剪贴板”。<br>
  &nbsp;4.进入论坛发贴页面,鼠标右键“粘贴(P)”或按Ctrl+V将帖子内容复制到帖子内容筐。<br>
  &nbsp;5.乱码过滤只在discuz4.1和phpwind4.32下测试过部分论坛,如不能正常使用请关掉乱码过滤。<br>
  &nbsp;<span class="STYLE1">6.对于没有开启干扰代码的论坛建议去掉屏蔽干扰码的复选框。</span>
                      </p>

</td></tr></table>
</TD></TR>

     </TBODY></TABLE>
<tr><td class="catend"></td></tr>
</tr></td></TABLE>
      <SCRIPT>
rtf.document.designMode="On";
</SCRIPT><br>
 

Powered by emlog 湘ICP备13007859号 空间由景安网络赞助