Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I can't tell but is the chat room supposed to make everyone's name in a different color? It doesn't seem to be doing that on our site:
http://www.tribalectic.com/Drupal/chatrooms/chat/1
Am I missing something or does this feature not exist?
-Drew
Comments
Comment #1
manimal CreditAttribution: manimal commentedI'm having the same problem.. they just all come up red text. I'm using the dev release from january of this year.
Comment #2
Hinode CreditAttribution: Hinode commentedThe persistent red color seems to be a bug in the following code: ($Id: chatroom.module,v 1.59.2.67 2007/10/05 19:37:34 darrenoh Exp $)
Line 1310
The array $colours[] was populated with the same object ($colour), thus, have the same reference in memory and all elements assume the value of the last assign (color = #CC0000).
I do not know PHP, but the following code work for me and maybe indicate a way to more simple solutions.
If users colors yet do not work, try enable the "Chat Room: chat on-line list" block. I'm not sure, but the "Drupal.settings.chatroom.chatUsers.length" is not actualizing and a call to the on-line list do this.
Comment #3
manimal CreditAttribution: manimal commentedtried it, and it didn't seem to work for me..
I have the online list block enabled as well, and it shows the red usernames in that as well..
Comment #4
Hinode CreditAttribution: Hinode commentedI do not know why the code above didn't work for you...
In fact, I'm using drupal 5.5 and chatroom 5.x-1.x-dev (not 5.x-1.9).
You may try to verify if the code is ok by adding the following line (try before and after the suggested patch) and see if the array was populated in the right way.
(don't forget excluding the
tags)
With the patched code, all times you enter in a chatroom the header should be like this:
Otherwise, with the orignal code, all colors will be #CC0000 (at least it was happening here).
In addition, examine the chatroom.js (line 260):
p.css('color', Drupal.chatroom.chat.getUserColour(msgs[i].user));
and replace to:
alert('color: ' + Drupal.chatroom.chat.getUserColour(msgs[i].user));
p.css('color', Drupal.chatroom.chat.getUserColour(msgs[i].user));
Now, every message you send to chat trigger an alert window that show the color assign to the current user (or other user, if sent by a remote machine). In fact, that color was (random) assigned the first time the current user send a message. A remote user color was assign the same way, but here the Drupal.settings.chatroom.chatUsers.length must reflect the correct number of users in a chatroom, otherwise the user get a black color (undefined).
Obs: I note that the user colors you see in your screen is not the same that others will see in yours.
Comment #5
manimal CreditAttribution: manimal commentedokay, that worked..
seemed the code you posted did work.. I just didn't think you changed much more than the part attached above the "function _chatroom_load_hex_colours" section.. I missed the line: $colour = new objColour;
works nicely.. thanks a lot!
Comment #6
szegadlo CreditAttribution: szegadlo commentedThe much simpler solution is to put:
$colours[] = clone $colour;
instead of:
$colours[] = $colour;
And that's it. (On-line block has to be enabled.)
Comment #7
tsaorin CreditAttribution: tsaorin commentedIt would be prettier if the text of each user was printed with the same color of the user name.
I don't know much php, but I suppose It would be easy to find where Chatroom write the text and applies the same color its author.
Comment #8
Darren OhComment #9
Flying Drupalist CreditAttribution: Flying Drupalist commentedFix works for me. Hopefully this will go into the next patch.
Comment #10
geerlingguy CreditAttribution: geerlingguy commentedBumping to current version - I'm wondering where to configure this at all... everyone gets a blue username in my chats; I'd like to have users have different colors (maybe even let users choose a color on their profile page—that'd be icing on the cake, though).