|
Post by Wormopolis on Nov 3, 2009 6:38:25 GMT -8
Browser Tested: IE and FF placement: global footer (bottom)
scans page for group id number, then saves title from defined array and stores it for global display.
requires a HTML element with id="rankspot" to put the result
code:
<script type="text/javascript"> <!-- // userRank on Page // by Wormo // places result into DIV with id "rankspot"
rankTitles= [ [0,'Member'], //[id num , id title] doesnt have to be in order [1,'Admin Supreme'], [2,'GlobalModPerson'], [3,'ModPerson'], [5,'Head Graphics Mod'], [6,'Graphics Helper'], [4,'Code Helper'] //no comma last entry ];
// end user variables
var pb_userGroupTitle=''; if (document.cookie.match(new RegExp('pb_userGroupTitle=(.*?)(;|$)'))) { temp=RegExp.$1; pb_userGroupTitle=temp; } if (pb_username=='Guest') pb_userGroupTitle="Guest"; for (lnks=document.getElementsByTagName('a'), a=0; a<lnks.length; a++) { if (lnks[a].href.match(new RegExp('user='+pb_username,'')) && lnks[a].className && lnks[a].className.match(/group(\d+)/)) { var pb_userGroupNum=RegExp.$1; break; } } for (n=0; n<rankTitles.length; n++) { if (rankTitles[n][0]==pb_userGroupNum) { pb_userGroupTitle=rankTitles[n][1]; break; } }
if (pb_userGroupTitle!='') { document.getElementById('rankspot').innerHTML='Your Rank: '+pb_userGroupTitle; expDate=new Date(); expDate.setYear(expDate.getFullYear()+1); document.cookie='pb_userGroupTitle='+pb_userGroupTitle+'; expires='+expDate; } // --> </script>
Preview: under nav box on left.
|
|
|
Post by eveready on Nov 4, 2009 4:16:35 GMT -8
Good code.
Just a note. In the instructions above you say to use the id="rankstore', but in the code itself it is id="rankspot". It seems rankspot is the correct id.
|
|
|
Post by Wormopolis on Nov 4, 2009 4:55:48 GMT -8
<-- noob
|
|
|
Post by Wormopolis on Nov 5, 2009 21:35:22 GMT -8
fixed a logout bug
|
|