So recently i followed the tutorial made on here to make a rainbow username. And when i put this under the group name, it told me that i cant use script, meta, or base tags.
<span style="font-weight: bold; color:#27A727;"><i><SCRIPT language="JavaScript">var rainbowcount=(rainbowcount+1); document.write("<span id='rain"+rainbowcount+"'>"); </SCRIPT>{username}</i></span>
Is there any other way to do this? If i have to go a new route to get a rainbow name, i will. Thanks!
What I would recommend doing is assigning a class in the span. You can then use jQuery to handle this for you. I'd recommend something like this:
$(document).ready(function() {
$(".rainbow").each(function () {
// your code would go here
});
});
(2015-06-05, 12:52 PM)dragonexpert Wrote: [ -> ]What I would recommend doing is assigning a class in the span. You can then use jQuery to handle this for you. I'd recommend something like this:
$(document).ready(function() {
$(".rainbow").each(function () {
// your code would go here
});
});
Thanks for the reply, but what goes in the "Your code would go here" area?
You initialize a variable. You then either use a Switch statement or a bunch of if / else if / else statements based on the variables value. You will use this to figure out what color it should be.
var myvar = 1;
var mystring = $(this).text();
var looper = 1;
splitter = mystring.split(""); // Set each letter as a new element
var rainbowname = "";
for(x in splitter)
{
if(looper % 7 == 1)
{
color = "red";
}
else if(looper % 7 == 2)
{
color = "blue";
}
// etc.
else
{
color = "violet";
}
rainbowname = rainbowname + "<span style='color:" + color + "'>" + splitter[x] + "</span>";
looper += 1;
} // Closes the for in loop
Ok, thank you for the help!
(2015-06-06, 12:49 PM)dragonexpert Wrote: [ -> ]You initialize a variable. You then either use a Switch statement or a bunch of if / else if / else statements based on the variables value. You will use this to figure out what color it should be.
var myvar = 1;
var mystring = $(this).text();
var looper = 1;
splitter = mystring.split(""); // Set each letter as a new element
var rainbowname = "";
for(x in splitter)
{
if(looper % 7 == 1)
{
color = "red";
}
else if(looper % 7 == 2)
{
color = "blue";
}
// etc.
else
{
color = "violet";
}
rainbowname = rainbowname + "<span style='color:" + color + "'>" + splitter[x] + "</span>";
looper += 1;
} // Closes the for in loop
(2015-06-07, 12:43 PM)dragonexpert Wrote: [ -> ]Is this solved?
Not sure yet. Been busy and haven't had the time to test. Ill do it soon.
Here is a small modification of the script :
// ncolors is the array of colors you want to use
// Fill it with names or hex codes (with the #)
var ncolors = new Array('aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple', 'red', 'silver', 'teal', 'white', 'yellow');
var mystring = $(this).text();
var looper = 0;
splitter = mystring.split(""); // Set each letter as a new element
var rainbowname = "";
for(x in splitter)
{
pcol = looper % ncolors.length;
rainbowname += "<span style='color:" + ncolors[pcol] + "'>" + splitter[x] + "</span>";
looper++;
}
So, you can use all the colors you need / want