|
Post by Wormopolis on Nov 13, 2011 16:40:04 GMT -8
browser tested: IE, FF and Chrome placement: divs go where you need them, script goes in global footer (below divs)
this will let you create multiple div elements that will show for only certain usergroups. you can have multiple divs show based on what usergroups you allow to see them. you can also have divs only show for guests. all divs start out as hidden and only show after usergroup has been captured. usergroup is captured off a link to the member's name, so if the script never finds a link, no divs show.
The Divs can go where you need them to show, as long as they appear before the script runs. here are some example divs:
<style type="text/css"> .SquirrlyDiv {display: none;} </style>
<center> <div class="SquirrlyDiv SQgroup1" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 1 only <br> hopefully </div> <div class="SquirrlyDiv SQgroup1 SQgroup2" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 1 and 2 <br> hopefully </div> <div class="SquirrlyDiv SQgroupG" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for groupG (guests) <br> hopefully </div> <div class="SquirrlyDiv SQgroup2 SQgroup0" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 2 and 0 <br> hopefully </div> <div class="SquirrlyDiv SQgroup1 SQgroup2 SQgroup11" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 1, 2 and 11 <br> hopefully </div> <div class="SquirrlyDiv SQgroup11" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 11 only <br> hopefully </div> <div class="SquirrlyDiv SQgroup0" style="background: #000000; border: #ff0000 1px solid; color: #ffffff"> This div should show for group 0 only <br> hopefully </div> </center>
the CSS at the very top is required to keep all divs hidden until usergroup is captured. SQgroupG is for guests. SQgroup0 is for members not in a group. multiple groups can be assigned to a div with a simple space between them in the classname.
The script should go in global footer for best chance of capturing the correct usergroup.
<script type="text/javascript"> <!-- // divs revealed by usergroup // by Wormopolis - www.wormocodes.com // request by absinthe // keep header intact
for (lnks=document.getElementsByTagName('a'), ug=0; ug<lnks.length; ug++) { if (lnks[ug].className && lnks[ug].className.match(/group/) && lnks[ug].href.match(/action=viewprofile&user=(.*?)$/)) { var lnkuser=RegExp.$1; if (lnkuser==pb_username) { var tmptime=new Date(); tmptime.setFullYear(tmptime.getFullYear()+1); var pb_usergroup=lnks[ug].className; document.cookie="pb_usergroup="+pb_usergroup+"; expires="+tmptime; break; } } }
if (pb_username=='Guest') { var holdgroup="groupG"; } else { if (document.cookie.match(/pb_usergroup=(.*?)($|;)/)) { var holdgroup=RegExp.$1; } else { // not a guest but usergroup hasnt been captured. assume not a guest, but dont reveal any divs var holdgroup="none"; } }
if (holdgroup!='none') document.write('<style type="text/css"> .SQ'+holdgroup+' {display: block;} </sty'+'le>');
// --> </script>
|
|