"超连接转换UBB"功能 FOR CMS1.2
作者:cmscn 日期:2008-08-20
"超连接转换UBB"功能介绍:
发贴速度加快.可以省下很多时间.
只需要复制一张图片或有颜色,字体的字后就会自动转换为:
[*img]XXX[/img]等!(为了显示.把img前面加了*号)
修改方法:(由于无法正常显示,请复制前先将红色的*号去掉!)
1.---------------------------------------
创建文件: ubb_zhq.js 并放在style/内
JS内容为:
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,"
$2
");
str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"
$2
");
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,"
");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(/\[url=([^\]]+)\]
(\[img\]\1\[\/img\])
\[\/url\]/g,"$2");
str = str.replace(/
+/g,"
");
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("剪切板不存在超文本数据!");
return "";
}
return html_trans(str);
}
2.---------------------------------------
修改forum_write.asp
1)查找<script language=javascript src="style/joekoe_functions.js"></script>
在下面添加<script language="javascript" src="style/ubb_zhq.js"></script>
2)查找onkeydown="javascript:frm_quicksubmit();"
空一格,在后面添加:
onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}"
3)然后在(红色部分的后面添加)
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>
<script>
rtf.document.designMode="On";
</script>
</td>
</tr>
<tr class=bg_td>
<td>UBB转换:</td>
<td> <input type=button onClick="document.getElementById('text').value += trans()" value="超连接转换UBB">
</tr>
评论: 0 | 引用: 0 | 查看次数: 576
发表评论