The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Username in multiple colors

Go down

Tutorial Username in multiple colors

Post by Ange Tuteur January 17th 2014, 2:21 pm



Username in multiple colors


This tutorial will allow you to put more colors in the username of a member.

Username in multiple colors Captu307

Here are the steps :

1. ) Create a new Javascript

Administration Panel > Modules > Javascript codes management > Create a new Javascript

Remember to tick 'in all the pages'

Copy and paste the following code :

Code:
$(function(){
  multiColor(XX, 'MY HTML CODE');
  
  function multiColor(id, html){$('a[href="/u'+id+'"]').not(function(){return $("img",this)[0]}).html(html)}
});


2. ) Insert the details of a member into the code

- Replace the 2 "XX" in your code with the ID of a member. This ID can be found on the profile in the address bar after "/u".

Here is an example if we would put Ange Tuteur.

Username in multiple colors Captu308

Username in multiple colors 111

3. ) Put some color into the code

Once you have chosen your colors, you can insert it into your JS code.

Here is an example with my username Ange Tuteur in blue and green.

I have added this code in place of "MY HTML CODE"

Code:
<strong><font color="#32A4D5">Ange</font> <font color="#7BB92B">Tuteur</font></strong>

Username in multiple colors 112

Username in multiple colors 113

Now simply insert the desired color codes :

Code:
$(function(){
  multiColor(88576, '<strong><font color="#32A4D5">Ange</font> <font color="#7BB92B">Tuteur</font></strong>');
  
  function multiColor(id, html){$('a[href="/u'+id+'"]').not(function(){return $("img",this)[0]}).html(html)}
});

Then all you need to do is submit and you're done. Smile

Username in multiple colors 114

If you want to put several usernames in the same color, or different colors you can do the following in your Javascript code :

Simply copy and paste your final code, then modify the information about the member and colors.

Username in multiple colors 115

The resulting code :
Code:
$(function(){
  multiColor(88576, '<strong><font color="#32A4D5">Ange</font> <font color="#7BB92B">Tuteur</font></strong>');
  multiColor(46681, '<strong><font color="#32A4D5">Black</font> <font color="#7BB92B">Scorpion</font></strong>');
  
  function multiColor(id, html){$('a[href="/u'+id+'"]').not(function(){return $("img",this)[0]}).html(html)}
});

Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum