[Phpfreechat-svn] SF.net SVN: phpfreechat: [1102] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-08-08 22:01:20
|
Revision: 1102 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1102&view=rev Author: gpinzone Date: 2007-08-08 15:01:19 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Made more changes to handle Macintosh OS. Mac version of FF doesn't work well with "keydown" event. Safari returns unicode for arrow keys. Added Safari and Opera detection. History command will only work on recognized browsers. All changes regression tested on previously used browsers on Windows XP. Ref: http://unixpapa.com/js/key.html Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-08 20:32:35 UTC (rev 1101) +++ trunk/data/public/js/pfcclient.js 2007-08-08 22:01:19 UTC (rev 1102) @@ -2,6 +2,9 @@ var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML"); var is_ff = navigator.appName.match("Netscape"); var is_ie7 = navigator.userAgent.indexOf('MSIE 7') > 0; +var is_opera = window.opera; +var is_safari = document.childNodes && !document.all && !navigator.taintEnabled && !accentColorName; + /** * This class is the client part of phpFreeChat * (depends on prototype library) @@ -627,6 +630,34 @@ { return this.doSendMessage(); } + else if (code == 38 && is_ff || code == 63232 && is_safari) // up arrow key + { + // write the last 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 = this.cmdhistory.length-1; + w.value = this.cmdhistory[this.cmdhistoryid]; + } + } + else if (code == 40 && is_ff || code == 63233 && is_safari) // 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 = 0; + w.value = this.cmdhistory[this.cmdhistoryid]; + } + } else { /* allow other keys */ @@ -649,7 +680,7 @@ this.completeNick(); return false; /* do not leave the tab key default behavior */ } - else if (code == 38) // up arrow key + else if (code == 38 && (is_ie || is_khtml || is_opera)) // up arrow key { // write the last command in the history if (this.cmdhistory.length>0) @@ -663,7 +694,7 @@ w.value = this.cmdhistory[this.cmdhistoryid]; } } - else if (code == 40) // down arrow key + else if (code == 40 && (is_ie || is_khtml || is_opera)) // down arrow key { // write the next command in the history if (this.cmdhistory.length>0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |