Randomize name color
3 posters
Page 1 of 1
Randomize name color
I know it's possible to make a color change with each refresh using JS, but is there any way to apply this to a username maybe?
Last edited by Derp-chan on August 17th 2015, 5:03 pm; edited 1 time in total
Re: Randomize name color
if the user is in a group. then its close to impossible without heavy coding.
Re: Randomize name color
It's possible, you'll just need to use JavaScript to apply a random class. For example :
Go to Modules > JavaScript codes management > New script
Placement : In all the pages
The script above will apply a random class to users 1 and 3, whereas user 2 is stuck with .style_3. The strings in the arrays are just random classnames for the example. You can change them to whatever you want.
Then you just have to write some styles for your classnames..![Smile](https://2img.net/i/fa/i/smiles/icon_smile.gif)
Go to Modules > JavaScript codes management > New script
Placement : In all the pages
- Code:
$(function() {
var users = {
'u1' : ['style_1', 'style_2', 'style_3'],
'u2' : ['style_3'],
'u3' : ['style_1', 'style_2']
},
a = document.getElementsByTagName('A'), i = 0, j = a.length, k;
for (; i < j; i++) for (k in users) if ($(a[i]).attr('href') == '/' + k) a[i].className += ' ' + users[k][Math.floor(Math.random() * users[k].length)]
});
The script above will apply a random class to users 1 and 3, whereas user 2 is stuck with .style_3. The strings in the arrays are just random classnames for the example. You can change them to whatever you want.
Then you just have to write some styles for your classnames..
![Smile](https://2img.net/i/fa/i/smiles/icon_smile.gif)
- Code:
.style_1, .style_1 > span { color:red !important }
.style_2, .style_2 > span { color:green !important }
.style_3, .style_3 > span { color:blue !important }
![-](https://2img.net/i/empty.gif)
» Randomize your forum banner
» "Randomize your forum banner" not displaying banner in correct position
» Add a color to the top of the last post in categories with the same color as the group
» Background color and text color by rank
» How can I create a color image surrounding the names and each name has a different image color
» "Randomize your forum banner" not displaying banner in correct position
» Add a color to the top of the last post in categories with the same color as the group
» Background color and text color by rank
» How can I create a color image surrounding the names and each name has a different image color
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum