Post by Todge on Nov 21, 2008 13:00:59 GMT -8
This will allow a member to select their own rank once they reach a specified number of posts..
Put it in your Global Footer..
Edit the variable 'postsNeeded' at the top of the code with the number of posts needed to allow your members to select their own rank. Which they can do in their profile.
This code uses cookies, so obviously your members will need to allow them for the code to work for them, also, only posts created after a rank has been chosen will display the new rank.
Put it in your Global Footer..
<script type="text/javascript">
<!--
/*
Member selectable rank
Copyright © 2008 by Todge.
Please keep this header intact
*/
// Edit Below...
var postsNeeded = 300;
// Edit Above...
function setCookie(rank)
{
if(document.modifyForm)
{
rank = document.modifyForm.personalrank.value.replace(/ /g,'_');
rank = 'Rank='+rank;
}
var expireDate = new Date();
expireDate.setMonth(expireDate.getMonth()+24);
document.cookie = rank+'; expires='+expireDate.toGMTString()+'; path=/';
}
// Cookie post total...
if(document.location.href.match(/action=viewprofile$/))
{
var posts = document.getElementsByTagName('font');
for(p=0; p<posts.length; p++)
{
if(posts[p].innerHTML == 'Posts:')
{
posts = posts[p+1].innerHTML;
setCookie('Posts='+posts);
if(posts >= postsNeeded && !document.cookie.match(/Rank/))
{
alert('You have posted enough times to choose a rank');
}
break;
}}}
// Show option in profile page...
if(document.modifyForm)
{
var postsSoFar = parseInt(document.cookie.split('Posts=')[1].split(';')[0]);
var tr = document.createElement('TR');
var td1 = document.createElement('TD');
var td2 = document.createElement('TD');
var td3 = document.createElement('TD');
td1.innerHTML = '<font size="-1">Personal Rank:</font>';
td2.innerHTML = '<font size="-1"><input name="personalrank" size="35" maxlength="20" value="" type="text"></font>';
td3.innerHTML = '<font size="-2">You can choose a rank once you reach '+postsNeeded+' posts.</font>';
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
var sig = document.modifyForm.signature.parentNode.parentNode.parentNode;
sig.parentNode.insertBefore(tr,sig);
if(document.cookie.match('Rank='))
{
document.modifyForm.personalrank.value = document.cookie.split('Rank=')[1].split(';')[0].replace(/_/g,' ');
}
if(postsSoFar >= postsNeeded)
{
document.modifyForm.onsubmit = function(){setCookie();}
}}
// Add Rank to posts...
if(document.postForm)
{
if(document.cookie.match('Rank='))
{
if(document.postForm.message.value.match(/_rank\.com\] \[/))
{
document.postForm.message.value = document.postForm.message.value.replace(/\[url=(.)+_rank\.com\] \[\/url\]/,'');
}
var rank = "[url=http://"+document.cookie.split('Rank=')[1].split(';')[0];
rank += "_rank.com] [/url]";
document.postForm.onsubmit = function(){document.postForm.message.value = document.postForm.message.value+rank;}
}}
// Find and add rank to mini profile...
if(document.location.href.match('action=display'))
{
var posts = document.getElementsByTagName('font');
for(p=0; p<posts.length; p++)
{
if(posts[p].innerHTML .match('- google_ad_section_start -') && posts[p].innerHTML.match('_rank.com'))
{
var rank = posts[p].innerHTML.split('_rank')[0].split('//')[1].replace(/_/g,' ');
miniPro = posts[p];
while(miniPro.parentNode.firstChild.width != '20%')
{
miniPro = miniPro.parentNode;
}
miniPro = miniPro.parentNode.firstChild;
var currentRank = miniPro.innerHTML.split(/<br>/i)[1];
miniPro.innerHTML = miniPro.innerHTML.replace(currentRank,rank);
}}}
// -->
</script>
Edit the variable 'postsNeeded' at the top of the code with the number of posts needed to allow your members to select their own rank. Which they can do in their profile.
This code uses cookies, so obviously your members will need to allow them for the code to work for them, also, only posts created after a rank has been chosen will display the new rank.