【实测】如何在dz论坛快速发帖及快速回帖内容中增加自动排版功能
一、帖子列表快速发帖自动排版
修改 /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>
复制代码 上方添加:- <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>
复制代码 二、内容页快速回帖增加自动排版
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、进入网站后台——更新缓存即可!
|