Post by snap2000 on Jul 31, 2005 13:43:47 GMT -8
This code adds a box to your info center dedicated to online staff members. This is similar to that seen in SSD's info center, but customizable! See below for more information.
Location: Main Footer
To customize:
1) The icon. If you wish to change the icon in the info center, simply change the underlined url in the code to that of the icon you want to use.
2) The groups. By default, you have 3 staff member groups: Administrator, Global Moderator, and Moderator. These are given the unique ids 1, 2, and 3, respectively. In the blue part above, you may see how this implemented into the code. Below are examples of ways to customize these Groups:
Binding Groups:
I have also included a feature that allows you to bind multiple groups together. For example, if you have multiple moderator groups (perhaps for different subjects, like coding and graphics), then you can combine them to be displayed as just "Moderators" for example.
To accomplish this, add any number of ids into the group id field, seperated by "|"s. For example, 3 moderator groups bound into one might look like this:
The ids don't need to be in any particular order.
Obtaining Group Ids:
Finding a group id may be tough for someone not familiar with HTML. However, I will try to make it as clear as possible:
1) First, go to the profile of a member assigned to your group.
2) Click View in your browser toolbar, and select "Page Source" or similar.
3) Do a search (Ctrl + F) for the username of the member on that page until you reach a line similar to this:
4) Copy the number where bold # is. This is the group id.
If this does not help, feel free to PM me.
Other Notes:
This code automatically adds an "s" to the end of group names if more or less than one are online (i.e. 3 Administrators). Therefore you do not need to include the s in your names, however this does not support special changes (i.e. fly -> flies).
Bug Fixes
8/5/05 - Now works with images disabled
8/1/05 - Fixed small CSS-related problem
06/02/2008 - Upgraded to work with ProBoards v4.5 - Ross
Location: Main Footer
<script type="text/javascript"><!--
/* Staff Online by snap2000 */
var staffIcon = "s1.images.proboards.com/online.gif"; //icon to use in Info Center
var staffGroups=[
["Administrator", "1"],
["Global Moderator", "2"],
["Moderator", "3"]
];
var row=document.getElementsByTagName("tr");
if(!location.href.match(/\?action\=(?!home)/)) {
for(r=0;r<row.length;r++) {
if(row[r].firstChild.className=="catbg" && row[r].firstChild.innerHTML.match("Users Online")) {
var staffList=[],staffCount=[];
for(g=0;g<staffGroups.length;g++) staffCount[g]=0;
var newCat=row[r].cloneNode(true);
newCat.firstChild.getElementsByTagName("b")[0].innerHTML="Staff Online";
var newWin=row[r+2].cloneNode(true);
var onlineCell=row[r+2].lastChild.getElementsByTagName("font")[0];
var staffCell=newWin.lastChild.getElementsByTagName("font")[0];
newWin.firstChild.innerHTML=(newWin.firstChild.firstChild.nodeName=="IMG") ? '<img src="'+staffIcon+'" border="0" alt="s" />' : 's';
onlineCell.innerHTML=onlineCell.innerHTML.replace(/\d+ Staff Members*,\s/,"");
var links=onlineCell.getElementsByTagName("a");
for(a=0;a<links.length;a++) {
if(links.className && links.className.match(/^group(\d+)$/)) {
reg=eval("\/\\b"+RegExp.$1+"\\b\/");
for(g=0;g<staffGroups.length;g++) {
if(staffGroups[g][1].match(reg)) {
staffCount[g]++;
staffList.push(links);
if(a<links.length-1) links.nextSibling.parentNode.removeChild(links.nextSibling);
break;
}
}
}
}
staffCell.innerHTML="";
for(g=0;g<staffGroups.length;g++) {
staffCell.innerHTML+=staffCount[g]+' '+staffGroups[g][0]+(staffCount[g]!=1?'s':'');
staffCell.innerHTML+=(g+1<staffGroups.length ? ', ' : '<br />');
}
for(a=0;a<staffList.length;a++) {
staffCell.appendChild(staffList);
if(a<staffList.length-1) staffCell.innerHTML+=", ";
}
if(onlineCell.lastChild.nodeType==3) onlineCell.lastChild.parentNode.removeChild(onlineCell.lastChild);
row[r].parentNode.insertBefore(newWin,row[r]);
row[r].parentNode.insertBefore(newCat,row[r]);
break;
}
}
}
//--></script>
/* Staff Online by snap2000 */
var staffIcon = "s1.images.proboards.com/online.gif"; //icon to use in Info Center
var staffGroups=[
["Administrator", "1"],
["Global Moderator", "2"],
["Moderator", "3"]
];
var row=document.getElementsByTagName("tr");
if(!location.href.match(/\?action\=(?!home)/)) {
for(r=0;r<row.length;r++) {
if(row[r].firstChild.className=="catbg" && row[r].firstChild.innerHTML.match("Users Online")) {
var staffList=[],staffCount=[];
for(g=0;g<staffGroups.length;g++) staffCount[g]=0;
var newCat=row[r].cloneNode(true);
newCat.firstChild.getElementsByTagName("b")[0].innerHTML="Staff Online";
var newWin=row[r+2].cloneNode(true);
var onlineCell=row[r+2].lastChild.getElementsByTagName("font")[0];
var staffCell=newWin.lastChild.getElementsByTagName("font")[0];
newWin.firstChild.innerHTML=(newWin.firstChild.firstChild.nodeName=="IMG") ? '<img src="'+staffIcon+'" border="0" alt="s" />' : 's';
onlineCell.innerHTML=onlineCell.innerHTML.replace(/\d+ Staff Members*,\s/,"");
var links=onlineCell.getElementsByTagName("a");
for(a=0;a<links.length;a++) {
if(links.className && links.className.match(/^group(\d+)$/)) {
reg=eval("\/\\b"+RegExp.$1+"\\b\/");
for(g=0;g<staffGroups.length;g++) {
if(staffGroups[g][1].match(reg)) {
staffCount[g]++;
staffList.push(links);
if(a<links.length-1) links.nextSibling.parentNode.removeChild(links.nextSibling);
break;
}
}
}
}
staffCell.innerHTML="";
for(g=0;g<staffGroups.length;g++) {
staffCell.innerHTML+=staffCount[g]+' '+staffGroups[g][0]+(staffCount[g]!=1?'s':'');
staffCell.innerHTML+=(g+1<staffGroups.length ? ', ' : '<br />');
}
for(a=0;a<staffList.length;a++) {
staffCell.appendChild(staffList);
if(a<staffList.length-1) staffCell.innerHTML+=", ";
}
if(onlineCell.lastChild.nodeType==3) onlineCell.lastChild.parentNode.removeChild(onlineCell.lastChild);
row[r].parentNode.insertBefore(newWin,row[r]);
row[r].parentNode.insertBefore(newCat,row[r]);
break;
}
}
}
//--></script>
To customize:
1) The icon. If you wish to change the icon in the info center, simply change the underlined url in the code to that of the icon you want to use.
2) The groups. By default, you have 3 staff member groups: Administrator, Global Moderator, and Moderator. These are given the unique ids 1, 2, and 3, respectively. In the blue part above, you may see how this implemented into the code. Below are examples of ways to customize these Groups:
To add a group, add a new line as shown to the right. Make sure to add a comma to the end of the previous line. Also, make sure that the group id is correct. Information on finding this id is below. | ["Administrator", "1"], ["Global Moderator", "2"], ["Moderator", "3"], ["New Group", "4"] |
To change a group's name, simply change the name in the array, as shown. | ["Administrator", "1"], ["Global Moderator", "2"], ["Moderator", "3"], ["Cool Group Name", "4"] |
To delete a group, remove it's line from the array. Make sure there is no trailing comma on the last line. | ["Administrator", "1"], ["Global Moderator", "2"], ["Moderator", "3"], |
Binding Groups:
I have also included a feature that allows you to bind multiple groups together. For example, if you have multiple moderator groups (perhaps for different subjects, like coding and graphics), then you can combine them to be displayed as just "Moderators" for example.
To accomplish this, add any number of ids into the group id field, seperated by "|"s. For example, 3 moderator groups bound into one might look like this:
["Moderator", "3|6|4"]
The ids don't need to be in any particular order.
Obtaining Group Ids:
Finding a group id may be tough for someone not familiar with HTML. However, I will try to make it as clear as possible:
1) First, go to the profile of a member assigned to your group.
2) Click View in your browser toolbar, and select "Page Source" or similar.
3) Do a search (Ctrl + F) for the username of the member on that page until you reach a line similar to this:
<a href="/index.cgi?action=viewprofile&user=username" class="group#">
4) Copy the number where bold # is. This is the group id.
If this does not help, feel free to PM me.
Other Notes:
This code automatically adds an "s" to the end of group names if more or less than one are online (i.e. 3 Administrators). Therefore you do not need to include the s in your names, however this does not support special changes (i.e. fly -> flies).
Bug Fixes
8/5/05 - Now works with images disabled
8/1/05 - Fixed small CSS-related problem
06/02/2008 - Upgraded to work with ProBoards v4.5 - Ross