[转帖]超文本粘贴转换工具自动帖
超文本转换源代码:网络
修改:且听风吟论坛
提议:vaman[来自freediscuz]
功能说明:基于上一版[]修改,添加了点击按键自动帖内容到文本框.
修改难易:简单
修改文件:post_bbinsert.htm
转帖请注明出处
演示:www.cug.oor.cn ,注册 发新帖即可看到
很爽的一个东西啊~~~可能以前发过拉,但是我看收集帖里面没这个,随便有一个转换的但是只能转换图片,这个就可以一次都搞定 一个字 爽
1.打开post_bbinsert.htm模板,查找
在后面添加
- <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("剪切版不存在超文本数据!");
- return "";
- }
- return html_trans(str);
- }
- </script>
复制代码
2.查找
- <a href="javascript:list()"><img src="{IMGDIR}/bb_list.gif" border="0" alt="{lang post_discuzcode_list}"></a>
复制代码
如果之前修改过"[原创]发帖时多一个UBB按钮[超文本粘贴转换工具]",没有影响.
在此后面添加.
- <iframe scrolling="no" id="rtf" src="about:blank" MARGINHEIGHT="0" MARGINWIDTH="0" style="width:0px; height:0px;"></iframe>
- <span style=cursor:hand onclick="document.getElementById('message').value += trans()"><img src="{IMGDIR}/bb_ub2.gif" border="0" alt="自动帖超文本"></span>
- <SCRIPT>
- rtf.document.designMode="On";
- </SCRIPT>
复制代码
3.上传附件图片bb_ub2.gif到当前模板图片文件夹.默认是./images/defaule/
图片在本站可以直接右键另存为, 也可以自己美化一下啊,呵呵
[ Last edited by qilin520 on 2005-5-18 at 13:53 ] |