|
Post by Wormopolis on Apr 19, 2011 12:14:09 GMT -8
browsers tested: IE and FF placement: main footer
lets you create fake users that show up in the info center. names look just like regular users.
<script type="text/javascript"> <!-- // ghost users v1.3 // by Wormopolis // keep header intact
var ghosts=[ ['huey','Huginald Humphrey','1'], //username, displayname, groupid ['duey','Dubistal Humphrey','2'], ['louie','Lewis Humphrey','0'], ['admin','Jason Miller','1'], ['larry','Lawrence Talbert','0'], ['curly','Rebecca Stamos','1'], ['moe','Mohinder Mercury','3'] //no comma last line ];
var staffIDs="1|2|3"; //put all ids considered staff in here seperated by |
var groupIdColors=new Array(); groupIdColors['0']='#002233'; // group 0 is regular members groupIdColors['1']='#223344'; groupIdColors['2']='#023344'; groupIdColors['3']='#0000FF'; groupIdColors['13']='#FF0000';
var persistantGhosts=true; // set true if you want ghosts to last 24 hours var percentageOfGhostsPersistant=50; //in percentage
// no need to edit below
if (pb_action=='home') { staffAccum=0; memAccum=0; var ghostArrayFix=new Array(); var ghostArrayFix2=new Array(); if (true && document.cookie.match(/ghosties=(.*?)(;|$)/)) { var ckghosts=RegExp.$1.split('.'); for (g=0; g<ckghosts.length; g++) { ckg=parseInt(ckghosts[g]); ghostArrayFix2[g]='<a class="group'+ghosts[ckg][2]+'" href="/index.cgi?action=viewprofile&user='+ghosts[ckg][0]+'"><font '+(groupIdColors[ghosts[ckg][2]] ? 'color="' + groupIdColors[ghosts[ckg][2]] + '" ' : '')+'>'+ghosts[ckg][1]+'</font></a>'; } } else { for (g=0; g<ghosts.length; g++) { ghostArrayFix[g]=new Array(); ghostArrayFix[g][0]=g; ghostArrayFix[g][1]='<a class="group'+ghosts[g][2]+'" href="/index.cgi?action=viewprofile&user='+ghosts[g][0]+'"><font '+(groupIdColors[ghosts[g][2]] ? 'color="' + groupIdColors[ghosts[g][2]] + '" ' : '')+'>'+ghosts[g][1]+'</font></a>'; ghostArrayFix2[g]='<a class="group'+ghosts[g][2]+'" href="/index.cgi?action=viewprofile&user='+ghosts[g][0]+'"><font '+(groupIdColors[ghosts[g][2]] ? 'color="' + groupIdColors[ghosts[g][2]] + '" ' : '')+'>'+ghosts[g][1]+'</font></a>'; } if (persistantGhosts) { var numKeep=ghosts.length - parseInt((percentageOfGhostsPersistant/100.0)*ghosts.length); for (gg=0; gg<numKeep; gg++) { var vgnum=parseInt(Math.random()*ghostArrayFix.length); ghostArrayFix.splice(vgnum,1); ghostArrayFix2.splice(vgnum,1); } var tmpit=''; for (gg2=0; gg2<ghostArrayFix.length; gg2++) { tmpit+=ghostArrayFix[gg2][0]+(gg2<ghostArrayFix.length-1 ? '.' : ''); } var expTime=new Date(); expTime.setDate(expTime.getDate+1); document.cookie='ghosties='+tmpit+'; expires='+expTime; } } function userSort(a, b) { a_name=(a.match(/user=(.*?)"/) ? RegExp.$1 : ''); b_name=(b.match(/user=(.*?)"/) ? RegExp.$1 : ''); return b_name<a_name; } for (tds=document.getElementsByTagName('td'), m=tds.length-1; m>0; m--) { if (tds[m].colSpan==2 && tds[m].className=="catbg" && tds[m].innerHTML.match(/Active Users/)) { listSpot=tds[m].parentNode.nextSibling.firstChild.nextSibling.getElementsByTagName('font')[0]; AUstuff=listSpot.innerHTML.split(/<br>/i); actualUsers=AUstuff[1].split(/\,\s/);
// look for dupes for (aU=0; aU<actualUsers.length; aU++) { for (gU=0; gU<ghostArrayFix2.length; gU++) { tmp1=(actualUsers[aU].match(/user=(.*?)"/) ? RegExp.$1 : ''); tmp2=(ghostArrayFix2[gU].match(/user=(.*?)"/) ? RegExp.$1 : ''); if (tmp1 && tmp2 && tmp1==tmp2) { ghostArrayFix2.splice(gU,1); break; } } } putEmBoth=actualUsers.concat(ghostArrayFix2); putEmBoth.sort(userSort);
// get new totals checkit=new RegExp('class="?group('+staffIDs+')"?(>|\\s)','i'); for (T=0; T<putEmBoth.length; T++) { if (putEmBoth[T].match(checkit)) staffAccum++; else memAccum++; } AUstuff[1]=putEmBoth.join(', '); if (AUstuff[0].match(/(\d+) Staff Member(s?)/)) { AUstuff[0]=AUstuff[0].replace(/(\d+) Staff Member(s?)/,staffAccum+ " Staff Member"+(staffAccum==1? '' : 's')) } if (AUstuff[0].match(/(\d+) Member(s?)/)) { AUstuff[0]=AUstuff[0].replace(/(\d+) Member(s?)/,memAccum+ " Member"+(memAccum==1? '' : 's')) } listSpot.innerHTML=AUstuff.join('<br>');
break; } } } //--> </script>
|
|
|
Post by Wormopolis on Apr 19, 2011 14:26:27 GMT -8
version upgrade 1.1: added in group colors.
|
|
|
Post by Wormopolis on Jul 20, 2011 21:40:17 GMT -8
version upgrade 1.3: added in persistance of ghosts (they last 24 hours), added in subset percentage
code now uses a cookie to store ghosts if you want them to last 24 hours.
|
|
gardenguru
Not New Member
Posts: 3
gardenguru said 0 great things
|
Post by gardenguru on Dec 29, 2011 10:48:37 GMT -8
I hope I'm asking this in the right area, if not please move it! I'm using this code and am having 2 problems: 1- it's putting all the members fake or other-wise into alphabetical order, I like them all jumbled up! 2- It's not listing all my staff members right, as far as staff member count! It may be something I'm not filling in right, so any help with this would be great... oops... forgot the link... notjusttomatoes.proboards.com
|
|
|
Post by Wormopolis on Dec 29, 2011 15:40:36 GMT -8
correct area!
this line:
putEmBoth.sort(userSort);
is what sorts by name. it was part of the original request to do that, so if you dont want them sorted, just remove that line.
as for staff members, in your array you list every ghost as being part of group 0, which is a normal user. if you want one of those ghosts to be in a staff group, you have to put the id of that member group there instead of 0. there is also this line:
var staffIDs="1|2|3"; //put all ids considered staff in here seperated by |
you have to list which of your membergroups are considered staff in there. currently only groups 1,2 and 3 are staff according to that.
|
|
gardenguru
Not New Member
Posts: 3
gardenguru said 0 great things
|
Post by gardenguru on Dec 29, 2011 16:06:03 GMT -8
Thanks for the help Wormy, got the first one taken care of but the 2nd one cornfusses me!! None of my staff are listed in there, but if you have time to look again, look at the staff member count in the "Active Users" area! As I am posting here there are 7 staff members in there, but the count only says 5?
|
|
|
Post by Wormopolis on Dec 29, 2011 16:16:28 GMT -8
it recalculates the 2 numbers based on total names. that variable says ONLY groups 1 2 and 3 are considered staff. in that list of names, only 5 names are in those groups. you have a member stratcat that is in group 4, so if you want them to be considered staff (for this code purposes), you have to add a 4 into that variable
|
|
gardenguru
Not New Member
Posts: 3
gardenguru said 0 great things
|
Post by gardenguru on Dec 29, 2011 16:19:45 GMT -8
Ahhh... Thanks again, I was just thinking that I should have done that before posting the 2nd question again... Thank you for all your help!!!
|
|
|
Post by Wormopolis on Dec 29, 2011 16:40:46 GMT -8
there ya go! now yer site is haunted.
|
|
|
Post by tunescool on Jan 7, 2012 17:14:51 GMT -8
wormer when should members start showing up in the IC. ive had them registered for days but had the ID wrong and just changed it. will it work if i use the MYOIC
var ghosts=[ ['tites','tites','0'], //username, displayname, groupid ['mintass','mintass','0'] //no comma last line ];
var staffIDs="1|2|3"; //put all ids considered staff in here seperated by |
var groupIdColors=new Array(); groupIdColors['0']='#00138E'; // group 0 is regular members groupIdColors['1']='#223344'; groupIdColors['2']='#023344'; groupIdColors['3']='#0000FF'; groupIdColors['4']='#FF0000';
var persistantGhosts=true; // set true if you want ghosts to last 24 hours var percentageOfGhostsPersistant=100; //in percentage
|
|
|
Post by Wormopolis on Jan 8, 2012 2:56:20 GMT -8
would have to run before the IC remodel
|
|
|
Post by tunescool on Jan 8, 2012 4:05:54 GMT -8
i moved it and only one showed up, 100%, wouldnt all of them show
|
|
|
Post by tunescool on Jan 8, 2012 5:00:58 GMT -8
theyre both showing up, its alrite
|
|
endo
Not New Member
Posts: 18
endo said 0 great things
|
Post by endo on Sept 12, 2012 20:08:48 GMT -8
Hey Wormo, using your Ghost Users code and it works great, but is there a way to hide the "Ghosts" info? Right now anyone can click on a "Ghost" and see that they never made a post or logged in for over a year.
Is it something in the forum settings and I'm missing it, or something I need to do in the code? Thanks,
endo
|
|
|
Post by Wormopolis on Sept 12, 2012 20:19:57 GMT -8
well the original point of the code was to make it appear like the ghosts were normal users and clicking their names did what clicking a regular member's name would do - go to their profile. I can change it so clicking their name doesnt go to a profile, but it will seem kinda obvious something is wrong when their name is no longer clickable. you still want it?
|
|