Customizing SMF > SMF Coding Discussion
Rainbow Color Membergroup
lazyness:
I've found this coding, but I'm not sure where to put it. Also do I have to edit it for every member that I apply it to?
--- Code: ---<script type="text/javascript">
/*
Multi-Colored Display Names for SMF by wildgoosespeeder
v2.2
Based from the JavaScript codes of
Two Colored Display Names by Code Dragon and Boccy109
from ProBoards
*/
var z = 0;
var e = "";
var a = document.getElementsByTagName('a');
var span = document.getElementsByTagName('span');
var memberscolors = [];
// [user id, display name, color 1, color 2, etc...]
memberscolors[z++] = ["1","Mr.Uniquez","FF0000","FF0000","000000","00FF00","00FF00","00FF00","00FF00","00FF00","00FF00","00FF00"];
for(loop = 0; loop < memberscolors.length; loop++)
{
e = "";
for(c = 0; c < memberscolors[loop][1].length; c++)
{
e += "<b><font color='#" + memberscolors[loop][(c % (memberscolors[loop].length - 2)) + 2] + "'>" + memberscolors[loop][1].charAt(c) + "</b></font>";
}
for(href = 0; href < a.length; href++)
{
if(a[href].href.match(new RegExp("action=profile;u=" + memberscolors[loop][0] + "$")) && a[href].innerHTML == memberscolors[loop][1])
{
a[href].innerHTML = e;
}
}
for(stylecheck = 0; stylecheck < span.length; stylecheck++)
{
if(span[stylecheck].innerHTML == memberscolors[loop][1])
{
span[stylecheck].innerHTML = e;
}
}
}
</script>
--- End code ---
IchBin™:
What do you want it to do. It looks like it only does it for a specific member. But you could probably pass any username and ID into that function with some PHP variables for more users.
lazyness:
--- Quote from: IchBin™ on February 05, 2011, 11:29:11 PM ---What do you want it to do. It looks like it only does it for a specific member. But you could probably pass any username and ID into that function with some PHP variables for more users.
--- End quote ---
I want to make the persons username have a sequence of colors like this:
Lazyness
User
Really Long Username
It's a sequence of colors. Not just a random selection. I guess you have to take into account spaces and such. But then again... If the modification attempted to color a SPACE then it would be a color at all and just a space.
Just ignore the fact that the selection of colors I chose to not suit the forum theme. The theme that I use is CoalBlack so it's not a problem.
IchBin™:
You should be able to put that code into the index.template.php file where the other <script> tags are. Yes, you'll have to add each member who's name you want colored that way.
★MR.TALENT★:
So the following code goes in the footer of the global footers and headers mod?
--- Code: ---<script type="text/javascript">
/*
Multi-Colored Display Names for SMF by wildgoosespeeder
v2.2
Based from the JavaScript codes of
Two Colored Display Names by Code Dragon and Boccy109
from ProBoards
*/var z = 0;
var e = "";
var a = document.getElementsByTagName('a');
var span = document.getElementsByTagName('span');
var memberscolors = [];
// [user id, display name, color 1, color 2, etc...]
memberscolors[z++] = ["1","MR.TALENT","FF0000","FF0000","000000","00FF00","00FF00","00FF00","00FF00","00FF00","00FF00","00FF00"];
for(loop = 0; loop < memberscolors.length; loop++)
{
e = "";
for(c = 0; c < memberscolors[loop][1].length; c++)
{
e += "<b><font color='#" + memberscolors[loop][(c % (memberscolors[loop].length - 2)) + 2] + "'>" + memberscolors[loop][1].charAt(c) + "</b></font>";
}
for(href = 0; href < a.length; href++)
{
if(a[href].href.match(new RegExp("action=profile;u=" + memberscolors[loop][0] + "$")) && a[href].innerHTML == memberscolors[loop][1])
{
a[href].innerHTML = e;
}
}
for(stylecheck = 0; stylecheck < span.length; stylecheck++)
{
if(span[stylecheck].innerHTML == memberscolors[loop][1])
{
span[stylecheck].innerHTML = e;
}
}
}
</script>
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version