Version: 1.00, by n.sinha.p
Developer Last Online: May 2012
Category: Forum Display Enhancements -
Version: 3.8.1
Rating:
Released: 02-09-2009
Last Update: Never
Installs: 114
Template Edits
Re-useable Code Additional Files Translations
No support by the author.
Info:
Rainbow effect (Multicolour) for Usernames
This simple hack enables to display usernames for any usergroup in random multicolour (rainbow) effect.
Having searched for the same effect for my board unsuccessfully where most of the modifications were for BBCodes, I came up with my own and though of sharing.
Please note that since it is based on pure HTML and JavaScript and in no way uses any BBcode of VB function/hooks, this is compatible with all versions of vBulletin.
Installation:
Time Required: 2 minutes
1. FTP rainbow.js to clientscript directory on your server in ASCII mode
2. Open headinclude template and add the following code at any reasonable place:
3. Open footer template and add the following code at the bottom:
Code:
<!-- rainbow text initialize -->
<script type="text/javascript">
<!--
rain();
// End -->
</script>
<!-- rainbow text end -->
4. Open the Usergroup Manager throug ACP and edit the desired user group.
5. Put start tag as:
Code:
<span class="rainbow">
6. Change the end tag to be:
Code:
</span>
You're Done! Enjoy!!
Versions: v1.0 - 10 February 2009
- Rainbow text effect for usernames
I may think of creating a plugin for this if I get time and people ask for it. But for now it is pretty simple and I would prefer having a hack rather than going for a plugin which would increase the load on your board's performance.
A Note: If you are using vbshout.. the effect will not show in the AJAX area. However, it will still display the usernames in the AJAX area and the rainbow effect will be available in shoutbox archive.
:up:Added & hidden bonus is that you can use this hack anywhere where you can use HTML code.. in almost any area you can think of!
Replace this code for rainbow.js. ^^ It'll be cool...
Code:
/**
Rainbow Text
**/
function RGB2Color(r,g,b)
{
return '#' + byte2Hex(r) + byte2Hex(g) + byte2Hex(b);
}
function byte2Hex(n)
{
var nybHexString = "0123456789ABCDEF";
return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1);
}
function colorText(str,phase)
{
var result="";
if (phase == undefined)
phase = 0;
center = 128;
width = 127;
frequency = Math.PI*2/str.length;
for (var i = 0; i < str.length; ++i)
{
red = Math.sin(frequency*i+2+phase) * width + center;
green = Math.sin(frequency*i+0+phase) * width + center;
blue = Math.sin(frequency*i+4+phase) * width + center;
result += ( '<font color="' + RGB2Color(red,green,blue) + '">' + str.substr(i,1) + '</font>');
}
return result;
}
function nickmausac(classname){
var txtValue = "";
var b = getElementsByClassName(classname);
for ( var i = 0; i < b.length; i++ ) {
txtValue = colorText(b[i].innerHTML,1);
b[i].innerHTML = txtValue;
}
}
Use same as this mod...
Code:
<span class="rainbow">
add to footer//
Code:
<!-- rainbow text initialize -->
<script type="text/javascript">
<!--
nickmausac('rainbow');
// End -->
</script>
<!-- rainbow text end -->
I have same as ideas by my sister, she asked me take her nickname has rainbow color... ^^
Does not work ... I did your edits.
You forgot to include
Code:
function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className)) a.push(els[i]);
return a;
}
in your js file.
The rainbow color does not appear until everything on the page has been loaded..
function getElementsByClassName(classname, node) {
if(!node) node = document.getElementsByTagName("body")[0];
var a = [];
var re = new RegExp('\\b' + classname + '\\b');
var els = node.getElementsByTagName("*");
for(var i=0,j=els.length; i<j; i++)
if(re.test(els[i].className)) a.push(els[i]);
return a;
}
in your js file.
The rainbow color does not appear until everything on the page has been loaded..
Ok, installed, but the names for the specific usergroup I'm applying this to shows up as "undefined" for each letter in the usergroup name and the actual member's name. The colors show up fine, so what would cause the letters to show up as "undefined"? Example:
Ok, installed, but the names for the specific usergroup I'm applying this to shows up as "undefined" for each letter in the usergroup name and the actual member's name. The colors show up fine, so what would cause the letters to show up as "undefined"? Example:
Ok! This means the mod is not able to handle the names when embedded by multiple random span tags. Let me install the mod and see if I can come up with an enhancement to overcome this.
nice , is it possible to have certain colors in this random things as some of the colors would be not really readable in some styles ( dark / white ones ) ?
nice , is it possible to have certain colors in this random things as some of the colors would be not really readable in some styles ( dark / white ones ) ?
thanks
Thanks for your feedback.
It is quite possible and very soon I will be uploading the enhancement.