• 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

Changing nick colors

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

Post a reply
6 posts • Page 1 of 1

Postby patulo » Wed Jun 13, 2007 2:18 pm

Hi folks !. I'd like to know if it possible to decide which nick color will be assigned to each user, dynamically, on the fly.

I'm going to explain you better. What I really need to have is 2 different types of users, one should keep his nick color "A", and all other users the nick color "B".

I think that a simple way to get this working would be that when a user joins the chat, from PHP to select his nick color as a parameter.

Well, that's all.
Any idea, suggestion, would be VERY appreciated.
patulo
New member
 
Posts: 1
Joined: Wed Jun 13, 2007 1:57 pm
Top

Postby datacompboy » Mon Jun 25, 2007 11:16 am

for mine BW chat, i have set in startup script
$params['nickmeta'] = array(
"race" => $r['race'],
);
$params["theme_path"] = dirname(__FILE__);
$params["theme"] = "bw";

and in bw theme I have customize.js.php with:

pfcClient.prototype.buildNickItem = function(nickid) {
var nick = this.getUserMeta(nickid, 'nick');
var isadmin = this.getUserMeta(nickid, 'isadmin');
if (isadmin == '') isadmin = false;
var race = this.getUserMeta(nickid, 'race');
if (race == '') race = "Hm";
var allready_colorized = false;
var nickpos = 0;
for(var j = 0; j < this.nickcolor.length && !allready_colorized; j++)
{
if (this.nickcolor[j][0] == nick)
{
allready_colorized = true;
nickpos = j;
}
}
var li = document.createElement('li');
li.style.borderBottom = '1px solid #AAA';

var a = document.createElement('a');
a.setAttribute('href','#');
a.pfc_nick = nick;
a.pfc_nickid = nickid;
a.onclick = function(evt){
var d = pfc.getNickWhoisBox(this.pfc_nickid);
document.body.appendChild(d);
d.style.display = 'block';
d.style.zIndex = '400';
d.style.position = 'absolute';
d.style.left = (mousePosX(evt)-5)+'px';
d.style.top = (mousePosY(evt)-5)+'px';
return false;
}
li.appendChild(a);

if (isadmin) {
var img = document.createElement('img');
img.setAttribute('src', this.res.getFileUrl('images/user-admin.gif'));
img.setAttribute('alt', 'op');
img.style.marginRight = '5px';
img.setAttribute('class', 'pfc_nickbutton');
img.setAttribute('className', 'pfc_nickbutton'); // for IE6
a.appendChild(img);
}

var nobr = document.createElement('nobr');
var span = document.createElement('span');
span.setAttribute('class', 'pfc_nickmarker pfc_nick_'+nickid+' '+race);
span.setAttribute('className', 'pfc_nickmarker pfc_nick_'+nickid+' '+race); // for IE6
span.appendChild(document.createTextNode(nick));
nobr.appendChild(span);
a.appendChild(nobr);
if (!allready_colorized)
{
this.nickcolor.push(new Array(nick, race));
}
else
{
this.nickcolor[nickpos][1] = race;
}


return li;
};


and by having defined race in CSS i got the result :) every race have its own color.
-- suicide proc nearn call deathn suicide endp
datacompboy
Member
 
Posts: 74
Joined: Thu Jan 18, 2007 9:10 pm
Location: Novosibirsk
  • Website
  • ICQ
Top

Postby wizjon » Mon Feb 21, 2011 6:56 pm

Hello. i'have problem. What a class i must defined in CSS file ? How they must looks? i search ansver to color nick ex: Jacek=blue/ Ania=RED ond other.

I search ALL forum and dont the answer how te colorize nick.
Last edited by wizjon on Tue Feb 22, 2011 9:42 am, edited 1 time in total.
wizjon
New member
 
Posts: 5
Joined: Mon Feb 21, 2011 9:31 am
Top

Postby wizjon » Tue Feb 22, 2011 9:42 am

UPDATE: i replay my self :D


i used pfc 1.3

i add sript in customize.js in my theme folder.
add to line:
$params['nickmeta'] = array(
"race" => $r['race'],
);
to index.php

next to add line to index.php and style CSS to define color

in index $params["nickmeta"] = array('race' => $nickcolor["jacek"] = "green");
in Css class: .green {
color: #FF003A;
}

and color is thange but green everyone in the chat. i dont now how to define separated color to 1 user ex: Adam=blue JAcek=yelow Ania=green and more.



i search forum all night to Solutions my problem. but i dont finde working code co colorize nick.

Pliss help my Solutions my problem.
Last edited by wizjon on Tue Feb 22, 2011 9:45 am, edited 1 time in total.
wizjon
New member
 
Posts: 5
Joined: Mon Feb 21, 2011 9:31 am
Top

Postby wizjon » Wed Feb 23, 2011 9:07 pm

elo its Once again my  my conclusion: 
When i put te code ex:
$params["nickmeta"] = array("race" => $nickcolor["adam1"] = 'green'); 
$params["nickmeta"] = array("race" => $nickcolor["adam2"] =blue');
$params["nickmeta"] = array("race" => $nickcolor["adam3"] = 'yelow');
he changeable 'race' take a color from the Last race(yelow). and Each user have the same last color (last changeable race) . Any sugestions ?
wizjon
New member
 
Posts: 5
Joined: Mon Feb 21, 2011 9:31 am
Top

Postby lxndr » Sun Feb 27, 2011 7:54 pm

I have exactly the same problem. I want to be able to specify the nick colour based on the individual nick of the user. Have searched the various forum posts for some time now but there is no clear explanation of it. I've tried the following but it didn't work (despite /rehash, clearing browser cache and restarting it)

index.php ->

$params["nickmeta"] = array("mycolor" => "#0000FF"); (as an example based on a specific user name)


and in customize.js.php within themes/default folder:

pfcClient.prototype.buildNickItem_modify_nick_style = function(nickid, span) {
span.style.color = this.getUserMeta(nickid, 'mycolor');
}


I'm sure it can't be that difficult, I just need a clear explanation from someone if possible.
lxndr
New member
 
Posts: 4
Joined: Sun Feb 27, 2011 7:39 pm
Top


Post a reply
6 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

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