Thread: [Phpfreechat-svn] SF.net SVN: phpfreechat: [914] trunk/data/public/js/pfcclient.js
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-01-04 17:58:04
|
Revision: 914 http://svn.sourceforge.net/phpfreechat/?rev=914&view=rev Author: kerphi Date: 2007-01-04 09:58:02 -0800 (Thu, 04 Jan 2007) Log Message: ----------- fix a margin problem Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-01-04 17:30:14 UTC (rev 913) +++ trunk/data/public/js/pfcclient.js 2007-01-04 17:58:02 UTC (rev 914) @@ -858,7 +858,7 @@ var recipientdiv = this.gui.getChatContentFromTabId(tabid); // create a dummy div to avoid konqueror bug when setting nickmarkers - var m = document.createElement('div'); + var m = document.createElement('span'); m.innerHTML = msg_html[recipientid]; this.colorizeNicks(m); this.refresh_clock(m); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-02-15 08:40:38
|
Revision: 952 http://svn.sourceforge.net/phpfreechat/?rev=952&view=rev Author: kerphi Date: 2007-02-15 00:40:35 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Optimization : http://www.phpfreechat.net/forum/viewtopic.php?id=1187 Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-02-14 16:55:52 UTC (rev 951) +++ trunk/data/public/js/pfcclient.js 2007-02-15 08:40:35 UTC (rev 952) @@ -1282,12 +1282,12 @@ /* check the nickname is colorized or not */ var allready_colorized = false; var nc = ''; - for(var j = 0; j < this.nickcolor.length; j++) + for(var j = 0; j < this.nickcolor.length && !allready_colorized; j++) { if (this.nickcolor[j][0] == nick) { - allready_colorized = true; - nc = this.nickcolor[j][1]; + allready_colorized = true; + nc = this.nickcolor[j][1]; } } if (!allready_colorized) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-02-15 17:26:43
|
Revision: 957 http://svn.sourceforge.net/phpfreechat/?rev=957&view=rev Author: kerphi Date: 2007-02-15 09:26:38 -0800 (Thu, 15 Feb 2007) Log Message: ----------- fix the ping calculation Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-02-15 16:13:34 UTC (rev 956) +++ trunk/data/public/js/pfcclient.js 2007-02-15 17:26:38 UTC (rev 957) @@ -42,7 +42,9 @@ this.timeout = null; this.refresh_delay = pfc_refresh_delay; this.max_refresh_delay = pfc_max_refresh_delay; - this.last_refresh_time = new Date().getTime(); + this.last_response_time = new Date().getTime(); + this.last_request_time = new Date().getTime(); + /* unique client id for each windows used to identify a open window * this id is passed every time the JS communicate with server * (2 clients can use the same session: then only the nickname is shared) */ @@ -148,6 +150,14 @@ { if (pfc_debug) if (cmd != "update") trace('handleResponse: '+cmd + "-"+resp+"-"+param); + + // store the new refresh time + this.last_response_time = new Date().getTime(); + + // calculate the ping and display it + this.ping = this.last_response_time - this.last_request_time; + $('pfc_ping').innerHTML = this.ping+'ms'; + if (cmd == "connect") { //alert(cmd + "-"+resp+"-"+param); @@ -333,12 +343,11 @@ } else if (cmd == "update") { - this.canupdatenexttime = true; // if the first ever refresh request never makes it back then the chat will keep // trying to refresh as usual // this only helps if we temporarily lose connection in the middle of an established // chat session - this.last_refresh_time = new Date().getTime(); + this.canupdatenexttime = true; } else if (cmd == "version") { @@ -890,8 +899,17 @@ */ sendRequest: function(cmd, recipientid) { - if (pfc_debug) - if (cmd != "/update") trace('sendRequest: '+cmd); + if (cmd != "/update") + { + // setup a new timeout to update the chat in 5 seconds (in refresh_delay more exactly) + clearTimeout(this.timeout); + this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); + + if (pfc_debug) + trace('sendRequest: '+cmd); + } + + this.last_request_time = new Date().getTime(); var rx = new RegExp('(^\/[^ ]+) *(.*)','ig'); if (!recipientid) recipientid = this.gui.getTabId(); cmd = cmd.replace(rx, '$1 '+this.clientid+' '+(recipientid==''?'0':recipientid)+' $2'); @@ -906,10 +924,6 @@ clearTimeout(this.timeout); if (start) { - // calculate the ping and display it - this.ping = Math.abs(this.refresh_delay-(new Date().getTime() - this.last_refresh_time)); - $('pfc_ping').innerHTML = this.ping+'ms'; - var res = true; if (this.canupdatenexttime) { @@ -917,12 +931,12 @@ res = this.sendRequest('/update'); this.canupdatenexttime = false; // don't update if the last 'ok' response is not yet received } - else if ((new Date().getTime() - this.last_refresh_time) > this.max_refresh_delay) + else if ((new Date().getTime() - this.last_response_time) > this.max_refresh_delay) { // the connection is probably closed or very slow res = this.sendRequest('/update'); this.canupdatenexttime = false; // don't update if the last 'ok' response is not yet received - this.last_refresh_time = new Date().getTime(); + this.last_response_time = new Date().getTime(); } // setup the next update this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-02-28 17:21:51
|
Revision: 981 http://svn.sourceforge.net/phpfreechat/?rev=981&view=rev Author: kerphi Date: 2007-02-28 09:21:49 -0800 (Wed, 28 Feb 2007) Log Message: ----------- [en] Bug fix: URL's with a comma does not get recognized as a link (sf bug 1649431) [fr] Bug fix : les urls avec une virgule n'?\195?\169taient pas reconnues (sf bug 1649431) Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-02-27 14:23:54 UTC (rev 980) +++ trunk/data/public/js/pfcclient.js 2007-02-28 17:21:49 UTC (rev 981) @@ -1154,7 +1154,7 @@ var rx = null; // parse urls - var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\~\\/\\?\\=\\&\\-\\_\\#:;%]*)([^\\"]|$)','ig'); + var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\~\\/\\?\\=\\&\\-\\_\\#:;%,]*[a-z0-9\\/\\?\\=\\&\\-\\_\\#])([^\\"]|$)','ig'); var ttt = msg.split(rx_url); if (ttt.length > 1 && !navigator.appName.match("Explorer|Konqueror") && This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-04-16 17:00:18
|
Revision: 1016 http://svn.sourceforge.net/phpfreechat/?rev=1016&view=rev Author: kerphi Date: 2007-04-16 10:00:15 -0700 (Mon, 16 Apr 2007) Log Message: ----------- [en] Bug fix: nicknames with spaces at first connection were broken [fr] Bug fix : les pseudonymes avec des espaces entr?\195?\169s lors de la premi?\195?\168re connexion ne fonctionnaient pas Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-04-13 11:42:00 UTC (rev 1015) +++ trunk/data/public/js/pfcclient.js 2007-04-16 17:00:15 UTC (rev 1016) @@ -150,7 +150,7 @@ if (this.isconnected) this.sendRequest('/nick "'+newnick+'"'); else - this.sendRequest('/connect '+newnick); + this.sendRequest('/connect "'+newnick+'"'); } }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-05-04 15:31:42
|
Revision: 1023 http://svn.sourceforge.net/phpfreechat/?rev=1023&view=rev Author: kerphi Date: 2007-05-04 08:31:35 -0700 (Fri, 04 May 2007) Log Message: ----------- Bug fix : make possible to have '@' characteres in urls Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-04-25 07:42:44 UTC (rev 1022) +++ trunk/data/public/js/pfcclient.js 2007-05-04 15:31:35 UTC (rev 1023) @@ -1114,9 +1114,9 @@ parseMessage: function(msg) { var rx = null; - + // parse urls - var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\~\\/\\?\\=\\&\\-\\_\\#:;%,]*[a-z0-9\\/\\?\\=\\&\\-\\_\\#])([^\\"]|$)','ig'); + var rx_url = new RegExp('(^|[^\\"])([a-z]+\:\/\/[a-z0-9.\\~\\/\\?\\=\\&\\-\\_\\#:;%,@]*[a-z0-9\\/\\?\\=\\&\\-\\_\\#])([^\\"]|$)','ig'); var ttt = msg.split(rx_url); if (ttt.length > 1 && !navigator.appName.match("Explorer|Konqueror") && This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-06-30 17:34:40
|
Revision: 1040 http://svn.sourceforge.net/phpfreechat/?rev=1040&view=rev Author: kerphi Date: 2007-06-30 10:34:36 -0700 (Sat, 30 Jun 2007) Log Message: ----------- Bug fix: nicknames with spaces were broken when using the 'nick' parameter Bug fix : les pseudonymes avec des espaces ne fonctionnaient pas lorsque l'on utilisait le param?\195?\168tre 'nick' Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-06-26 10:02:44 UTC (rev 1039) +++ trunk/data/public/js/pfcclient.js 2007-06-30 17:34:36 UTC (rev 1040) @@ -1475,7 +1475,7 @@ if (this.nickname == '') this.askNick(); else - this.sendRequest('/connect '+this.nickname); + this.sendRequest('/connect "'+this.nickname+'"'); } }, refresh_loginlogout: function() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-06-30 21:07:28
|
Revision: 1045 http://svn.sourceforge.net/phpfreechat/?rev=1045&view=rev Author: kerphi Date: 2007-06-30 14:07:30 -0700 (Sat, 30 Jun 2007) Log Message: ----------- Bug fix: clicking on the nick in the chat area was broken in IE6 (thanks to onslo) Bug fix : cliquer sur les pseudonymes dans la zone du chat provoquait une erreur dans IE6 (merci ?\195?\160 onslo) Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-06-30 20:43:19 UTC (rev 1044) +++ trunk/data/public/js/pfcclient.js 2007-06-30 21:07:30 UTC (rev 1045) @@ -1550,11 +1550,10 @@ if (document.selection && document.selection.createRange) { msgfield.focus(); - sel = document.selection.createRange(); - var text = sel.text; + pfcp.sel = document.selection.createRange(); + var text = pfcp.sel.text; if (text == "" && promptifselempty) { - pfcp.sel = document.selection.createRange(); pfcp.prompt(this.res.getLabel('Enter the text to format'), ''); pfcp.focus(); } @@ -1594,7 +1593,6 @@ var promptifselempty = pfcp.promptifselempty; var msgfield = pfcp.msgfield; var sel = pfcp.sel; - // IE support if (document.selection && document.selection.createRange) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ke...@us...> - 2007-07-20 13:46:56
|
Revision: 1054 http://svn.sourceforge.net/phpfreechat/?rev=1054&view=rev Author: kerphi Date: 2007-07-20 06:46:58 -0700 (Fri, 20 Jul 2007) Log Message: ----------- Bug fix: when all the tabs are closed, the first tab should be open on the front Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-07-19 14:13:08 UTC (rev 1053) +++ trunk/data/public/js/pfcclient.js 2007-07-20 13:46:58 UTC (rev 1054) @@ -226,7 +226,7 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "ch"); - if (cmd != "join2") this.gui.setTabById(tabid); + if (cmd != "join2" || this.gui.tabs.length == 1) this.gui.setTabById(tabid); this.refresh_Smileys(); this.refresh_WhosOnline(); } @@ -269,7 +269,7 @@ var tabid = param[0]; var name = param[1]; this.gui.createTab(name, tabid, "pv"); - if (cmd != "privmsg2") this.gui.setTabById(tabid); + if (cmd != "privmsg2" || this.gui.tabs.length == 1) this.gui.setTabById(tabid); this.privmsgs.push(name); this.privmsgids.push(tabid); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <gpi...@us...> - 2007-08-08 22:15:04
|
Revision: 1103 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1103&view=rev Author: gpinzone Date: 2007-08-08 15:15:04 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Fixed Firefox bug introduced in last commit. Should not cause issues on Mac Firefox since "evt.which" takes precedence. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-08 22:01:19 UTC (rev 1102) +++ trunk/data/public/js/pfcclient.js 2007-08-08 22:15:04 UTC (rev 1103) @@ -630,7 +630,7 @@ { return this.doSendMessage(); } - else if (code == 38 && is_ff || code == 63232 && is_safari) // up arrow key + else if (code == 63232 && is_safari) // up arrow key { // write the last command in the history if (this.cmdhistory.length>0) @@ -644,7 +644,7 @@ w.value = this.cmdhistory[this.cmdhistoryid]; } } - else if (code == 40 && is_ff || code == 63233 && is_safari) // down arrow key + else if (code == 63233 && is_safari) // down arrow key { // write the next command in the history if (this.cmdhistory.length>0) @@ -680,7 +680,7 @@ this.completeNick(); return false; /* do not leave the tab key default behavior */ } - else if (code == 38 && (is_ie || is_khtml || is_opera)) // up arrow key + else if (code == 38 && (is_ff || is_ie || is_khtml || is_opera)) // up arrow key { // write the last command in the history if (this.cmdhistory.length>0) @@ -694,7 +694,7 @@ w.value = this.cmdhistory[this.cmdhistoryid]; } } - else if (code == 40 && (is_ie || is_khtml || is_opera)) // down arrow key + else if (code == 40 && (is_ff || 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. |
From: <gpi...@us...> - 2007-08-09 01:07:13
|
Revision: 1104 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1104&view=rev Author: gpinzone Date: 2007-08-08 18:07:15 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Got rid of buggy Safari detection method. Replaced other detection methods and variable names with the ones in prototype.js. Tested history function on Safari for Windows. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-08 22:15:04 UTC (rev 1103) +++ trunk/data/public/js/pfcclient.js 2007-08-09 01:07:15 UTC (rev 1104) @@ -1,9 +1,9 @@ -var is_ie = navigator.appName.match("Explorer"); -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; +var is_ie = window.attachEvent && !window.opera; +var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML"); +var is_gecko = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1; +var is_ie7 = navigator.userAgent.indexOf('MSIE 7') > 0; +var is_opera = window.opera; +var is_webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1; /** * This class is the client part of phpFreeChat @@ -630,7 +630,7 @@ { return this.doSendMessage(); } - else if (code == 63232 && is_safari) // up arrow key + else if (code == 63232 && is_webkit) // up arrow key { // write the last command in the history if (this.cmdhistory.length>0) @@ -644,7 +644,7 @@ w.value = this.cmdhistory[this.cmdhistoryid]; } } - else if (code == 63233 && is_safari) // down arrow key + else if (code == 63233 && is_webkit) // down arrow key { // write the next command in the history if (this.cmdhistory.length>0) @@ -680,7 +680,7 @@ this.completeNick(); return false; /* do not leave the tab key default behavior */ } - else if (code == 38 && (is_ff || is_ie || is_khtml || is_opera)) // up arrow key + else if (code == 38 && (is_gecko || is_ie || is_khtml || is_opera)) // up arrow key { // write the last command in the history if (this.cmdhistory.length>0) @@ -694,7 +694,7 @@ w.value = this.cmdhistory[this.cmdhistoryid]; } } - else if (code == 40 && (is_ff || is_ie || is_khtml || is_opera)) // down arrow key + else if (code == 40 && (is_gecko || is_ie || is_khtml || is_opera)) // down arrow key { // write the next command in the history if (this.cmdhistory.length>0) @@ -908,7 +908,7 @@ while (elt) { // delete this element to save browser memory - if (is_ff) + if (is_gecko) elt.innerHTML = ''; else // this code don't work in FF, why ? don't know .. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-09 01:57:43
|
Revision: 1105 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1105&view=rev Author: gpinzone Date: 2007-08-08 18:57:45 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Command history stops at oldest entry and provides blank textbox after newest. This emulates most IRC clients. Cleaned up comments and removed all tabs. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-09 01:07:15 UTC (rev 1104) +++ trunk/data/public/js/pfcclient.js 2007-08-09 01:57:45 UTC (rev 1105) @@ -605,9 +605,9 @@ var n_list = this.getChanMeta(tabid,'users')['nick']; for (var i=0; i<n_list.length; i++) { - var nick = n_list[i]; - if (nick.indexOf(nick_src) == 0) - w.value = w.value.replace(nick_src, nick); + var nick = n_list[i]; + if (nick.indexOf(nick_src) == 0) + w.value = w.value.replace(nick_src, nick); } } }, @@ -618,6 +618,7 @@ */ callbackWords_OnKeypress: function(evt) { + // All browsers except for IE should use evt.which var code = (evt.which) ? evt.which : evt.keyCode; if (code == Event.KEY_TAB) /* tab key */ { @@ -632,30 +633,35 @@ } else if (code == 63232 && is_webkit) // up arrow key { - // write the last command in the history - if (this.cmdhistory.length>0) + // 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 = this.cmdhistory.length-1; + this.cmdhistoryid = this.cmdhistoryid - 1; + if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry w.value = this.cmdhistory[this.cmdhistoryid]; } } else if (code == 63233 && is_webkit) // down arrow key { // write the next command in the history - if (this.cmdhistory.length>0) + 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]; + 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]; } } else @@ -667,6 +673,9 @@ /** * Handle the pressed keys * see also callbackWords_OnKeypress + * WARNING: Suppressing defaults on the keydown event + * may prevent keypress and/or keyup events + * from firing. */ callbackWords_OnKeydown: function(evt) { @@ -682,30 +691,35 @@ } else if (code == 38 && (is_gecko || is_ie || is_khtml || is_opera)) // up arrow key { - // write the last command in the history - if (this.cmdhistory.length>0) + // 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 = this.cmdhistory.length-1; + this.cmdhistoryid = this.cmdhistoryid - 1; + if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry w.value = this.cmdhistory[this.cmdhistoryid]; } } else if (code == 40 && (is_gecko || is_ie || is_khtml || is_opera)) // down arrow key { // write the next command in the history - if (this.cmdhistory.length>0) + 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]; + 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]; } } else @@ -778,13 +792,13 @@ { if (this.blinkloop[id] == 1) { - $(id).style.backgroundColor = '#FFDFC0'; - this.blinkloop[id] = 2; + $(id).style.backgroundColor = '#FFDFC0'; + this.blinkloop[id] = 2; } else { - $(id).style.backgroundColor = '#FFFFFF'; - this.blinkloop[id] = 1; + $(id).style.backgroundColor = '#FFFFFF'; + this.blinkloop[id] = 1; } this.blinktimeout[id] = setTimeout('pfc.blink(\'' + id + '\',\'loop\')', 500); } @@ -844,15 +858,15 @@ 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> '; @@ -1353,8 +1367,9 @@ var rx2 = new RegExp('.*'+clsIgnore+'.*'); for(i=0; i<els.length; i++) { if(els.item(i).className.match(rx1) && - (clsIgnore == '' || !els.item(i).className.match(rx2)) ) { - matches.push(els.item(i)); + (clsIgnore == '' || !els.item(i).className.match(rx2)) ) + { + matches.push(els.item(i)); } } return matches; @@ -1403,8 +1418,8 @@ var elts = this.getElementsByClassName(root, 'pfc_nickmarker', ''); for(var i = 0; elts.length > i; i++) { - // this is not supported in konqueror =>>> elts[i].removeAttribute('style'); - elts[i].style.color = ''; + // this is not supported in konqueror =>>> elts[i].removeAttribute('style'); + Elts[i].style.color = ''; } } }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-09 02:02:06
|
Revision: 1106 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1106&view=rev Author: gpinzone Date: 2007-08-08 19:02:05 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Oops! modified line 1422 by accident. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-09 01:57:45 UTC (rev 1105) +++ trunk/data/public/js/pfcclient.js 2007-08-09 02:02:05 UTC (rev 1106) @@ -1419,7 +1419,7 @@ for(var i = 0; elts.length > i; i++) { // this is not supported in konqueror =>>> elts[i].removeAttribute('style'); - Elts[i].style.color = ''; + elts[i].style.color = ''; } } }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <gpi...@us...> - 2007-08-09 22:30:43
|
Revision: 1109 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1109&view=rev Author: gpinzone Date: 2007-08-09 15:30:42 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Moved Safari function out of keypress. Misc cleanup. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-09 18:27:36 UTC (rev 1108) +++ trunk/data/public/js/pfcclient.js 2007-08-09 22:30:42 UTC (rev 1109) @@ -1,8 +1,8 @@ -var is_ie = window.attachEvent && !window.opera; +var is_ie = !!(window.attachEvent && !window.opera); var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML"); var is_gecko = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1; var is_ie7 = navigator.userAgent.indexOf('MSIE 7') > 0; -var is_opera = window.opera; +var is_opera = !!window.opera; var is_webkit = navigator.userAgent.indexOf('AppleWebKit/') > -1; /** @@ -614,11 +614,10 @@ /** * Cycle to older entry in history - * TODO: Fix up arrow issue in Opera */ historyUp: function() { - // write the previous command in the history + // write the previous command in the history if (this.cmdhistory.length > 0) { var w = this.el_words; @@ -626,7 +625,8 @@ this.cmdhistory.push(w.value); this.cmdhistoryissearching = true; this.cmdhistoryid = this.cmdhistoryid - 1; - if (this.cmdhistoryid < 0) this.cmdhistoryid = 0; // stop at oldest entry + if (this.cmdhistoryid < 0) + this.cmdhistoryid = 0; // stop at oldest entry w.value = this.cmdhistory[this.cmdhistoryid]; } }, @@ -673,18 +673,6 @@ { return this.doSendMessage(); } - else if (code == 63232 && is_webkit) // up arrow key - { - // write the previous command in the history - 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 - this.historyDown(); - return false; // do not leave the tab key default behavior - } else { /* allow other keys */ @@ -710,20 +698,24 @@ this.completeNick(); return false; /* do not leave the tab key default behavior */ } - else if (code == 38 && (is_gecko || is_ie || is_opera)) // up arrow key + else if (code == 38 && (is_gecko || is_ie || is_opera || is_webkit)) // up arrow key { + /* TODO: Fix up arrow issue in Opera */ + // Konqueror does not work due to keycode conflicts // write the previous command in the history this.historyUp(); return false; // do not leave the tab key default behavior } - else if (code == 40 && (is_gecko || is_ie || is_opera)) // down arrow key + else if (code == 40 && (is_gecko || is_ie || is_opera || is_webkit)) // down arrow key { + // Konqueror does not work due to keycode conflicts // write the next command in the history this.historyDown(); return false; // do not leave the tab key default behavior } else { + /* allow other keys */ return true; } }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-10 14:54:26
|
Revision: 1110 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1110&view=rev Author: gpinzone Date: 2007-08-10 07:54:27 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Fixed "Nickname Completion" bug 1595638. Rewrote algorithm to do intelligent completion like on a Linux command line. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-09 22:30:42 UTC (rev 1109) +++ trunk/data/public/js/pfcclient.js 2007-08-10 14:54:27 UTC (rev 1110) @@ -1,5 +1,5 @@ var is_ie = !!(window.attachEvent && !window.opera); -var is_khtml = navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML"); +var is_khtml = !!(navigator.appName.match("Konqueror") || navigator.appVersion.match("KHTML")); var is_gecko = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1; var is_ie7 = navigator.userAgent.indexOf('MSIE 7') > 0; var is_opera = !!window.opera; @@ -593,31 +593,52 @@ /** * Try to complete a nickname like on IRC when pressing the TAB key - * @todo: improve the algorithme, it should take into account the cursor position */ completeNick: function() { var w = this.el_words; - var nick_src = w.value.substring(w.value.lastIndexOf(' ')+1,w.value.length); + var nick_src = w.value; if (nick_src != '') { var tabid = this.gui.getTabId(); var n_list = this.getChanMeta(tabid,'users')['nick']; - for (var i=0; i<n_list.length; i++) + var nick_match = false; + for (var i = 0; i < n_list.length; i++) { - var nick = n_list[i]; - if (nick.indexOf(nick_src) == 0) - w.value = w.value.replace(nick_src, nick); + var nick_tmp = n_list[i]; + if (nick_tmp.indexOf(nick_src) == 0) + { + if (! nick_match) + { + nick_match = true; + nick_replace = nick_tmp; + } + else + { + // more than one possibility for completion + // return common characters only + var nick_len = Math.min(nick_tmp.length, nick_replace.length); + for (var j = 0; j < nick_len; j++) + { + if (nick_tmp.charAt(j) != nick_replace.charAt(j)) + { + nick_replace = nick_replace.substr(0,j); + break; + } + } + } + } } + if (nick_match == true) + w.value = w.value.replace(nick_src, nick_replace); } }, - /** * Cycle to older entry in history */ historyUp: function() { - // write the previous command in the history + // write the previous command in the history if (this.cmdhistory.length > 0) { var w = this.el_words; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-10 15:06:08
|
Revision: 1111 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1111&view=rev Author: gpinzone Date: 2007-08-10 08:06:09 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-10 14:54:27 UTC (rev 1110) +++ trunk/data/public/js/pfcclient.js 2007-08-10 15:06:09 UTC (rev 1111) @@ -625,7 +625,8 @@ nick_replace = nick_replace.substr(0,j); break; } - } + } + nick_replace = nick_replace.substr(0,nick_len); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-10 18:17:20
|
Revision: 1112 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1112&view=rev Author: gpinzone Date: 2007-08-10 11:17:23 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Patch 1771266: Updated code to use W3C standard DOM parentNode with fallback on IE parentElement. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-10 15:06:09 UTC (rev 1111) +++ trunk/data/public/js/pfcclient.js 2007-08-10 18:17:23 UTC (rev 1112) @@ -936,11 +936,12 @@ while (elt) { // delete this element to save browser memory - if (is_gecko) + if(elt.parentNode) + elt.parentNode.removeChild(elt); + else if(elt.parentElement) // older IE browsers (<6.0) may not support parentNode + elt.parentElement.removeChild(elt); + else // if all else fails elt.innerHTML = ''; - else - // this code don't work in FF, why ? don't know .. - elt.parentElement.removeChild(elt); limit_msgid--; elt = $('pfc_msg_'+recipientid+'_'+limit_msgid); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-10 20:24:27
|
Revision: 1113 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1113&view=rev Author: gpinzone Date: 2007-08-10 13:24:20 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Simplification to Nickname Completion script. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-10 18:17:23 UTC (rev 1112) +++ trunk/data/public/js/pfcclient.js 2007-08-10 20:24:20 UTC (rev 1113) @@ -601,7 +601,7 @@ if (nick_src != '') { var tabid = this.gui.getTabId(); - var n_list = this.getChanMeta(tabid,'users')['nick']; + var n_list = this.getChanMeta(tabid, 'users')['nick']; var nick_match = false; for (var i = 0; i < n_list.length; i++) { @@ -616,21 +616,18 @@ else { // more than one possibility for completion - // return common characters only var nick_len = Math.min(nick_tmp.length, nick_replace.length); - for (var j = 0; j < nick_len; j++) - { + // only keep characters that are common to all matches + var j = 0; + for (j = 0; j < nick_len; j++) if (nick_tmp.charAt(j) != nick_replace.charAt(j)) - { - nick_replace = nick_replace.substr(0,j); break; - } - } - nick_replace = nick_replace.substr(0,nick_len); + + nick_replace = nick_replace.substr(0, j); } } } - if (nick_match == true) + if (nick_match) w.value = w.value.replace(nick_src, nick_replace); } }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-11 00:22:37
|
Revision: 1114 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1114&view=rev Author: gpinzone Date: 2007-08-10 17:22:37 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Nickname completion now works based on last space in string instead of only at the beginning of line. This more closely emulates IRC. However, nicknames with spaces may not work well. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-10 20:24:20 UTC (rev 1113) +++ trunk/data/public/js/pfcclient.js 2007-08-11 00:22:37 UTC (rev 1114) @@ -591,13 +591,28 @@ return false; }, + reverse: function(inp) + { + var outp = ''; + + for (var i = 0; i < inp.length; i++) + outp = inp.charAt(i) + outp; + + return outp; + }, + /** * Try to complete a nickname like on IRC when pressing the TAB key + * Nicks with spaces may not work under certain circumstances + * Note: IRC does not allow nicks with spaces */ completeNick: function() { var w = this.el_words; - var nick_src = w.value; + var last_space = w.value.lastIndexOf(' '); + var nick_src = w.value.substring(last_space+1, w.value.length); + var non_nick_src = w.value.substring(0,last_space+1); + if (nick_src != '') { var tabid = this.gui.getTabId(); @@ -628,7 +643,7 @@ } } if (nick_match) - w.value = w.value.replace(nick_src, nick_replace); + w.value = non_nick_src + nick_src.replace(nick_src, nick_replace); } }, /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-11 06:41:58
|
Revision: 1115 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1115&view=rev Author: gpinzone Date: 2007-08-10 23:41:57 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Replace spaces in nick text with to help with completion of nicknames that contain spaces. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-11 00:22:37 UTC (rev 1114) +++ trunk/data/public/js/pfcclient.js 2007-08-11 06:41:57 UTC (rev 1115) @@ -591,19 +591,12 @@ return false; }, - reverse: function(inp) - { - var outp = ''; - - for (var i = 0; i < inp.length; i++) - outp = inp.charAt(i) + outp; - - return outp; - }, - /** * Try to complete a nickname like on IRC when pressing the TAB key * Nicks with spaces may not work under certain circumstances + * Replacing standards spaces with alternate spaces (e.g., ) helps + * Gecko browsers convert the to regular spaces + * TODO: Move cursor to end of line after nick completion in Konqueror and Webkit browsers * Note: IRC does not allow nicks with spaces */ completeNick: function() @@ -621,6 +614,8 @@ for (var i = 0; i < n_list.length; i++) { var nick_tmp = n_list[i]; + // replace spaces in nicks with + nick_tmp = nick_tmp.replace(/ /g, '\240'); if (nick_tmp.indexOf(nick_src) == 0) { if (! nick_match) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-12 16:22:48
|
Revision: 1117 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1117&view=rev Author: gpinzone Date: 2007-08-12 09:22:48 -0700 (Sun, 12 Aug 2007) Log Message: ----------- Moved Webkit/Konqueror cursor position fix into completeNick function. Modified to move cursor if setSelectionRange is supported rather than on browser id. Hopefully, this will fix newer versions of Konqueror. Rewrote insertSmiley to work truly as an "insert" function. Fixes Opera issue when smiley is inserted into an empty textbox. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-12 04:27:16 UTC (rev 1116) +++ trunk/data/public/js/pfcclient.js 2007-08-12 16:22:48 UTC (rev 1117) @@ -638,7 +638,17 @@ } } if (nick_match) + { w.value = non_nick_src + nick_src.replace(nick_src, nick_replace); + // Move cursor to end of line. + // This fixes Webkit (Safari) and hopefully newer Konqueror releases. + /* Konqueror does not support setSelectionRange() on KDE versions <3.5.2. */ + if (w.setSelectionRange) + { + var selEnd = w.value.length; + w.setSelectionRange(selEnd, selEnd); + } + } } }, @@ -744,21 +754,9 @@ } else if (code == 9) /* TAB key */ { - /* Konqueror has the same problem as Webkit (Safari), - but setSelectionRange() won't work on - KDE versions <3.5.2. Therefore, I'm leaving - the Webkit fix out for these browsers. */ - // Do nickname completion like on IRC / Unix command line. this.completeNick(); - var tb = evt.srcElement || evt.target; - if (is_webkit) - { - // Move cursor to end of line for Webkit (Safari). - var selEnd = this.el_words.value.length; - tb.setSelectionRange(selEnd, selEnd); - } if (is_opera) { // Fixes Opera's loss of focus after TAB key is pressed. @@ -766,7 +764,8 @@ // that executes the default key operation BEFORE the // keydown and keypress event handler. // This is probably the reason for the "up arrow" issue above. - window.setTimeout(function(){tb.focus();}, 0); + //window.setTimeout(function(){evt.target.focus();}, 0); + evt.target.onblur = function() { this.focus(); this.onblur = null; }; } if (evt.returnValue) // IE @@ -1030,10 +1029,30 @@ /** * insert a smiley */ - insertSmiley: function(s) + insertSmiley: function(smiley) { - this.el_words.value += s; - this.el_words.focus(); + var w = this.el_words; + + if (w.setSelectionRange) { + // Gecko + var s = w.selectionStart; + var e = w.selectionEnd; + w.value = w.value.substring(0, s) + smiley + w.value.substr(e); + w.setSelectionRange(s + smiley.length, s + smiley.length); + w.focus(); + } + else if (w.createTextRange) + { + // IE + w.focus(); + document.selection.createRange().text = smiley; + } + else + { + // Unsupported browsers get smiley at end of string like old times. + w.value += smiley; + w.focus(); + } }, updateNickBox: function(nickid) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-13 15:06:13
|
Revision: 1118 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1118&view=rev Author: gpinzone Date: 2007-08-13 08:06:14 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Added text selection tracking to fix annoying IE loss of selection and caret position. Will look to extend this fix to other areas like bbcode insertion. Tested on IE 6.0 and IE 7.0. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-12 16:22:48 UTC (rev 1117) +++ trunk/data/public/js/pfcclient.js 2007-08-13 15:06:14 UTC (rev 1118) @@ -81,6 +81,8 @@ // don't use this line because when doing completeNick the "return false" doesn't work (focus is lost) // Event.observe(this.el_words, 'keypress', this.callbackWords_OnKeypress.bindAsEventListener(this), false); Event.observe(this.el_words, 'keydown', this.callbackWords_OnKeydown.bindAsEventListener(this), false); + Event.observe(this.el_words, 'keyup', this.callbackWords_OnKeyup.bindAsEventListener(this), false); + Event.observe(this.el_words, 'mouseup', this.callbackWords_OnMouseup.bindAsEventListener(this), false); Event.observe(this.el_words, 'focus', this.callbackWords_OnFocus.bindAsEventListener(this), false); Event.observe(this.el_handle, 'keydown', this.callbackHandle_OnKeydown.bindAsEventListener(this), false); Event.observe(this.el_handle, 'change', this.callbackHandle_OnChange.bindAsEventListener(this), false); @@ -780,6 +782,16 @@ return true; } }, + callbackWords_OnKeyup: function(evt) + { + // Needed for IE since the text box loses caret position on blur + this.storeSelectionPos(); + }, + callbackWords_OnMouseup: function(evt) + { + // Needed for IE since the text box loses caret position on blur + this.storeSelectionPos(); + }, callbackWords_OnFocus: function(evt) { // if (this.el_handle && this.el_handle.value == '' && !this.minmax_status) @@ -1027,6 +1039,35 @@ }, /** + * Stores the caret position for IE 6.x and 7.x + * Code based on: http://www.bazon.net/mishoo/articles.epl?art_id=1292 + */ + storeSelectionPos: function() + { + var w = this.el_words; + + // IE + if (w.createTextRange && document.selection) + { + // Determine current selection start position. + var range = document.selection.createRange(); + var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0; + if (!isCollapsed) + range.collapse(true); + var b = range.getBookmark(); + w.selStart = b.charCodeAt(2) - b.charCodeAt(0) - 1; + + // Determine current selection end position. + range = document.selection.createRange(); + isCollapsed = range.compareEndPoints("StartToEnd", range) == 0; + if (!isCollapsed) + range.collapse(false); + b = range.getBookmark(); + w.selEnd = b.charCodeAt(2) - b.charCodeAt(0) - 1; + } + }, + + /** * insert a smiley */ insertSmiley: function(smiley) @@ -1045,7 +1086,25 @@ { // IE w.focus(); - document.selection.createRange().text = smiley; + + // Set range based on stored values. + var range = w.createTextRange(); + range.collapse(true); + range.moveStart("character", w.selStart); + range.moveEnd("character", w.selEnd - w.selStart); + range.select(); + + //document.selection.createRange().text = smiley; + range.text = smiley; + + // Check if internally kept values for selection are initialized. + if (w.selStart && w.selEnd) + { + w.selStart += smiley.length; + w.selEnd = w.selStart; + } + else + this.storeSelectionPos(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gpi...@us...> - 2007-08-13 17:08:33
|
Revision: 1119 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1119&view=rev Author: gpinzone Date: 2007-08-13 10:08:34 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Simplified caret position update on smiley insert for IE. Modified Paths: -------------- trunk/data/public/js/pfcclient.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-08-13 15:06:14 UTC (rev 1118) +++ trunk/data/public/js/pfcclient.js 2007-08-13 17:08:34 UTC (rev 1119) @@ -1097,14 +1097,10 @@ //document.selection.createRange().text = smiley; range.text = smiley; + // Increment caret position. // Check if internally kept values for selection are initialized. - if (w.selStart && w.selEnd) - { - w.selStart += smiley.length; - w.selEnd = w.selStart; - } - else - this.storeSelectionPos(); + w.selStart = (w.selStart) ? w.selStart + smiley.length : smiley.length; + w.selEnd = w.selStart; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |