• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

My try for better nickname recognition

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
2 posts • Page 1 of 1

Postby Bernhard J. M. Grün » Thu Mar 02, 2006 11:36 pm

Hi,

at the moment pfc also highlights a nickname if it is in between a word. I tried to fix that by using the following lines (instead of the old ones) (function parseMessage):
Code: Select all
rx = new RegExp('(^|[^A-Za-z0-9])'+RegExp.escape(this.nickname)+'([^A-Za-z0-9]|$)','g');
msg = msg.replace(rx, '$1<strong>'+ this.nickname +'</strong>$2');

Instead of using a negation. We could also use something like that:
Code: Select all
rx = new RegExp('(^|[:.,;])'+RegExp.escape(this.nickname)+'([:.,;]|$)','g');
msg = msg.replace(rx, '$1<strong>'+ this.nickname +'</strong>$2');

I have another suggestion: Most people wont write a nickname case sensitive therefox the nickname highlighting should not me case sensitive. So I suggest to change "g" to "gi".

Just a remark:
Nicknames should be - in general - (at least for latin languages) not case sensitive to be more IRC conform.

Bernhard
Bernhard J. M. Grün
Member
 
Posts: 13
Joined: Thu Feb 23, 2006 3:42 pm
Location: Püttlingen, Saarland, Germany
  • Website
  • ICQ
Top

Postby phpfreechat » Fri Mar 03, 2006 9:54 am

I just integrated you 2nd proposal but with a little modification :
Code: Select all
rx = new RegExp('(^|[ :.,;])'+RegExp.escape(this.nickname)+'([ :.,;]|$)','g');
msg = msg.replace(rx, '$1<strong>'+ this.nickname +'</strong>$2');

I added a " " (space) into the special chars list.

Anyway thank you for this nice enhancment !
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top


Post a reply
2 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 6 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub