Post by ialex on Dec 18, 2007 18:36:34 GMT -8
With this code, every user will get their own individual amount of money. This money is based on the amount of posts the user has and their amount of karma.
As well as this, all staff who have the power to modify other's profiles, will be able to subtract or add as much money for any individual user.
Mini Profile Preview
Main Profile Preview
Global Footer.
Cross Browser.
Open Source.
<script type="text/javascript">
<!--
/*Profile Editable Karma and Post Money - By iAlex - Open Source*/
var iPerPost=5; //Money Per Post
var iPerKarma=10; //Money Per Karma
var iMoneySign="$"; //Money Symbol
var iMoneyName="Money"; //Name of Money
if(document.modifyForm && document.modifyForm.customtitle){
var iCustom=document.modifyForm.customtitle;
iCustomTr=iCustom.parentNode.parentNode.parentNode;
var iPosts=document.modifyForm.posts.value;
var iKarma=document.modifyForm.karma.value;
var iMoney=iCustomTr.cloneNode(true);
iMoney.childNodes[0].firstChild.innerHTML=iMoneyName;
iMoney.childNodes[1].innerHTML='<input type="text" size="35" maxlength="30" id="iMonInp" disabled="true" value="'+((parseInt(iPosts)*parseInt(iPerPost))+(parseInt(iKarma)*parseInt(iPerKarma)))+'" /><b'+'r /><b'+'r /><div style="float: left;"><input type="text" size="5" maxlength="25" id="iAddInp" /><a onclick="javascript: iAddMoney(this)" style="cursor: pointer;">Add</a></div><div style="float: right;"><input type="text" size="5" maxlength="25" id="iMinusInp" /><a onclick="javascript: iAddMoney(this)" style="cursor: pointer;">Minus</a> &nb'+'sp; &nb'+'sp; </div>';
iMoney.childNodes[2].firstChild.innerHTML='This is the user\'s amount of '+iMoneyName+' that will be displayed in their mini profile. Use the functions on the left to alter the amount.';
iCustomTr.parentNode.insertBefore(iMoney, iCustomTr.nextSibling);
var iMonInp=document.getElementById('iMonInp');
iHoldChange=0;
if(iCustom.value.match(/\[M0n:NaN\]/)){
iCustom.value=iCustom.value.replace(/\[M0n:NaN\]/g, '');
}
if(iCustom.value.match(/\[M0n:(.+?)\]/)){
iHoldChange=RegExp.$1;
iMonInp.value=parseInt(RegExp.$1)+parseInt(iMonInp.value);
iCustom.value=iCustom.value.replace(/\[M0n:(.+?)\]/g, '');
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSaveMoney, false);
document.modifyForm.posts.addEventListener('keyup', function(){
iMonInp.value= (parseInt(iHoldChange) + (this.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma)));
}, false);
document.modifyForm.karma.addEventListener('keyup', function(){
iMonInp.value = (parseInt(iHoldChange) + (this.value*iPerKarma) + (parseInt(document.modifyForm.posts.value*iPerPost)));
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaveMoney);
document.modifyForm.posts.attachEvent('onkeyup', function(){
iMonInp.value = parseInt(iHoldChange) + (document.modifyForm.posts.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma));
});
document.modifyForm.karma.attachEvent('onkeyup', function(){
iMonInp.value = parseInt(iHoldChange) + (document.modifyForm.posts.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma));
});
}
}
function iSaveMoney(){
var iCustom=document.modifyForm.customtitle;
var iMonInp=document.getElementById('iMonInp').value;
var iPosts=document.modifyForm.posts.value;
var iKarma=document.modifyForm.karma.value;
var iKDefault=iPerKarma*iKarma;
var iPDefault=iPerPost*iPosts;
var iDefault=parseInt(iKDefault)+parseInt(iPDefault);
if(iDefault!=iMonInp && !iMonInp.match(/NaN/)){
iAddition=parseInt(iMonInp)-parseInt(iDefault);
iCustom.value=iCustom.value+'[M0n:'+iAddition+']';
}
}
function iAddMoney(iLink){
var iMonInp=document.getElementById('iMonInp');
iSum=iMonInp.value;
var iPrev=iLink.previousSibling;
if(!iPrev.value.match(/^(\d+)$/)){
alert('Please only insert numerals.');
}
else if(iLink.innerHTML=="Add" && iPrev.value.match(/^(\d+)$/)){
iSum=parseInt(iMonInp.value)+parseInt(RegExp.$1);
iHoldChange=parseInt(iHoldChange)+parseInt(RegExp.$1);
}
else if(iLink.innerHTML=="Minus" && iPrev.value.match(/^(\d+)$/)){
iSum=parseInt(iMonInp.value)-parseInt(RegExp.$1);
iHoldChange=parseInt(iHoldChange)-parseInt(RegExp.$1);
}
iPrev.value='';
iMonInp.value=iSum;
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|(calendar|pm)view|search2)/) || 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 iAddIt=(iTd.item(i).innerHTML.match(/\[M0n:(.+?)\]/))? RegExp.$1 : '0';
var iPost=(iTd.item(i).innerHTML.match(/Posts:\s(.+?)<br\s?\/?>/i))? RegExp.$1.replace(/,/g, '')*iPerPost : '';
var iKarma=(iTd.item(i).innerHTML.match(/Karma:\s(.+?)(<br\s?\/?>|$)/i))? RegExp.$1.replace(/,/g, '')*iPerKarma: '';
var iMonSpan=document.createElement('span');
iMonSpan.innerHTML='<b'+'r />'+iMoneyName+': '+iMoneySign+(parseInt(iAddIt)+(iPost)+(iKarma));
iTd.item(i).appendChild(iMonSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/(<br\s?\/?>)?\[M0n:(.+?)\]/gi, '');
}
}
}
//-->
</script>
You will only need to edit the four variables at the top of the code.
This variable determines the amount of money received per post.
var iPerPost=5; //Money Per Post
This will determine the amount of money received for every point of karma.
var iPerKarma=10; //Money Per Karma
This is the money symbol that will be displayed in the mini profile.
var iMoneySign="$"; //Money Symbol
And this is the name of your money, which will be shown in the mini profile.
var iMoneyName="Money"; //Name of Money
As well as this, all staff who have the power to modify other's profiles, will be able to subtract or add as much money for any individual user.
Mini Profile Preview
Main Profile Preview
Global Footer.
Cross Browser.
Open Source.
<script type="text/javascript">
<!--
/*Profile Editable Karma and Post Money - By iAlex - Open Source*/
var iPerPost=5; //Money Per Post
var iPerKarma=10; //Money Per Karma
var iMoneySign="$"; //Money Symbol
var iMoneyName="Money"; //Name of Money
if(document.modifyForm && document.modifyForm.customtitle){
var iCustom=document.modifyForm.customtitle;
iCustomTr=iCustom.parentNode.parentNode.parentNode;
var iPosts=document.modifyForm.posts.value;
var iKarma=document.modifyForm.karma.value;
var iMoney=iCustomTr.cloneNode(true);
iMoney.childNodes[0].firstChild.innerHTML=iMoneyName;
iMoney.childNodes[1].innerHTML='<input type="text" size="35" maxlength="30" id="iMonInp" disabled="true" value="'+((parseInt(iPosts)*parseInt(iPerPost))+(parseInt(iKarma)*parseInt(iPerKarma)))+'" /><b'+'r /><b'+'r /><div style="float: left;"><input type="text" size="5" maxlength="25" id="iAddInp" /><a onclick="javascript: iAddMoney(this)" style="cursor: pointer;">Add</a></div><div style="float: right;"><input type="text" size="5" maxlength="25" id="iMinusInp" /><a onclick="javascript: iAddMoney(this)" style="cursor: pointer;">Minus</a> &nb'+'sp; &nb'+'sp; </div>';
iMoney.childNodes[2].firstChild.innerHTML='This is the user\'s amount of '+iMoneyName+' that will be displayed in their mini profile. Use the functions on the left to alter the amount.';
iCustomTr.parentNode.insertBefore(iMoney, iCustomTr.nextSibling);
var iMonInp=document.getElementById('iMonInp');
iHoldChange=0;
if(iCustom.value.match(/\[M0n:NaN\]/)){
iCustom.value=iCustom.value.replace(/\[M0n:NaN\]/g, '');
}
if(iCustom.value.match(/\[M0n:(.+?)\]/)){
iHoldChange=RegExp.$1;
iMonInp.value=parseInt(RegExp.$1)+parseInt(iMonInp.value);
iCustom.value=iCustom.value.replace(/\[M0n:(.+?)\]/g, '');
}
if(document.addEventListener){
document.modifyForm.addEventListener('submit', iSaveMoney, false);
document.modifyForm.posts.addEventListener('keyup', function(){
iMonInp.value= (parseInt(iHoldChange) + (this.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma)));
}, false);
document.modifyForm.karma.addEventListener('keyup', function(){
iMonInp.value = (parseInt(iHoldChange) + (this.value*iPerKarma) + (parseInt(document.modifyForm.posts.value*iPerPost)));
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaveMoney);
document.modifyForm.posts.attachEvent('onkeyup', function(){
iMonInp.value = parseInt(iHoldChange) + (document.modifyForm.posts.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma));
});
document.modifyForm.karma.attachEvent('onkeyup', function(){
iMonInp.value = parseInt(iHoldChange) + (document.modifyForm.posts.value*iPerPost) + (parseInt(document.modifyForm.karma.value*iPerKarma));
});
}
}
function iSaveMoney(){
var iCustom=document.modifyForm.customtitle;
var iMonInp=document.getElementById('iMonInp').value;
var iPosts=document.modifyForm.posts.value;
var iKarma=document.modifyForm.karma.value;
var iKDefault=iPerKarma*iKarma;
var iPDefault=iPerPost*iPosts;
var iDefault=parseInt(iKDefault)+parseInt(iPDefault);
if(iDefault!=iMonInp && !iMonInp.match(/NaN/)){
iAddition=parseInt(iMonInp)-parseInt(iDefault);
iCustom.value=iCustom.value+'[M0n:'+iAddition+']';
}
}
function iAddMoney(iLink){
var iMonInp=document.getElementById('iMonInp');
iSum=iMonInp.value;
var iPrev=iLink.previousSibling;
if(!iPrev.value.match(/^(\d+)$/)){
alert('Please only insert numerals.');
}
else if(iLink.innerHTML=="Add" && iPrev.value.match(/^(\d+)$/)){
iSum=parseInt(iMonInp.value)+parseInt(RegExp.$1);
iHoldChange=parseInt(iHoldChange)+parseInt(RegExp.$1);
}
else if(iLink.innerHTML=="Minus" && iPrev.value.match(/^(\d+)$/)){
iSum=parseInt(iMonInp.value)-parseInt(RegExp.$1);
iHoldChange=parseInt(iHoldChange)-parseInt(RegExp.$1);
}
iPrev.value='';
iMonInp.value=iSum;
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|(calendar|pm)view|search2)/) || 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 iAddIt=(iTd.item(i).innerHTML.match(/\[M0n:(.+?)\]/))? RegExp.$1 : '0';
var iPost=(iTd.item(i).innerHTML.match(/Posts:\s(.+?)<br\s?\/?>/i))? RegExp.$1.replace(/,/g, '')*iPerPost : '';
var iKarma=(iTd.item(i).innerHTML.match(/Karma:\s(.+?)(<br\s?\/?>|$)/i))? RegExp.$1.replace(/,/g, '')*iPerKarma: '';
var iMonSpan=document.createElement('span');
iMonSpan.innerHTML='<b'+'r />'+iMoneyName+': '+iMoneySign+(parseInt(iAddIt)+(iPost)+(iKarma));
iTd.item(i).appendChild(iMonSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/(<br\s?\/?>)?\[M0n:(.+?)\]/gi, '');
}
}
}
//-->
</script>
You will only need to edit the four variables at the top of the code.
This variable determines the amount of money received per post.
var iPerPost=5; //Money Per Post
This will determine the amount of money received for every point of karma.
var iPerKarma=10; //Money Per Karma
This is the money symbol that will be displayed in the mini profile.
var iMoneySign="$"; //Money Symbol
And this is the name of your money, which will be shown in the mini profile.
var iMoneyName="Money"; //Name of Money