Post by Ross on Oct 9, 2005 22:31:18 GMT
Main Footer
This is something I did as a request. It's an info center rewrite with extra stats etc. It should work fine in Internet Explorer and FireFox
Edit any of the stuff in color and follow the comments for each bit.
Preview: Click Here
<style type="text/css">
<!--
.hr2
{
// Horizontal and Vertical Divider settings
border-bottom-color: #000000;
border-bottom-style: dashed;
border-botom-width: 1pt;
border-right-color: #000000;
border-right-style: dashed;
border-right-width: 1pt;
}
.info .catbg
{
// 'Users Online' and 'Forum Information' bar height
height: 20px;
}
.info .titlebg
{
// 'Info Center' bar height
height: 18px;
}
-->
</style>
<script type="text/javascript">
<!--
/*
Info Center 101 - v1.5
created by Ross, Copyright - 2005
this code may only be posted at
101support.proboards43.com
or
support.proboards.com
do not edit or redistribute without permission
keep this header intact at all times
*/
//These are the URLs to the Head and Base Images. Leave blank for no image
var grads = ["Head Image URL","Base Image URL"];
// Class of the box. Normally either windowbg or windowbg2
var iClass = "windowbg";
// Name of the Info Center
var iTitle = "Info Center";
//Edit the names of the staff groups and their corresponding group number. Repeat the pattern for more groups.
// For example, the next line might be: theStaff[3]=["Board Owner","7"]
var theStaff = [];
theStaff[0]=["Moderators","(3|4)"]
theStaff[1]=["Global Moderators","2"]
theStaff[2]=["Administrators","1"]
// Do not edit below this line
td = document.getElementsByTagName('td');
div = document.createElement('div');
updated = 0;
boards = 0;
categories = 0;
for (i=0; i<td.length; i++)
{
if(td.width == '66%' && td.className == 'windowbg2')
{
boards++
if(td[i-1].innerHTML.match(/\[\*\]/))
{
updated++
}
}
else if(td.className=='catbg' && td.innerHTML.match(/a name/i))
{
categories++
}
else if(td.parentNode.parentNode.parentNode.className == 'bordercolor' && td.parentNode.parentNode.parentNode.width == '100%' && td.innerHTML.match(/>Info Center</))
{
iCell = td.getElementsByTagName('td');
posts = td.innerHTML.match(/Total Posts: (.+?)</)? RegExp.$1 : '';
threads = td.innerHTML.match(/Total Topics: (.+?) &nb/)? RegExp.$1 : '';
post_per_topic = '<tr><td width=80% align=right>Average Posts per Topic:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(posts.replace(/,/g,'')) / parseInt(threads.replace(/,/g,''))) +'</td></tr>';
topic_per_board = '<tr><td width=70% align=right>Average Topics per Board:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(threads.replace(/,/g,'')) / boards) +'</td></tr>';
post_per_board = '<tr><td width=70% align=right>Average Replies per Board:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(posts.replace(/,/g,'')) / boards) +'</td></tr>';
boards = (boards>0)? 'Total Boards: <b>'+ boards+'</b>' : '';
categories = (categories>0)? 'Total Categories: <b>'+ categories +'</b>' : '';
usersOnline = iCell[iCell.length - 1].innerHTML;
recent = iCell[3].innerHTML.split('Last Updated Topic: ')[1].split(' by ')[0];
lastPost = iCell[3].innerHTML.split(' by ')[1].split(/<br>/i)[0].replace(' (',', ').replace(')','');
registered = (iCell[3].innerHTML.match(/Total Members: <(.+?)>(.+?)</))? RegExp.$2 : '';
newest = (iCell[3].innerHTML.match(/Newest Member: (.+?)<\//))? RegExp.$1 +'</a>' : '';
membersOnline = (usersOnline.match(/(\d+) Member/))? RegExp.$1+' Members' : '';
guestOnline = (usersOnline.match(/(\d+) Guest/))? RegExp.$1 +' Guests' : '';
guestOnline = (usersOnline.match(/viewguests/))? '<a href=javascript:popWindow(\'viewguests\')>'+guestOnline+'</a>' : guestOnline;
updated = (updated == 0)? 'No boards' : (updated == 1)? '1 board' : updated+' boards';
updated = '<a href=/index.cgi?&action=recent>'+ updated +'</a> have been updated recently';
if(td.innerHTML.match(/Today\'s Birthdays/)) {
birthdays = iCell[9].innerHTML;
iMembers = iCell[9].getElementsByTagName('a');
if(iMembers.length > 1) {
birthdays = birthdays.replace(new RegExp(iMembers[iMembers.length -2].innerHTML+'</a>,','i'),iMembers[iMembers.length -2].innerHTML+'<a> and');
}
plural1 = (iMembers.length > 2)? 'are' : 'is';
plural2 = (iMembers.length > 2)? 's' : '';
}
birthdays = (td.innerHTML.match(/Today\'s Birthdays/))? '<br/>'+ birthdays + ' ' + plural1+' celebrating their birthday'+plural2+' today.' : '';
events = (td.innerHTML.match(/Events This Month/))? '<br/>Upcoming Events: '+ iCell[iCell.length - 5].innerHTML : '';
var date = new Date(); var month = date.getMonth(); var day = date.getDay(); var daym = date.getDate(); var year = date.getYear(); if(year < 1900){ year += 1900 }
var montharray=["January","February","March","April","May","June","July","August","September","October","November","December"];
var dayarray=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
if(daym == (1|21|31)){ext = 'st'} else if(daym == (2|22)){ext = 'nd'} else if(daym == (3|23)){ext = 'rd'} else{ext = 'th'}
var hours = date.getHours(); if (hours >= 12) { hours = hours-12 }
var mins = date.getMinutes(); if (mins < 10) {mins = "0" + mins;}
iDate = dayarray[day] +' the '+ daym + ext + ' of ' + montharray[month]+', '+year;
iTime = hours+':'+mins;
iHolder = '<table class="info" width=100% cellpadding=0 cellspacing=0 border=0 align=center><tr>';
iHolder += '<td><table class=bordercolor width=100% cellspacing=1 celpadding=2><tr>';
iHolder += '<td width=100% class=titlebg align=center style="background-image: url('+grads[0]+');"><B>'+iTitle+'</B></td>';
iHolder += '</tr><tr><td class=catbg>Forum Statistics</td></tr><tr><td class='+iClass+'>';
iHolder += '<table align=center width=95%><tr><td align=center>';
iHolder += '&nb'+'sp; Total Posts: <b>'+ posts +'</b>&nb'+'sp; &nb'+'sp; &nb'+'sp; Total Topics: <b>'+ threads +'</b>&nb'+'sp; &nb'+'sp; &nb'+'sp;'+ boards +'&nb'+'sp; &nb'+'sp; &nb'+'sp;'+ categories +'&nb'+'sp;';
iHolder += '<hr class=hr2></td></tr><tr><td width=100%><table width=100%><tr><td width=60%>The most recently updated topic is \''+ recent +'\'<br/>';
iHolder+= 'The last forum post was made by '+ lastPost +'<br/>It is currently '+ iTime +', on '+iDate;
iHolder += '</td><td><table width=95% align=center>'+ post_per_topic + topic_per_board + post_per_board +'</table></td>';
iHolder += '</tr></table><hr class=hr2><table width=100%><tr><td width=72% class=hr2 style="border-bottom-style: none;">';
iHolder += 'There are currently <a href=/index.cgi?action=members>'+registered+' registered members</a> on '+document.title.split(/ -/)[0]+'.<br/>We would like to welcome '+newest+' as the most recent member to the forums.'+birthdays+events;
iHolder += '</td><td width=28% valign=top><table width=95% align=center valign=top><tr><td>'+ updated +'</td></tr></table></td></tr></table></td></tr></table></td></tr>';
iHolder += '<tr><td class=catbg>Users Online</td></tr><tr><td class='+iClass+' valign=top width=100%>';
iHolder += '<table align=center width=95%><tr><td width=21% valign=top class=hr2 style="border-bottom-style: none;">'+guestOnline +'<br/>'+ membersOnline;
iMembers = iCell[iCell.length -1].getElementsByTagName('a');
o = 0;
for(s=0; s<theStaff.length; s++)
{
for(g=0; g<iMembers.length; g++)
{
if(iMembers[g].className && iMembers[g].className.match(new RegExp('group'+theStaff[1])))
{
o++
}
}
iHolder += '<br/>'+ o +' '+ theStaff[0];
o = 0;
}
totOnline = (usersOnline.match(/(\d+) Guest/))? parseInt(RegExp.$1) : 0;
totOnline += iMembers.length;
usersOnline = 'There are currently '+totOnline+' users online. Most u'+ usersOnline.split(/Most u/)[1].replace(/<br>/i,'<br/><hr class=hr2>').replace(/(\d+) Invisible Users. /,'');
iHolder += '</td><td valign=top>'+ usersOnline;
base = (grads[1].match(/http:/))? '<center><img src='+grads[1]+' /></center>' : '';
iHolder += '</td></tr></table></td></tr></table>'+base+'</td></tr></table>';
div.innerHTML = iHolder;
td.parentNode.parentNode.parentNode.parentNode.replaceChild(div, td.parentNode.parentNode.parentNode);
break;
}
}
//-->
</script>
This is something I did as a request. It's an info center rewrite with extra stats etc. It should work fine in Internet Explorer and FireFox
Edit any of the stuff in color and follow the comments for each bit.
Preview: Click Here
<style type="text/css">
<!--
.hr2
{
// Horizontal and Vertical Divider settings
border-bottom-color: #000000;
border-bottom-style: dashed;
border-botom-width: 1pt;
border-right-color: #000000;
border-right-style: dashed;
border-right-width: 1pt;
}
.info .catbg
{
// 'Users Online' and 'Forum Information' bar height
height: 20px;
}
.info .titlebg
{
// 'Info Center' bar height
height: 18px;
}
-->
</style>
<script type="text/javascript">
<!--
/*
Info Center 101 - v1.5
created by Ross, Copyright - 2005
this code may only be posted at
101support.proboards43.com
or
support.proboards.com
do not edit or redistribute without permission
keep this header intact at all times
*/
//These are the URLs to the Head and Base Images. Leave blank for no image
var grads = ["Head Image URL","Base Image URL"];
// Class of the box. Normally either windowbg or windowbg2
var iClass = "windowbg";
// Name of the Info Center
var iTitle = "Info Center";
//Edit the names of the staff groups and their corresponding group number. Repeat the pattern for more groups.
// For example, the next line might be: theStaff[3]=["Board Owner","7"]
var theStaff = [];
theStaff[0]=["Moderators","(3|4)"]
theStaff[1]=["Global Moderators","2"]
theStaff[2]=["Administrators","1"]
// Do not edit below this line
td = document.getElementsByTagName('td');
div = document.createElement('div');
updated = 0;
boards = 0;
categories = 0;
for (i=0; i<td.length; i++)
{
if(td.width == '66%' && td.className == 'windowbg2')
{
boards++
if(td[i-1].innerHTML.match(/\[\*\]/))
{
updated++
}
}
else if(td.className=='catbg' && td.innerHTML.match(/a name/i))
{
categories++
}
else if(td.parentNode.parentNode.parentNode.className == 'bordercolor' && td.parentNode.parentNode.parentNode.width == '100%' && td.innerHTML.match(/>Info Center</))
{
iCell = td.getElementsByTagName('td');
posts = td.innerHTML.match(/Total Posts: (.+?)</)? RegExp.$1 : '';
threads = td.innerHTML.match(/Total Topics: (.+?) &nb/)? RegExp.$1 : '';
post_per_topic = '<tr><td width=80% align=right>Average Posts per Topic:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(posts.replace(/,/g,'')) / parseInt(threads.replace(/,/g,''))) +'</td></tr>';
topic_per_board = '<tr><td width=70% align=right>Average Topics per Board:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(threads.replace(/,/g,'')) / boards) +'</td></tr>';
post_per_board = '<tr><td width=70% align=right>Average Replies per Board:</td><td width=10%></td><td width=21% align=right>'+ Math.round(parseInt(posts.replace(/,/g,'')) / boards) +'</td></tr>';
boards = (boards>0)? 'Total Boards: <b>'+ boards+'</b>' : '';
categories = (categories>0)? 'Total Categories: <b>'+ categories +'</b>' : '';
usersOnline = iCell[iCell.length - 1].innerHTML;
recent = iCell[3].innerHTML.split('Last Updated Topic: ')[1].split(' by ')[0];
lastPost = iCell[3].innerHTML.split(' by ')[1].split(/<br>/i)[0].replace(' (',', ').replace(')','');
registered = (iCell[3].innerHTML.match(/Total Members: <(.+?)>(.+?)</))? RegExp.$2 : '';
newest = (iCell[3].innerHTML.match(/Newest Member: (.+?)<\//))? RegExp.$1 +'</a>' : '';
membersOnline = (usersOnline.match(/(\d+) Member/))? RegExp.$1+' Members' : '';
guestOnline = (usersOnline.match(/(\d+) Guest/))? RegExp.$1 +' Guests' : '';
guestOnline = (usersOnline.match(/viewguests/))? '<a href=javascript:popWindow(\'viewguests\')>'+guestOnline+'</a>' : guestOnline;
updated = (updated == 0)? 'No boards' : (updated == 1)? '1 board' : updated+' boards';
updated = '<a href=/index.cgi?&action=recent>'+ updated +'</a> have been updated recently';
if(td.innerHTML.match(/Today\'s Birthdays/)) {
birthdays = iCell[9].innerHTML;
iMembers = iCell[9].getElementsByTagName('a');
if(iMembers.length > 1) {
birthdays = birthdays.replace(new RegExp(iMembers[iMembers.length -2].innerHTML+'</a>,','i'),iMembers[iMembers.length -2].innerHTML+'<a> and');
}
plural1 = (iMembers.length > 2)? 'are' : 'is';
plural2 = (iMembers.length > 2)? 's' : '';
}
birthdays = (td.innerHTML.match(/Today\'s Birthdays/))? '<br/>'+ birthdays + ' ' + plural1+' celebrating their birthday'+plural2+' today.' : '';
events = (td.innerHTML.match(/Events This Month/))? '<br/>Upcoming Events: '+ iCell[iCell.length - 5].innerHTML : '';
var date = new Date(); var month = date.getMonth(); var day = date.getDay(); var daym = date.getDate(); var year = date.getYear(); if(year < 1900){ year += 1900 }
var montharray=["January","February","March","April","May","June","July","August","September","October","November","December"];
var dayarray=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
if(daym == (1|21|31)){ext = 'st'} else if(daym == (2|22)){ext = 'nd'} else if(daym == (3|23)){ext = 'rd'} else{ext = 'th'}
var hours = date.getHours(); if (hours >= 12) { hours = hours-12 }
var mins = date.getMinutes(); if (mins < 10) {mins = "0" + mins;}
iDate = dayarray[day] +' the '+ daym + ext + ' of ' + montharray[month]+', '+year;
iTime = hours+':'+mins;
iHolder = '<table class="info" width=100% cellpadding=0 cellspacing=0 border=0 align=center><tr>';
iHolder += '<td><table class=bordercolor width=100% cellspacing=1 celpadding=2><tr>';
iHolder += '<td width=100% class=titlebg align=center style="background-image: url('+grads[0]+');"><B>'+iTitle+'</B></td>';
iHolder += '</tr><tr><td class=catbg>Forum Statistics</td></tr><tr><td class='+iClass+'>';
iHolder += '<table align=center width=95%><tr><td align=center>';
iHolder += '&nb'+'sp; Total Posts: <b>'+ posts +'</b>&nb'+'sp; &nb'+'sp; &nb'+'sp; Total Topics: <b>'+ threads +'</b>&nb'+'sp; &nb'+'sp; &nb'+'sp;'+ boards +'&nb'+'sp; &nb'+'sp; &nb'+'sp;'+ categories +'&nb'+'sp;';
iHolder += '<hr class=hr2></td></tr><tr><td width=100%><table width=100%><tr><td width=60%>The most recently updated topic is \''+ recent +'\'<br/>';
iHolder+= 'The last forum post was made by '+ lastPost +'<br/>It is currently '+ iTime +', on '+iDate;
iHolder += '</td><td><table width=95% align=center>'+ post_per_topic + topic_per_board + post_per_board +'</table></td>';
iHolder += '</tr></table><hr class=hr2><table width=100%><tr><td width=72% class=hr2 style="border-bottom-style: none;">';
iHolder += 'There are currently <a href=/index.cgi?action=members>'+registered+' registered members</a> on '+document.title.split(/ -/)[0]+'.<br/>We would like to welcome '+newest+' as the most recent member to the forums.'+birthdays+events;
iHolder += '</td><td width=28% valign=top><table width=95% align=center valign=top><tr><td>'+ updated +'</td></tr></table></td></tr></table></td></tr></table></td></tr>';
iHolder += '<tr><td class=catbg>Users Online</td></tr><tr><td class='+iClass+' valign=top width=100%>';
iHolder += '<table align=center width=95%><tr><td width=21% valign=top class=hr2 style="border-bottom-style: none;">'+guestOnline +'<br/>'+ membersOnline;
iMembers = iCell[iCell.length -1].getElementsByTagName('a');
o = 0;
for(s=0; s<theStaff.length; s++)
{
for(g=0; g<iMembers.length; g++)
{
if(iMembers[g].className && iMembers[g].className.match(new RegExp('group'+theStaff
{
o++
}
}
iHolder += '<br/>'+ o +' '+ theStaff
o = 0;
}
totOnline = (usersOnline.match(/(\d+) Guest/))? parseInt(RegExp.$1) : 0;
totOnline += iMembers.length;
usersOnline = 'There are currently '+totOnline+' users online. Most u'+ usersOnline.split(/Most u/)[1].replace(/<br>/i,'<br/><hr class=hr2>').replace(/(\d+) Invisible Users. /,'');
iHolder += '</td><td valign=top>'+ usersOnline;
base = (grads[1].match(/http:/))? '<center><img src='+grads[1]+' /></center>' : '';
iHolder += '</td></tr></table></td></tr></table>'+base+'</td></tr></table>';
div.innerHTML = iHolder;
td.parentNode.parentNode.parentNode.parentNode.replaceChild(div, td.parentNode.parentNode.parentNode);
break;
}
}
//-->
</script>