• 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

nick coloring

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

Post a reply
11 posts • Page 1 of 1

Postby thegroover » Thu Jan 06, 2011 4:24 pm

Hi,

I checked http://www.phpfreechat.net/customize but the example does not work for me

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

chat index.php (part of it):
$params["nickmeta"] = array("mycolor" => "#BBBBFF");

ideally, this would color all nicks to BBBBFF but it does not...the default colors are appearing.

PFC 1.3, PHP 5.2.6

any help would be appreciated
thegroover
New member
 
Posts: 5
Joined: Thu Jan 06, 2011 4:13 pm
Top

Postby re*s.t.a.r.s.*2 » Thu Jan 06, 2011 5:20 pm

chat index.php (part of it):
$params["nickmeta"] = array("mycolor" => "#BBBBFF")

Try this instead!!!
Code: Select all
$params['nickname_colorlist']=array('#BBBBFF');

And the js part works but it must be set directly in pfcclient.js
on buildNickItem_modify_nick_style: function(nickid, span){}
regards..
Search gas prices in Los Angeles at tankUpLA
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby thegroover » Thu Jan 06, 2011 7:00 pm

I want to use 2 colors, one for the girls and one for the boys so nickname_colorlist is not good for me.
I check the js part in pfcclient.js, thanks for the tip ...
thegroover
New member
 
Posts: 5
Joined: Thu Jan 06, 2011 4:13 pm
Top

Postby thegroover » Thu Jan 06, 2011 7:44 pm

Well...the "color" property is not recognized, no matter where I type it. But I can change the "backgroundColor" property. Any idea why the text color is ignored?
thegroover
New member
 
Posts: 5
Joined: Thu Jan 06, 2011 4:13 pm
Top

Postby re*s.t.a.r.s.*2 » Thu Jan 06, 2011 8:27 pm

The chat isnt built for what you want , you need to set the color chosen at the login page or else...
in your registration system, Pass it in a session and set it on some variables , then on the $params['nickname_colorlist']=array($choosenColor); that would work although not tested ...

Nope dont think its going to work, it was a quick Idea that I had... but try it see what up..
Last edited by re*s.t.a.r.s.*2 on Thu Jan 06, 2011 8:34 pm, edited 1 time in total.
Search gas prices in Los Angeles at tankUpLA
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby thegroover » Thu Jan 20, 2011 5:26 pm

got the solution, if anyone is interested. might be a bit complicated though...

for the php code to work, I renamed pfcclient.js to pfcclient.js.php and edited chat.js.tpl.php to include the pfcclient.js.php

in the pfcclient.js.php I built an array with the nicknames and their colors, it is populated from the mysql database (actually it was 2 arrays, one for the name and one for the color, both has the same key for the 2 values, so "nickname" in name[0] has the color in color[0]...and so on). this was necessary to handle quotes and accents in the nicknames.

in the colorizeNicks function in pfcclient.js.php i search for the "cur_nick" variable in the name[] array and i assign the color from the color[] array: nicklist[i].style.color = color[j];

that's all, now all the girls are pink and all the boys are blue :)
thegroover
New member
 
Posts: 5
Joined: Thu Jan 06, 2011 4:13 pm
Top

Postby Doro » Fri Feb 18, 2011 2:29 pm

could you share this? I'm very interested in it!
Doro
New member
 
Posts: 1
Joined: Fri Feb 18, 2011 2:23 pm
Location: Argentina
Top

Postby wizjon » Wed Feb 23, 2011 8:41 pm

I'm very interested to. i tested this code http://www.phpfreechat.net/forum/viewtopic.php?id=1588 but i have to many problems. Sugestions ???
wizjon
New member
 
Posts: 5
Joined: Mon Feb 21, 2011 9:31 am
Top

Postby thegroover » Mon Feb 28, 2011 2:35 pm

ok, so here it is more detailed.

for the php code to work, I renamed pfcclient.js to pfcclient.js.php and edited chat.js.tpl.php to include the pfcclient.js.php.

