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

nickname completion challenge

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

Post a reply
1 post • Page 1 of 1

Postby phpfreechat » Fri Mar 10, 2006 1:26 pm

Hello,

I just integrated the TAB key multi-browser handling to support nicknames completions like on most IRC clients.
But the completion algorithme I written is very basic.
It would be great to have a better one.

Here is the basic code I wrote :
Code: Select all
  /**
   * 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);
    if (nick_src != '')
    {
      var ul_online = this.el_online.firstChild;
      for (var i=0; i<ul_online.childNodes.length; i++)
      {
        var nick = ul_online.childNodes[i].innerHTML;
        if (nick.indexOf(nick_src) == 0)
          w.value = w.value.replace(nick_src, nick);
      }
    }
  },

- this.el_words is the form text input widget where text is typed.
- this.el_online is the html nickname list using <ul> and <li>, but it would be easier to use the javascript array which containes exatly the same : this.nicklist

The challenge is to simplify this algorithme and improve it in order to :
- make possible to choose which nickname to use if two nickname starts with the same prefix, example: if the two nicks are "bob" and "boby", when the user type "bo"+TAB, the algorithme can't choose.
- ... list to complete :)

For those who want to help, just checkout the subversion head : svn co http://www.phpfreechat.net/svn/trunk
Then open this file : phpfreechat/themes/default/templates/pfcclient.js.tpl.php
And search for the completeNick function.

Anyway, any ideas are welcomed to help :)
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Post a reply
1 post • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 15 guests

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