We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
[ C ] Moderator posting background different colour; EX: Admins have a gold bg, mods have green
Topic Started: Mar 29 2010, 06:43 PM (427 Views)
Kevin Koehler
Member
[ * ]
Hey guys, I was wondering if someone could write a code for an invisionfree forum which allows different groups to have different posting background. For example: Global moderators's post background would be green.

I've seen a few of these on the forums. The only problem is that it only colours the post section and not the section beside it where the avatar is etc.

I've got one which only allows the poster background, not the table beside it, so if you want to build from it... here it is:

Code:
 
<script>
adminnames=new Array();
l=0;
adminnames[l++]="Shane";

tds=document.getElementsByTagName("td");
for (p=0; p<tds.length; p++) {
for (m=0; m<adminnames.length; m++) {
temp=tds[p].getElementsByTagName("span");
for(x=0;x<temp.length;x++){
if (temp[x].className=="normalname" && temp[x].getElementsByTagName("a").length==1 && temp[x].getElementsByTagName("a")[0].innerHTML.toLowerCase().indexOf(adminnames[m].toLowerCase())!=-1)
{
tds[p+3].style.backgroundColor="#06C300";
}
}
}
}
</script>


Thank you very much in advance. :)

~Kevin
Offline Profile Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
With the help from a few other coders, here's what we were able to produce:
Quote:
 
<script type="text/javascript">
function change(group, color) {
var y = document.getElementsByTagName('span');
for (x = 0;x < y.length;x++) {
if (y[x].className == "postdetails" && y[x].innerHTML.match(/Group: (.*)/i)) {
if (RegExp.$1.match(group)) {
var c = y[x].parentNode.parentNode.getElementsByTagName('td');
var b = c.length;
while (b--) {
if (c[b].className == "post1" || c[b].className == "post2") {
c[b].style.background = color;
}
}
}
}
}
}
change("Admin", "red");
change("Global Moderator", "#000");
</script>
Offline Profile Goto Top
 
Kevin Koehler
Member
[ * ]
Thanks so much dude! Seriously, very thankful! :D
Just one quick addition... is it possible to make groups also change their font color? Thanks <3
Edited by Kevin Koehler, Mar 29 2010, 11:59 PM.
Offline Profile Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Quote:
 
<script type="text/javascript">
function change(group, color, tcolor) {
var y = document.getElementsByTagName('span');
for (x = 0;x < y.length;x++) {
if (y[x].className == "postdetails" && y[x].innerHTML.match(/Group: (.*)/i)) {
if (RegExp.$1.match(group)) {
var c = y[x].parentNode.parentNode.getElementsByTagName('td');
var b = c.length;
while (b--) {
if (c[b].className == "post1" || c[b].className == "post2") {
c[b].style.background = color;
c[b].style.color = tcolor;
}
}
}
}
}
}
change("Admin", "red", "#000");
change("Global Moderator", "#000", "red");
</script>
Offline Profile Goto Top
 
Kevin Koehler
Member
[ * ]
Awesome dude! Thanks so much :)
Offline Profile Goto Top
 
Roby-ZNR
Member Avatar
Efficacy
[ *  *  *  *  *  * ]
Completed!

Your code request has been completed.

Thank you for using our Member Request system here at Zathyus Networks Resources! If you have any questions regarding this topic, feel free to PM the code creator or post a new topic in the request forum. :)

Have a nice day!
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Closed Requests · Next Topic »
Locked Topic