Post by iAlex on Dec 16, 2007 21:24:26 GMT -5
This code will give each user a certain amount of money for each post they make. This money will then appear in their mini profile.
As well as this, all staff who have profile modifying powers, will be able to add or subtract as much money as they want from any individual member.
Mini Profile Preview
Main Profile Preview
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Profile Editable Post Money - By iAlex - Open Source*/
var iPerPost=5; //Money Per Post
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 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))+'" /><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:(.+?)\]/)){
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);
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaveMoney);
document.modifyForm.posts.attachEvent('onkeyup', function(){
iMonInp.value=parseInt(iHoldChange)+(document.modifyForm.posts.value*iPerPost);
});
}
}
function iSaveMoney(){
var iCustom=document.modifyForm.customtitle;
var iMonInp=document.getElementById('iMonInp').value;
var iPosts=document.modifyForm.posts.value;
var iDefault=iPerPost*iPosts;
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 iMonSpan=document.createElement('span');
iMonSpan.innerHTML='<b'+'r />'+iMoneyName+': '+iMoneySign+(parseInt(iAddIt)+(iPost));
iTd.item(i).appendChild(iMonSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/(<br\s?\/?>)?\[M0n:(.+?)\]/gi, '');
}
}
}
//-->
</script>
You simply need to edit the three variables at the top of the code:
This variable determines how much money each user will receive for each of their posts:
var iPerPost=5; //Money Per Post
This is the money symbol, which will appear before the amount of money in the mini profile:
var iMoneySign="$"; //Money Symbol
And this is what you want to call the money. It will appear in the mini profile.
var iMoneyName="Money"; //Name of money
As well as this, all staff who have profile modifying powers, will be able to add or subtract as much money as they want from any individual member.
Mini Profile Preview
Main Profile Preview
Cross Browser.
Global Footer.
Open Source.
<script type="text/javascript">
<!--
/*Profile Editable Post Money - By iAlex - Open Source*/
var iPerPost=5; //Money Per Post
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 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))+'" /><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:(.+?)\]/)){
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);
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', iSaveMoney);
document.modifyForm.posts.attachEvent('onkeyup', function(){
iMonInp.value=parseInt(iHoldChange)+(document.modifyForm.posts.value*iPerPost);
});
}
}
function iSaveMoney(){
var iCustom=document.modifyForm.customtitle;
var iMonInp=document.getElementById('iMonInp').value;
var iPosts=document.modifyForm.posts.value;
var iDefault=iPerPost*iPosts;
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 iMonSpan=document.createElement('span');
iMonSpan.innerHTML='<b'+'r />'+iMoneyName+': '+iMoneySign+(parseInt(iAddIt)+(iPost));
iTd.item(i).appendChild(iMonSpan);
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/(<br\s?\/?>)?\[M0n:(.+?)\]/gi, '');
}
}
}
//-->
</script>
You simply need to edit the three variables at the top of the code:
This variable determines how much money each user will receive for each of their posts:
var iPerPost=5; //Money Per Post
This is the money symbol, which will appear before the amount of money in the mini profile:
var iMoneySign="$"; //Money Symbol
And this is what you want to call the money. It will appear in the mini profile.
var iMoneyName="Money"; //Name of money