• 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

Setting a username color

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

Post a reply
12 posts • Page 1 of 1

Postby OldWolf » Sun Sep 23, 2007 6:47 am

First, I'd like to say a big thanks to the author(s?) of phpfreechat... I went through some 30 different websites for chatroom applications, and this one was by far the most customizable, feature rich, utilizable software package available. It was also somewhat funny because I must have downloaded and installed in hours, or even minutes, before version 1.0 (final) was released. I already have to upgrade!

At any rate, my question is pretty simple:
I saw that there's a way to choose the colors randomly assigned to users.
In my system, users will have their usernames assigned and frozen from their logged in SESSION names. I'd like to also set their colors according to their usergroup (I.E. All moderators are red, all admin blue, premium users green, whatever). Is there a way to set their color when I set their name, or am I going to have to make my own modifications to do so?

Along those same lines... is there a way to establish admin or operator status when I assign the name?

Thanks very much!
James

(edited to clarify which version of the software I meant)
Last edited by OldWolf on Sun Sep 23, 2007 10:35 am, edited 1 time in total.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby phpfreechat » Sun Sep 23, 2007 7:05 pm

Currently you cannot customize the nickname color.
Concerning the admin status, have a look to "admins" and "isadmin" parameters.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby OldWolf » Sun Sep 23, 2007 10:53 pm

Okie dokie... When I make the changes for the username, would you like a summary to consider for publication or a mod?
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby phpfreechat » Mon Sep 24, 2007 8:20 am

Yes, i think it would be an improvement so i'll integrate your contribution in official source code if it's well written.
I suggest you use the "nickmeta" parameters to do such thing.
For example:
$params['nickmeta']['color'] = '#F5301A';

When the contribution is finished please post a patch (diff between subversion trunk and your work) so it will be easier for me to integrate it.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby OldWolf » Mon Sep 24, 2007 10:26 pm

Sure thing... it'll take me some time to familiarize myself with your style and softwear so I can make it a solid mod. :)
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby OldWolf » Tue Sep 25, 2007 10:41 am

I have a decent start on this... I have the user list display colors as set by your indicated parameter.. but I run into a problem with the actual chat.

Unless I'm misreading it, the sender's id is never passed into handleComingRequest. Since I have no ID, I have no way to pull the meta array values, and therefor have no way to know if color has been set or not.

Also, and this is minor, but don't you normally use the nickmeta array for the little drop down profile? Are you sure this is the way you'd like me to go about it?

I think I may be stuck, any ideas? Should I just add a function at the end to recolor the usernames (this seems fairly inefficient)? Ideas are welcome, as are corrections to my assumption about the ID. :P

Edited because I'm tired and not making sense! :P
Last edited by OldWolf on Tue Sep 25, 2007 10:44 am, edited 1 time in total.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby phpfreechat » Tue Sep 25, 2007 1:30 pm

Ok, i can explain you this line :
Code: Select all
line += 'class="pfc_nickmarker pfc_nick_'+ hex_md5(_to_utf8(sender)) +'">';

It's a bit dirty but the nickid value is generated by "hex_md5(_to_utf8(sender))".

I think you should create a colorizeNick function and call it after updateNickWhoisBox in the handleResponse function :
Code: Select all
      if (resp == "ok")
      {
        this.setUserMeta(nickid, param);
        this.updateNickBox(nickid);
        this.updateNickWhoisBox(nickid);
      }

The colorizeNick should just colorize the "pfc_nick_(nickid)" CSS class.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby OldWolf » Tue Sep 25, 2007 2:20 pm

That works, and probably a bit cleanier than my approach to boot. :)

Thanks for the pointers. :)
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby OldWolf » Thu Sep 27, 2007 10:02 am

Here's my little js bit (not yet finished, see below):

Code: Select all
   setUserColor: function(nickid)//here
  {
     var setcolor = this.getUserMeta(nickid, 'color');
      if (setcolor != ''){
      var allMatches = document.getElementsByTagName('*');
      var compare = new RegExp('.*'+'pfc_nick_'+nickid+'.*');
      for(i=0; i<allMatches.length; i++) {
        if(allMatches.item(i).className.match(compare))
           {
             var cur_item = allMatches.item(i).innerHTML;
          allMatches.item(i).style.color = setcolor;
           }
      }
      }
   },

The function is included as you suggested, just after the other two in the handle response function. :)

Code: Select all
      if (resp == "ok")
      {
        this.setUserMeta(nickid, param);
        this.updateNickBox(nickid);
        this.updateNickWhoisBox(nickid);
            this.setUserColor(nickid); //here
      }

I have the userlist properly coloring based on the correct usermeta. Is there a way I can expand this (easily) to the chatroom window portion? I am having a bit of a tough time following the code with respects to the windows, due to my limited javascript skills (I'm much more comfortable in php!). From what it looks like to me, I'll only be able to process the menu from this point in the script, but as I said, I'm not very good at js, so it's I'm likely not reading it right. How would I go about getting the chatroom itself correctly colored for those user names? Any tidiness issues in my above code?

Thanks,
James
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby OldWolf » Thu Sep 27, 2007 10:03 am

Eww, my braces got all jumbled here in the message... sorry about that. :/
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby phpfreechat » Mon Oct 01, 2007 10:22 am

I think these lines are not very optimized :
Code: Select all
var allMatches = document.getElementsByTagName('*');
var compare = new RegExp('.*'+'pfc_nick_'+nickid+'.*');

A better way would be to add (or change) directly the css rule identified by the 'pfc_nick_'+nickid selector.
However, i have no ideas if it is easy to add a global css rule using just javascript.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby OldWolf » Mon Oct 01, 2007 9:56 pm

As I said, I'm not very good with javascript, so I have no further ideas, lol.
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top


Post a reply
12 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 5 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