pfcclient.js.php: paste this code. I pasted it after var pfcClient = Class.create(); (row #15)


Code: Select all
  var nickColors = new Array();
  var nickNames = new Array();
  <?php
      $host="127.0.0.1:3306";
      $user="your_user_here";
      $pass="your_pw_here";
      $db="your_db_here";
      mysql_connect($host,$user,$pass) or die('Connect error! #1');;
      mysql_select_db($db) or die('Connect error! #2');
      
     $q = mysql_query("select id, name, gender from partner");
     $girlColor = "#DDBCD2";
     $boyColor = "#BBBBFF";
     while ($data = mysql_fetch_assoc($q)) {
        echo "nickNames[".$data["id"]."] = '".str_replace("'", null, $data["name"])."';";
        if ($data["gender"] == 0) { // girl
           $color = $girlColor;
        }   else { // boy
           $color = $boyColor;
        }
        echo "nickColors[".$data["id"]."] = '".$color."';";
     }
  ?>

In this code I search for the gender, but you can search for any name...etc.

Then in the same file, edit the colorizeNicks function. (row around #1630). it should look like this:

Code: Select all
  colorizeNicks: function(root)
  {
    if (this.nickmarker)
    {
      var nicklist = this.getElementsByClassName(root, 'pfc_nickmarker', '');
      for(var i = 0; i < nicklist.length; i++)
      {
        var cur_nick = nicklist[i].innerHTML;
            var gotit = false;
            for (var j = 0; j < nickNames.length; j++) {
               if (nickNames[j]) {
                  if (nickNames[j] == cur_nick) {
                 nicklist[i].style.color = nickColors[j];
                 gotit = true;
                 break;
                  }
               }
            }
         if (!gotit) nicklist[i].style.color = '#222222';
      }
    }
  },
thegroover
New member
 
Posts: 5
Joined: Thu Jan 06, 2011 4:13 pm
Top

Postby wizjon » Mon Feb 28, 2011 11:27 pm

my replay:

a change this part code to integrate PhpBB3 forum(User from forum datebase)

Code: Select all
var nickColors = new Array();
  var nickNames = new Array();
  <?php
        $host="localhost";
        $user="user_database";
        $pass="user_password";
        $db="database_forum";
        mysql_connect($host,$user,$pass) or die('Connect error! #1');;
        mysql_select_db($db) or die('Connect error! #2');
       
      $q = mysql_query("select user_id,username from phpbb3_users");
   
   
      while ($data = mysql_fetch_assoc($q)) {
          echo "nickNames[".$data["user_id"]."] = '".str_replace("'", null, $data["username"])."';";
          if ($data["username"] == " ") { // girl
              $color = "#000000";
           }
        if ($data["username"] == "admin") {
              $color = "#FF0F2F";
          }
          
          if ($data["username"] == "jacek") {
              $color = "#BA55D3";
           }
            
            if ($data["username"] == "ewap") {
              $color = "#48D1CC";
           }
          
         if ($data["username"] == "meg") {
              $color = "#000055";
           }
                 
      
          echo "nickColors[".$data["user_id"]."] = '".$color."';";
      }
  ?>

and nick coloring is WORKING :D and i have color wath i need.
Last edited by wizjon on Mon Feb 28, 2011 11:28 pm, edited 1 time in total.
wizjon
New member
 
Posts: 5
Joined: Mon Feb 21, 2011 9:31 am
Top

Postby r0b33 » Mon Dec 12, 2011 9:43 pm

my attempt to integrate in vldpersonals:

this code integrated to the pfcclient.js with this arrays >>var nickColors = new Array(); var nickNames = new Array();<<, and renamed to pfcclient.js.php
Code: Select all
<?php
$host = "servername";         // this changed for security reason
$user = "u118732108_root";      // this changed for security reason
$pass = "raffaella";            // this changed for security reason
$db   = "u118732108_db";         // this changed for security reason
mysql_connect( $host, $user, $pass ) or die( 'Connect error! #1' );
mysql_select_db( $db ) or die( 'Connect error! #2' );

// the vldpersonals stores in 2 tables that information what we need vld_members & vld_members data
// here we get the username & userid pairs

$q         = mysql_query( "select member_id, username from vld_members" );
$girlColor = "#DDBCD2";
$boyColor  = "#BBBBFF";
while ( $data = mysql_fetch_assoc( $q ) ) {
                echo "nickNames[" . $data[ "member_id" ] . "] = '" . str_replace( "'", null, $data[ "username" ] ) . "';";
}

// here we get the gender data

$q = mysql_query( "select data_id, data_gender from vld_members_data" );
while ( $gender = mysql_fetch_assoc( $q ) ) {
                if ( $gender[ "data_gender" ] == 2 ) {
                                $color = $girlColor;
                } else {
                                $color = $boyColor;
                }
                echo "nickColors[" . $gender[ "data_id" ] . "] = '" . $color . "';";
}
?>

and of course the other part...

if i make a standalone test.php and running it http://www.myhost.com/test.php
the result:

Code: Select all
nickNames[1] = 'user1';nickNames[4] = 'user2';nickNames[6] = 'user3';nickColors[1] = '#BBBBFF';nickColors[4] = '#BBBBFF';nickColors[6] = '#DDBCD2';

i think the code working perfectly

my problem is the chat.js.tpl.php calls...

what i need to editing in this line?
Code: Select all
<script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/pfcclient.js"></script>

i'm try this:

Code: Select all
<script type="text/javascript" src="<?php echo $c->data_public_url; ?>/js/pfcclient.js.php"></script>

and this:

Code: Select all
<? include '/js/pfcclient.js'; />

without luck... the chat won't starting
any tips, and or help?
r0b33
New member
 
Posts: 1
Joined: Tue Oct 11, 2011 8:58 pm
Top


Post a reply
11 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

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