Post by D-Fox on Apr 6, 2007 12:16:02 GMT -8
Are you tired of an anemic looking Info Center - Users Online? Other BBs, like vB, show users "online" for hours, not a few minutes, when they aren't doing anything. This code adds a calculated subset of selected users that are offline to the Users Online in the Info Center with random dynamics. A selected user that is online will not be shown twice.
- Turn "invisible" mode off for all selected users and ask them to keep it off for maximum effect. It is up to you how you want to handle "admin."
- Edit 4/7/07: Leading comma problem in core code fix - no need to turn off Info Center for Guests.
- Add 15, 30 or more selected users in the code below, examples are shown. Try to add 15 to 20 as a minimum to start. The form in the code for each user is: ['signin name', 'display name', 'group'], -- e.g. ['shelly','Shelly','Pink'],
Leave 'group' as '' if you don't know what it is. This is a one time set up and you can always add or subtract (use //) selected users. Remove any deleted users as soon as possible since clicking on their profile will show nothing, an error.
- If you use name colors, add the following code in the Global Footer AFTER this code. Form is: ('signin name', 'color',''); -- e.g., color('shelly','FF69B4','');
support.proboards.com/index.cgi?board=codedatabase&action=display&n=1&thread=70682
- Tweak the MinAdd and Aggr parameters to your liking. For example, with MinAdd = 3 and Aggr = 0.75 with 9 actual users online, the code will add ( 3 + 0.75*9 +/- 1) = (9,10,11) offline selected users.
- This code is IE and FF compatible.
- Thanks to CrAzY_J for the basic code and Rosss for the basic users online function.
- GLOBAL FOOTER
- Note 5/23/07: The easiest way to check for conflicts is to copy the code exactly as is to the bottom of your Global Footer. The example selected users should start showing up as Users Online in the Info Center. See test site: dfoxtesting.proboards107.com/index.cgi
Edit -- modified -- MinAdd = MinAdd + Math.round( Aggr*userct );
-- to -- MinAdd = Math.round( MinAdd + Aggr*userct );
-- just in case a non-integer is entered for MinAdd -- not critical
- Turn "invisible" mode off for all selected users and ask them to keep it off for maximum effect. It is up to you how you want to handle "admin."
- Edit 4/7/07: Leading comma problem in core code fix - no need to turn off Info Center for Guests.
- Add 15, 30 or more selected users in the code below, examples are shown. Try to add 15 to 20 as a minimum to start. The form in the code for each user is: ['signin name', 'display name', 'group'], -- e.g. ['shelly','Shelly','Pink'],
Leave 'group' as '' if you don't know what it is. This is a one time set up and you can always add or subtract (use //) selected users. Remove any deleted users as soon as possible since clicking on their profile will show nothing, an error.
- If you use name colors, add the following code in the Global Footer AFTER this code. Form is: ('signin name', 'color',''); -- e.g., color('shelly','FF69B4','');
support.proboards.com/index.cgi?board=codedatabase&action=display&n=1&thread=70682
- Tweak the MinAdd and Aggr parameters to your liking. For example, with MinAdd = 3 and Aggr = 0.75 with 9 actual users online, the code will add ( 3 + 0.75*9 +/- 1) = (9,10,11) offline selected users.
- This code is IE and FF compatible.
- Thanks to CrAzY_J for the basic code and Rosss for the basic users online function.
- GLOBAL FOOTER
- Note 5/23/07: The easiest way to check for conflicts is to copy the code exactly as is to the bottom of your Global Footer. The example selected users should start showing up as Users Online in the Info Center. See test site: dfoxtesting.proboards107.com/index.cgi
<script type='text/javascript'>
/* Show a subset of selected users that are offline (random) in the Info Center
== thanks to CrAzY_J for core code
== thanks to Rosss for the core Users Online function*/
// set basic parameters
var MinAdd = 3; // minimum selected users offline to add, e.g. 3 +/- 1 (random)
var Aggr = 0.75; // aggressiveness factor, e.g. add additional 0.75*(Actual Users Online), [ 0 to x ]
// add selected users
var OnlineUsers = [
['earl','Earl','Red'],
['shelly','Shelly','Pink'],
['jjones','Janice Jones','Blue'],
['jackbrown','Jack Brown','Brown'],
['akelly','Ann Kelly','Green'] // no comma for last entry
];
// do not edit below this line
if( MinAdd < 0 ) { MinAdd = 0;}
if( Aggr < 0 ) { Aggr = 0; }
// calculate number of selected users offline to add (based on the number of actual users online)
var userct = get_users_online(1);
MinAdd = Math.round( MinAdd + Aggr*userct );
var users = get_users_online(0);
// determine indices and number of selected users offline
var ay = [];
var Len = 0;
for( var z = 0 ; z < OnlineUsers.length ; z ++ )
{
if( 0 > users.search( OnlineUsers[z][0] ))
{
ay[Len] = z;
Len = Len + 1;
}
}
// randomize indices of selected users offline
for( var z = 0 ; z < Len ; z ++ )
{
j = Math.floor(Math.random()*Len);
h = ay[z];
ay[z] = ay[j];
ay[j] = h;
}
// determine the number of selected users offline to add ( random +/- 1 )
MinAdd = MinAdd + Math.floor(Math.random()*3) -1;
if( Len < MinAdd ) { MinAdd = Len; }
if( MinAdd < 0 ) { MinAdd = 0; }
Len = MinAdd;
var TD = document.body.getElementsByTagName('td');
if( this.location.href.match(/\.com(\/(index\.cgi(#\w+|\?(action=home)?)?)?)?$/))
{
for( var t = TD.length-1 ; t > 0 ; t -- )
{
if( TD[t].vAlign == 'top' && TD[t].align == 'left' && TD[t].firstChild.firstChild && new RegExp('\\d+\\sMembers?').test(TD[t].firstChild.firstChild.data))
{
for( var z = 0 ; z < Len ; z ++ )
{
az = ay[z];
var A = document.createElement('a');
A.href = '/index.cgi?action=viewprofile&user='+OnlineUsers[az][0];
A.className = OnlineUsers[az][2];
A.appendChild( document.createTextNode( OnlineUsers[az][1] ));
if( 0 < ( userct + z ) ) {
TD[t].firstChild.appendChild( document.createTextNode(', ') );
}
TD[t].firstChild.appendChild( A );
}
var setReg = /(\d+) Member(s)?/i;
var toAdd = Len;
var cur = (TD[t].innerHTML.match(setReg)?RegExp.$1:0);
var n = toAdd+parseInt(cur);
TD[t].innerHTML = TD[t].innerHTML.replace(setReg,n+" Member"+(n==1?"":"s"));
break;
}
}
}
if( this.location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/))
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '20%' && TD[t].vAlign == 'top' && TD[t].className != 'catbg' && TD[t].getElementsByTagName('a') )
{
var Inp = TD[t].getElementsByTagName('a');
kill:
for( var z = 0 ; z < Inp.length ; z ++ )
{
for( var o = 0 ; o < Len ; o ++ )
{
az = ay[o];
if( new RegExp(OnlineUsers[az][0]).test(Inp[z].href) )
{
TD[t].innerHTML = TD[t].innerHTML.replace(/\sis\soffline/,' is <b>online</b>');
break;
break kill;
}
}
}
}
}
}
function get_users_online(zz) {
var users = "";
var userct = 0;
var td = document.getElementsByTagName('td');
if(location.href.match(/\.com\/?index.cgi\??(&?action=home)?(#\w+)?$/)) {
for(i=td.length-1; i>0; i--) {
if(td.item(i).vAlign == 'top' && td.item(i).align == 'left' && td.item(i).innerHTML.match(/\d+ Members?,/)) {
var a = td.item(i).getElementsByTagName('a');
for(n=0; n<a.length; n++) {
if(a.item(n).href.match(/user=/)) {
if(users != "") {
users += ", ";
}
users += a.item(n).href.split(/user=/)[1];
userct = userct + 1;
}
}
break;
}
}
}
if( zz < 1) { return users; }
return userct;
}
</script>
Edit -- modified -- MinAdd = MinAdd + Math.round( Aggr*userct );
-- to -- MinAdd = Math.round( MinAdd + Aggr*userct );
-- just in case a non-integer is entered for MinAdd -- not critical