<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,"\n[url=$1]$2[/url]\n"); if(!set.font_color.checked&&!set.stext.checked) str = str.replace(/<font([^>]+)color=([^ >]+)([^>]*)>(.*?)<\/font>/ig,"\n[color=$2]<font$1$3>$4</font>[/color]\n"); if(!set.font_size.checked&&!set.stext.checked) str = str.replace(/<font([^>]+)size=([^ >]+)([^>]*)>(.*?)<\/font>/ig,"\n[size=$2]<font$1$3>$4</font>[/size]\n"); if(!set.font_face.checked&&!set.stext.checked) str = str.replace(/<font[^>]+face=([^ >]+)[^>]*>(.*?)<\/font>/ig,"\n[font=$1]$2[/font]\n"); 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(/<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 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"> <style type="text/css"> <!-- body { color: #333333; font-family: "宋体", "Arial"; font-size: 9pt} td { color: #333333; font-family: "宋体", "Arial"; font-size: 9pt} --> </style> </head><base target=_blank><BODY BGCOLOR=#FFFFFF leftmargin="0" topmargin="0">
<tr> <td height="3"></td> </tr> </table> <table width="759" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-collapse: collapse"> <tr> <td width="100%" align="center"> <table width="99%" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center" bgcolor="#F8F8F8"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" class="fire"> <hr width="98%" size="1" color="#FFFFFF"></td> </tr> </table> <TEXTAREA cols="100" class=textarea id=text style="WIDTH: 98%; HEIGHT: 300px" onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}" style="border-style: groove; border-width: 1"></TEXTAREA> <IFRAME id=rtf style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME> <LABEL for=x_paste></LABEL> <table width="713" border="0" align="center"> <tr align="center"> <td width="25%"> <input name="button" type=button onClick="document.getElementById('text').value += trans();" value="追加转换剪切板数据" style="border:1px solid #808080; height:17;width:150"></td> <td width="25%"><p align="center"> <input type="button" value="将代码复制到剪切板" onclick="copycode(window.text)" style="border:1px solid #808080; height:17;width:150"> </p></td> <td width="25%"> <input type="button" value="清空所有内容" onClick="document.getElementById('text').value=''" style="border:1px solid #808080; height:17;width:150"></td> <td width="25%"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="center"> <td> <input type="button" name="Submit" value="分析超链接" onClick="url()" style="border:1px solid #808080; width:80; height:17" title="自动分析所有超链接,并转换成超链接格式 注意:超链接必须单独在一行中!"></td> <td> <input type="button" name="Submit" value="清除空行" onclick="delnull()" style="border:1px solid #808080; width:80; height:17" title="紧凑格式,删除所有空行"></td> </tr> <tr align="center"> <td> <input type="button" name="Submit" value="清除多余" onClick="refix()" style="border:1px solid #808080; width:80; height:17" title="清除多余的空行,保持最一个空行"></td> <td> <input type="button" name="Submit" value="增加空行" onClick="addbr()" style="border:1px solid #808080; width:80; height:17" title="为每一行(包括空行)增加一空行"></td> </tr> </table> </td> </tr> </table> <form name="set"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="13%" height="25" title="转换的结果中将不含有图片信息"><label for=img> <input type=checkbox id=img> 屏蔽图片</label></td> <td width="14%" title="转换的结果中将不含有链接信息"><label for=linka> <input type=checkbox id=linka> 屏蔽超链接</label></td> <td width="14%" title="转换的结果中将不含音频、视频、FLASH等信息"><label for=odj> <input type=checkbox id=odj> 屏蔽对象</label></td> <td width="14%" title="转换的结果中将不含文本信息,同时字体属性将被自动屏蔽"><label for=stext> <input type="checkbox" id="stext"> 屏蔽文字</label></td> <td width="14%" title="为了方便帖子的阅读,强制把图片用空行隔开"><label for=filtrate> <input type="checkbox" id="filtrate" onClick="if(this.checked)window.base_url.style.display='block';else window.base_url.style.display='none';"> 启用图片过滤</label></td> <td width="14%" title="屏蔽所有定字体相关的属性"><label for=font> <input type="checkbox" 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;"> 屏蔽字体属性</label></td> </tr> <tr> <td title="转换的结果中将不含有字体颜色信息"><label for=font_color> <input type=checkbox id=font_color> 屏蔽字体颜色</label></td> <td title="转换的结果中将不含有字体尺寸信息"><label for=font_size> <input type="checkbox" id="font_size"> 屏蔽字体尺寸</label></td> <td title="转换的结果中将不含有字体类型信息"><label for=font_face> <input type="checkbox" id="font_face"> 屏蔽字体类型</label></td> <td title="转换的结果中将不含有粗体信息"><label for=font_b> <input type="checkbox" id="font_b"> 屏蔽粗体</label></td> <td title="转换的结果中将不含有斜体信息"><label for=font_i> <input type="checkbox" id="font_i"> 屏蔽斜体</label></td> <td title="转换的结果中将不含有下划线信息"><label for=font_u> <input type="checkbox" id="font_u"> 屏蔽下划线</label></td> </tr> </table> </form> <table width="100%" border="0" cellspacing="0" cellpadding="2" id="base_url" style="display:none"> <tr> <td align="center"><b>输入图片的基本地址</b> <input name="textfield" type="text" size="70" style="background-color:#FFDFD0 "> <input type="button" name="Submit" value="清空" onClick="window.textfield.value=''" style="border: 1px solid #808080"></td> </tr> <tr> <td align="center"> <font color="#006600">如果未指基本地址,则将自动取第一张图片的位置做基本地址。 基本地址是指除文件名外的网络路径,如图片地址为:<font color="#0000FF">http://www.***.com/images/logo.jpg</font> ,则除去图片文件名 <font color="#0000FF">logo.jpg</font> 后基本地址为:<font color="#0000FF">http://www.***.com/images/</font></font> <hr width="100%" size="1" color="#000000"></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="91%" align="center" class="text11">查找文字 <input name="find_text" type="text" id="find_text" size="68" style="border-style: groove; border-width: 1"> <input type="button" name="Submit" value="全恢复默认" onclick="set.reset();find_text.value='';replace_text.value='';window.textfield.value='';" style="border: 1px solid #808080"> </td> <td width="9%" rowspan="2" align="center" class="text11"> <label for=reg><input type="checkbox" name="reg" id=reg value="1"> 使用<br> 正则语法</label> </td> </tr> <tr> <td align="center" class="text11">替换文字 <input name="replace_text" type="text" id="replace_text" size="68" style="border-style: groove; border-width: 1"> <input type="button" name="Submit" value=" 开始替换 " onclick="replace_star()" style="border: 1px solid #808080"></td> </tr> </table> <hr width="100%" size="1" color="#000000"></td> </tr> </table><SCRIPT> rtf.document.designMode="On"; </SCRIPT> <table width="99%" border="0" bgcolor="#9FB7D1"> <tr> <td><div align="center"> </div></td> <td><div align="center"> </div></td> </tr> </table> <table width="777" height="20" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF"> <tbody> <tr> <td align="center"> </td> </tr> </tbody> </table></td> </tr> </table> </body> </html>(出处:CodeFans.com转载) |