一、帖子列表快速发帖自动排版
1、修改 /template/default/forum/下的forumdisplay_fastpost.htm (注意备份)
查找:- <a href="forum.php?mod=post&action=newthread&fid=$_G[fid]" onclick="switchAdvanceMode(this.href);doane(event);">{lang post_advancemode}</a>
- </span>
复制代码 上面添加:- <a href="javascript:;" onclick="javascript:format()">自动排版</a>
- <SCRIPT language=JavaScript type=text/JavaScript>
- function format()
- {
- var body = "\n"+document.getElementById("fastpostmessage").value;
- body = body.replace(/ | /ig,"");
- body = body.replace(/\r\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n/ig,"\n\n ");
- body = body.replace("\n\n","");
- document.getElementById("fastpostmessage").value=body;
- }
- </script>
- <span class="pipe">|</span>
复制代码 2、更新缓存!
二、内容页快速回帖增加自动排版
1、修改 /template/default/forum/下的viewthread_fastpost.htm (注意备份)
查找:- <a href="forum.php?mod=post&action=reply&fid=$_G[fid]&tid=$_G[tid]{if $_GET[from]}&from=$_GET[from]{/if}" onclick="return switchAdvanceMode(this.href)">{lang post_advancemode}</a>
复制代码 上面添加:- <a href="javascript:;" onclick="javascript:format()">自动排版</a>
- <SCRIPT language=JavaScript type=text/JavaScript>
- function format()
- {
- var body = "\n"+document.getElementById("fastpostmessage").value;
- body = body.replace(/ | /ig,"");
- body = body.replace(/\r\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n\n/ig,"\n");
- body = body.replace(/\n/ig,"\n\n ");
- body = body.replace("\n\n","");
- document.getElementById("fastpostmessage").value=body;
- }
- </script>
- <span class="pipe">|</span>
复制代码 2、更新缓存即可!~
演示:http://www.ncxys.com |