[Phpfreechat-svn] SF.net SVN: phpfreechat: [1108] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-09 18:27:35
|
Revision: 1108 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1108&view=rev Author: gpinzone Date: 2007-08-09 11:27:36 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Disabled history feature for Konqueror. Moved history operations to separate functions. TODO: prevent up arrow default operation in Opera. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-09 11:04:30 UTC (rev 1107) +++ trunk/data/public/js/pfcclient.js 2007-08-09 18:27:36 UTC (rev 1108) @@ -613,6 +613,48 @@ }, /** + * Cycle to older entry in history + * TODO: Fix up arrow issue in Opera + */ + historyUp: function() + { + // write the previous command in the history + if (this.cmdhistory.length > 0) + { + var w = this.el_words; + if (this.cmdhistoryissearching == false && w.value != "") + this.cmdhistory.push(w.value); + this.cmdhistoryissearching = true; + this.cmdhistoryid = this.cmdhistoryid - 1; + if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry + w.value = this.cmdhistory[this.cmdhistoryid]; + } + }, + + /** + * Cycle to newer entry in history + */ + historyDown: function() + { + // write the next command in the history + if (this.cmdhistory.length > 0) + { + var w = this.el_words; + if (this.cmdhistoryissearching == false && w.value != "") + this.cmdhistory.push(w.value); + this.cmdhistoryissearching = true; + this.cmdhistoryid = this.cmdhistoryid + 1; + if (this.cmdhistoryid >= this.cmdhistory.length) + { + this.cmdhistoryid = this.cmdhistory.length; // stop at newest entry + 1 + w.value = ""; // blank input box + } + else + w.value = this.cmdhistory[this.cmdhistoryid]; + } + }, + + /** * Handle the pressed keys * see also callbackWords_OnKeydown */ @@ -634,35 +676,14 @@ else if (code == 63232 && is_webkit) // up arrow key { // write the previous command in the history - if (this.cmdhistory.length > 0) - { - var w = this.el_words; - if (this.cmdhistoryissearching == false && w.value != "") - this.cmdhistory.push(w.value); - this.cmdhistoryissearching = true; - this.cmdhistoryid = this.cmdhistoryid - 1; - if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry - w.value = this.cmdhistory[this.cmdhistoryid]; - } + this.historyUp(); + return false; // do not leave the tab key default behavior } else if (code == 63233 && is_webkit) // down arrow key { // write the next command in the history - if (this.cmdhistory.length > 0) - { - var w = this.el_words; - if (this.cmdhistoryissearching == false && w.value != "") - this.cmdhistory.push(w.value); - this.cmdhistoryissearching = true; - this.cmdhistoryid = this.cmdhistoryid + 1; - if (this.cmdhistoryid >= this.cmdhistory.length) - { - this.cmdhistoryid = this.cmdhistory.length; // stop at newest entry + 1 - w.value = ""; // blank input box - } - else - w.value = this.cmdhistory[this.cmdhistoryid]; - } + this.historyDown(); + return false; // do not leave the tab key default behavior } else { @@ -689,38 +710,17 @@ this.completeNick(); return false; /* do not leave the tab key default behavior */ } - else if (code == 38 && (is_gecko || is_ie || is_khtml || is_opera)) // up arrow key + else if (code == 38 && (is_gecko || is_ie || is_opera)) // up arrow key { // write the previous command in the history - if (this.cmdhistory.length > 0) - { - var w = this.el_words; - if (this.cmdhistoryissearching == false && w.value != "") - this.cmdhistory.push(w.value); - this.cmdhistoryissearching = true; - this.cmdhistoryid = this.cmdhistoryid - 1; - if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry - w.value = this.cmdhistory[this.cmdhistoryid]; - } + this.historyUp(); + return false; // do not leave the tab key default behavior } - else if (code == 40 && (is_gecko || is_ie || is_khtml || is_opera)) // down arrow key + else if (code == 40 && (is_gecko || is_ie || is_opera)) // down arrow key { // write the next command in the history - if (this.cmdhistory.length > 0) - { - var w = this.el_words; - if (this.cmdhistoryissearching == false && w.value != "") - this.cmdhistory.push(w.value); - this.cmdhistoryissearching = true; - this.cmdhistoryid = this.cmdhistoryid + 1; - if (this.cmdhistoryid >= this.cmdhistory.length) - { - this.cmdhistoryid = this.cmdhistory.length; // stop at newest entry + 1 - w.value = ""; // blank input box - } - else - w.value = this.cmdhistory[this.cmdhistoryid]; - } + this.historyDown(); + return false; // do not leave the tab key default behavior } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |