[Phpfreechat-svn] SF.net SVN: phpfreechat: [887] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-12-04 17:12:19
|
Revision: 887 http://svn.sourceforge.net/phpfreechat/?rev=887&view=rev Author: kerphi Date: 2006-12-04 09:12:10 -0800 (Mon, 04 Dec 2006) Log Message: ----------- [en] New parameter 'max_displayed_lines' (by default 150) used to free browser's memory when lot of lines are written in the chat. [1h20] [fr] Nouveau param?\195?\168tre 'max_displayed_lines' (par d?\195?\169faut 150) permettant de lib?\195?\169rer la m?\195?\169moire du navigateur lorsque bcp de messages sont affich?\195?\169s. [1h20] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/client/chat.js.tpl.php 2006-12-04 17:12:10 UTC (rev 887) @@ -19,6 +19,7 @@ var pfc_showwhosonline = <?php echo $json->encode($showwhosonline); ?>; var pfc_focus_on_connect = <?php echo $json->encode($focus_on_connect); ?>; var pfc_max_text_len = <?php echo $json->encode($max_text_len); ?>; +var pfc_max_displayed_lines = <?php echo $json->encode($max_displayed_lines); ?>; var pfc_quit_on_closedwindow = <?php echo $json->encode($quit_on_closedwindow); ?>; var pfc_debug = <?php echo $json->encode($debug); ?>; var pfc_btn_sh_smileys = <?php echo $json->encode($btn_sh_smileys); ?>; Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/client/pfcclient.js 2006-12-04 17:12:10 UTC (rev 887) @@ -776,6 +776,7 @@ handleComingRequest: function( cmds ) { var msg_html = $H(); + var max_msgid = 0; //alert(cmds.inspect()); @@ -804,20 +805,20 @@ line += '<span class="pfc_heure">'+ time +'</span> '; if (cmd == 'send') { - line += ' <span class="pfc_nick">'; - line += '‹'; - line += '<span '; + line += ' <span class="pfc_nick">'; + line += '‹'; + line += '<span '; line += 'onclick="pfc.insert_text(\'' + sender.replace("'", '\\\'') + ', \',\'\',false)" '; - line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; - line += sender; - line += '</span>'; - line += '›'; - line += '</span> '; + line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">'; + line += sender; + line += '</span>'; + line += '›'; + line += '</span> '; } if (cmd == 'notice' || cmd == 'me') - line += '<span class="pfc_words">* '+ this.parseMessage(param) +'</span> '; + line += '<span class="pfc_words">* '+ this.parseMessage(param) +'</span> '; else - line += '<span class="pfc_words">'+ this.parseMessage(param) +'</span> '; + line += '<span class="pfc_words">'+ this.parseMessage(param) +'</span> '; line += '</div>'; if (oldmsg == 0) @@ -828,7 +829,7 @@ var tabid = recipientid; if (this.gui.getTabId() != tabid) this.gui.notifyTab(tabid); - // notify the window (change the title) + // notify the window (change the title) if (!this.detectactivity.isActive() && pfc_notify_window) this.gui.notifyWindow(); } @@ -837,6 +838,9 @@ msg_html[recipientid] = line; else msg_html[recipientid] += line; + + // remember the max message id in order to clean old lines + if (max_msgid < id) max_msgid = id; } // loop on all recipients and post messages @@ -858,6 +862,21 @@ recipientdiv.appendChild(m); this.gui.scrollDown(tabid, m); } + + // delete the old messages from the client (save some memory) + var limit_msgid = max_msgid - pfc_max_displayed_lines; + var elt = $('pfc_msg'+limit_msgid); + while (elt) + { + // delete this element to save browser memory + if (is_ff) + elt.innerHTML = ''; + else + // this code don't work in FF, why ? don't know .. + elt.parentElement.removeChild(elt); + limit_msgid--; + elt = $('pfc_msg'+limit_msgid); + } }, /** Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-12-02 17:22:18 UTC (rev 886) +++ trunk/src/pfcglobalconfig.class.php 2006-12-04 17:12:10 UTC (rev 887) @@ -72,7 +72,8 @@ var $refresh_delay = 5000; // in mili-seconds (5 seconds) var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) var $timeout = 20000; // in mili-seconds (20 seconds) - var $max_msg = 20; + var $max_msg = 20; // number of messages keept in the history (this is what you see when you reload the chat) + var $max_displayed_lines = 150; // maximum number of displayed lines (old lines will be deleted to save browser's memory) var $quit_on_closedwindow = true; // could be annoying because the reload event is the same as a close event var $focus_on_connect = true; var $connect_at_startup = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |