● 插件名称:贴内增加html2UBB功能
● 适用版本:Discuz! 4.0.0
● 相关修改:数据升级-无,模板修改-有
● 安装难度:易
● 插件作者:偶不是原作者,只是对此整理修改和详细说明
● 最后更新:2005-12-20
● 技术支持:http://bbs.jdwcn.com
● 程序说明:http://bbs.jdwcn.com/viewthread.php?tid=1840&extra=page%3D1
● 修改文件:
./include/common.js
./templates/default/viewthread.htm
./templates/default/forumdisplay.htm
./templates/default/post_bbinsert.htm
● 具体步骤:
修改common.js
查找
- if(!document.onmouseover) {
- document.onmouseover = function(e) {
- if (!e) showPopupText(window.event); else showPopupText(e);
- };
- }
复制代码
下面添加
- 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 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=([^\]]+)\](\[img\]\1\[\/img\])\[\/url\]/g,"$2");
-
- return str;
- }
- function trans(){
- var str = "";
- xydwcopy.focus();
- xydwcopy.document.body.innerHTML = "";
- xydwcopy.document.execCommand("paste");
- str = xydwcopy.document.body.innerHTML;
- if(str.length == 0) {
- alert("剪切版不存在超文本数据!");
- return "";
- }
- return html_trans(str);
- }
复制代码
修改forumdisplay.htm
查找
- {lang post_submit_hotkey}
复制代码
后面添加
-
- <IFRAME id=xydwcopy style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME>
- <span style=cursor:hand onclick="document.getElementById('message').value += trans()">[转换超文本数据]</span>
- <SCRIPT> xydwcopy.document.designMode="On"; </SCRIPT>
复制代码
修改post_bbinsert.htm
查找
- <a href="javascript:alipay()"><img src="{IMGDIR}/bb_alipay.gif" border="0" alt="{lang post_discuzcode_alipay}"></a>
复制代码
后面添加
- <br><IFRAME id=xydwcopy style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME>
- <span style=cursor:hand onclick="document.getElementById('message').value += trans()">[转换剪切板数据]</span>
- <SCRIPT>
- xydwcopy.document.designMode="On";
- </SCRIPT>
复制代码
修改viewthread.htm
查找
- {lang post_submit_hotkey}
复制代码
后面添加
-
- <IFRAME id=xydwcopy style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME>
- <span style=cursor:hand onclick="document.getElementById('message').value += trans()">[转换超文本数据]</span>
- <SCRIPT> xydwcopy.document.designMode="On"; </SCRIPT>
复制代码
以后大家转帖时请注意新出现的 [转换剪切板数据] 链接,该链接能简单的实现 html2UBB 的功能,从而给
你的转帖带来方便.
使用说明:
首先,在相应的网页按住鼠标左键拖选你要复制的图片和文字,请尽量不要选无关的内容
接下来,在选中的部分点击鼠标右键--复制,此时,你选中的部分被复制到了剪切板
最后,将光标定位于本页文本框,按下本页“转换剪切板数据”按钮,你选中的内容将被转换成ubb代码
完
=============================================
还有热心的sdywd修改过的风格
喜欢的请看27楼
[ 本帖最后由 clon911 于 2005-12-29 19:23 编辑 ] |