PHPBB3.X论坛 快速转贴按钮(可方便贴图)for prosilver风格
功能:在发帖时,快速贴图,只要复制完毕要转贴的内容(包括图片和超连接),直接点击“转换剪切板数据”即可完成贴图等功能。
无需点击插入图片按钮后再输入图片连接地址,同样支持超链接,方便转贴。
修改方法:
1,用记事本打开论坛目录\styles\prosilver\template\overall_header.html文件
2,搜索代码
[code]<div id="format-buttons">[/code]
3,在它的下面添加
[code]<script>
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,"");
str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"[url=$1]$2[/url]");
str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"[img]$1[/img]");
str = str.replace(/<([\/]?)b>/ig,"[$1b]");
str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
str = str.replace(/<([\/]?)u>/ig,"[$1u]");
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(/<[^>]*?>/g,"");
str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
str = str.replace(/\n+/g,"\n");
return str;
}
function trans(){
var str = "";
rtf.focus();
rtf.document.body.innerHTML = "";
rtf.document.execCommand("paste");
str = rtf.document.body.innerHTML;
if(str.length == 0) {
alert("No data");
return "";
}
return html_trans(str);
}
</script>
<iframe scrolling="no" id="rtf" src="about:blank" MARGINHEIGHT="0" MARGINWIDTH="0" style="width:0px; height:0px;"></iframe>
<LABEL for=x_paste></LABEL><br>
<input type='button' name='tietu' onclick="document.getElementById('message').value += trans()" value=Paste>
<SCRIPT>
rtf.document.designMode="On";
</SCRIPT>[/code]
保存,上传覆盖,登录后台,更新缓存后,刷新即可。