Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Jan 23, 2011 21:53:49 GMT -8
This was born from a request on Proboards Support Global Header: <script>if(window['jQuery'])document.write('<xmp style="display:none">');</script> <script type="text/javascript" language="javascript" src="https://www.google.com/jsapi"></script> <script>google.load("jquery", "1.4.2");</script> <script>document.write('<xmp>');</script> </xmp> Global Footer: <script> (function(){ /* @name Tenure Based Rankings in Miniprofile */ //==start editable section== var starWeeks = [4,10,26,52,78,104,208,300,400,500,600,700,800,900,1000] //weeks since joined when one more star is added var starImages = [ //URLs to star images 'http://images.proboards.com/new/star.png',,, // bridge weeks 4 to 51 'http://images.proboards.com/new/starblue.png',, // bridge weeks 52 to 77 'http://images.proboards.com/new/stargreen.png',,, // bridge weeks 78 to 299 'http://images.proboards.com/new/starred.png' // weeks 300+ ]; $=jQuery var starCount = 0 //number>0 forces fixed amount of stars var replaceRank = true; //replace any existing post-count-based rank images //==end editable section==
$('.windowbg[width="20%"][valign][bgcolor], .windowbg2[width="20%"][valign][bgcolor]') .filter(function(){if(/Joined: ([^<]+)/.test(this.innerHTML)){$(this).data('joined',new Date($.trim(RegExp.$1).split(' ').join(' 1, ')));return true;}else return false;}) .each(function(){ var now=new Date(),mp=$(this); var a = mp.data('joined'),c,si='/v4images/new/star.png'; var b = ((now-a)/86400000/7)>>0 //weeks for (c=0;c<starWeeks.length;c++){ si= starImages[c]?starImages[c]:si if(b<=starWeeks[c]){if(c)c--;break;} } if(replaceRank) mp.find('img[alt="*"],img[alt="[image] "]').wrapAll('<span class="mpChron cronrank'+(c+1)+' cronweek'+b+'" />') if(mp.find('.mpChron').length==0) mp.find('a[class]').parent().next().replaceWith('<div class="mpChron cronrank'+(c+1)+' cronweek'+b+'" />') mp.find('.mpChron').html((new Array((starCount>0?starCount:c)+1)).join('<img border="0" alt="+" src="'+si+'" title="joined '+b+' weeks ago" \/>'))
}) })(); </script> Note that since only a month and year is given for the join date, all dates are compared as if joined on first day of month. - var starWeeks = [4,10,26,52,78,104,208,300,400,500,600,700,800,900,1000]
this defines the elapsed time (in weeks) from join date when images/stars are automatically awarded
- var starImages = [ //URLs to star images
'http://images.proboards.com/new/star.png',,, // weeks 4 to 51 'http://images.proboards.com/new/starblue.png',, // weeks 52 to 77 'http://images.proboards.com/new/stargreen.png',,, // weeks 78 to 299 'http://images.proboards.com/new/starred.png' // weeks 300+ ] this defines the images corresponding with the week values in starWeek. Image url spots that are left empty by not filling in the spot between the commas where they belong will default to the nearest populated lower value image spot
- var starCount = 0
In addition to having different images/stars displayed via the starImages array above, the number of images/star will be determined by where in the starWeeks array the members' total elapsed weeks (since registering) falls. If you instead wish to have a set number of stars/images per member regardless of how long they've been a member then set that number in starCount. A value of 0 (zero) means it will be ignored.
- var replaceRank = true;
if set to true the code will replace existing stars/images, if false it will add them as a new line.
Not recommended to run with mini-profile remodels but if testing with one then this should go above codes like that.
|
|