3 Replies - 758 Views - Last Post: 27 December 2012 - 06:28 AM

#1 Fluffy_Injun  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-December 12

Forum code to set Moderators to post in a set color

Posted 17 December 2012 - 08:28 PM

OK, so I have never coded for a forum and I have no idea where or how to begin. I want to make a code that would set moderators to post in a color. I understand that they could just post and use around there text but i want to simplify it to where they just post and the color is auto set. If anyone could lead me in a directions that would be greatly appreciated. I am not even sure if this is the place for it but i thought I would give it a try. THANKS in advance.

I did find this but it doesn't work and it's outside my understanding where it fails.

 <style type="text/javascript">
.usercolor{background-color:<font color="ADD8E6">000000</font>;}
</style>


<script type="text/javascript">
var monster=document.getElementsByTagName('td')
for(i=0;i<monster.length;i++){
if(monster<i>.className.match(/(windowbg|windowbg2)/i) && monster<i>.width.match(/20%/i) && this.location.href.match(/thread=/i) && monster<i>.innerHTML.match(/user=(admin|blue)/i)){
monster<i>.className=monster[i+1].className=monster[i+6].className="windowbg usercolor"
}
}
</script>


*I understand that they could just post and use around [ Color = ADD8E6 ] [ / color] there text...

Is This A Good Question/Topic? 0
  • +

Replies To: Forum code to set Moderators to post in a set color

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10693
  • View blog
  • Posts: 39,770
  • Joined: 27-December 08

Re: Forum code to set Moderators to post in a set color

Posted 17 December 2012 - 08:32 PM

Moved to Javascript. Please note that Java and Javascript are two separate languages.
Was This Post Helpful? 0
  • +
  • -

#3 Fluffy_Injun  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-December 12

Re: Forum code to set Moderators to post in a set color

Posted 19 December 2012 - 05:16 PM

Sorry didn't realize. Can someone help me out?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3559
  • View blog
  • Posts: 10,349
  • Joined: 08-June 10

Re: Forum code to set Moderators to post in a set color

Posted 27 December 2012 - 06:28 AM

first, there are a couple of syntax errors, which you can find in the Error Console.

wouldn’t it be easier to mark the cells of interest with a class name and target those specific cells (instead all of them)?

the href test should not be made inside the for loop, as it is constant for every cell. i.e. you only start the loop, if the href test succeeds.

if there are only windowbg and windowbg2 as class names (i.e. there is no windowbg3), it is sufficient to test for "windowbg" (at least /windowbg2?/ were more sensible).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1