Post by iAlex on Apr 6, 2008 18:18:51 GMT -5
This code will create an extra avatar in each user's mini profile which will change depending on that user's post count.
Edit the red text with the required post count and the image that will be used when that post count is reached.
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Extra Avatars based on Post Count - Open Source*/
var iPostAva=[
[0, "Image URL"],
[50, "Image URL"],
[100, "Image URL"],
[200, "Image URL],
[500, "Image URL"] //No comma on last line
];
if(location.href.match(/action=(display|(user)?recent|viewprofile|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
var i=iTd.length;
while(--i){
if(iTd.item(i).width=="20%" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).vAlign=="top" && iTd.item(i).innerHTML.match(/Posts:\s(.+?)<br\s?\/?>/i)){
var iPost=RegExp.$1.replace(/,/g, '');
var iCentre=iTd.item(i).getElementsByTagName('center');
iPostAva.sort(iSort);
for(var a=iPostAva.length-1;a>=0;a--){
if(iPost>=iPostAva[0]){
var iImage=document.createElement('span');
(iCentre.item(iCentre.length-1).innerHTML.match(/\[avatar\]/))? iImage.innerHTML='<b'+'r /><b'+'r />' : '';
iImage.innerHTML+='<img src="'+iPostAva[1]+'" alt="[post avatar]" title="[post avatar]" />';
(iCentre.item(iCentre.length-1).innerHTML.match(/\[avatar\]/))? iCentre.item(iCentre.length-1).insertBefore(iImage, iCentre.item(iCentre.length-1).getElementsByTagName('img').item(0).nextSibling) : iCentre.item(iCentre.length-1).insertBefore(iImage, iCentre.item(iCentre.length-1).firstChild);
break;
}
}
}
}
}
function iSort(a, b){
return parseInt(b) - parseInt(a);
}
//-->
</script>
You can add as many lines as you want, just ensure that there is no comma on the last line.
Edit the red text with the required post count and the image that will be used when that post count is reached.
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Extra Avatars based on Post Count - Open Source*/
var iPostAva=[
[0, "Image URL"],
[50, "Image URL"],
[100, "Image URL"],
[200, "Image URL],
[500, "Image URL"] //No comma on last line
];
if(location.href.match(/action=(display|(user)?recent|viewprofile|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
var i=iTd.length;
while(--i){
if(iTd.item(i).width=="20%" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).vAlign=="top" && iTd.item(i).innerHTML.match(/Posts:\s(.+?)<br\s?\/?>/i)){
var iPost=RegExp.$1.replace(/,/g, '');
var iCentre=iTd.item(i).getElementsByTagName('center');
iPostAva.sort(iSort);
for(var a=iPostAva.length-1;a>=0;a--){
if(iPost>=iPostAva[0]){
var iImage=document.createElement('span');
(iCentre.item(iCentre.length-1).innerHTML.match(/\[avatar\]/))? iImage.innerHTML='<b'+'r /><b'+'r />' : '';
iImage.innerHTML+='<img src="'+iPostAva[1]+'" alt="[post avatar]" title="[post avatar]" />';
(iCentre.item(iCentre.length-1).innerHTML.match(/\[avatar\]/))? iCentre.item(iCentre.length-1).insertBefore(iImage, iCentre.item(iCentre.length-1).getElementsByTagName('img').item(0).nextSibling) : iCentre.item(iCentre.length-1).insertBefore(iImage, iCentre.item(iCentre.length-1).firstChild);
break;
}
}
}
}
}
function iSort(a, b){
return parseInt(b) - parseInt(a);
}
//-->
</script>
You can add as many lines as you want, just ensure that there is no comma on the last line.