Post by Ross on Jan 13, 2006 5:07:44 GMT -8
Global Footer
This uses the same coding as the Money Hack v3 except Wonder edited it to allow the use of more than one type of money. For example, so all members can have Pounds, Dollars and Euros in their mini-profile.
To edit it, modify the bits in purple, all come with comments as to what they do. List the variables for each type of money as shown, seperating each one with a comma. If you have any questions or problems, please use the Code Support Board
<script type="text/javascript">
<!--
/*
Multiply Money Hack v3.1 - Global footer
Created by Ross, Concept by Peter, Modified by Wonder
This code cannot be reposted at anywhere other than ProBoards Support without permission.
This header must stay intact at all times.
*/
// The value of money a member should gain for each post
var MoneyPerPost =[
5,
2,
3
];
// What do you want to call your money?
var NameOfMoney = [
'Dollars',
'Pounds',
'Euros'
];
// The symbol that will appear next to the money
var SymbolOfMoney = [
'$',
'£',
'€'
];
// No need to edit below
temp="\\[M:";
for(i=0;i<MoneyPerPost.length;i++)
temp+="(-)?([\\d\\.]+):";
temp+="\\]";
var re=new RegExp(temp, "im");
var re2=new RegExp("(<br>)?"+temp, "im");
function updateMon() {
for(j=0;j<MoneyPerPost.length;j++)
{
var monChange = document.getElementById('monChange'+j);
var curMon = document.getElementById('monDisplay'+j);
var monType = document.getElementById('monType'+j);
mon = parseInt("0"+curMon.value.replace( SymbolOfMoney[j] , '' ),10) + parseInt(( ( monType.value == '-' ) ? '-' : '' ) + "0"+monChange.value,10 )
monChange.value = 0;
curMon.value = SymbolOfMoney[j] + mon;
}
return true;
}
function fNum(num){
if(!isNaN(num)){
num = num.toLocaleString().replace(/\.\d+/, "");
} else {
num = 0;
}
return num;
}
function saveMon() {
updateMon();
newMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
newMon[j] = document.getElementById('monDisplay'+j).value.replace( SymbolOfMoney[j] , '' );
newMon[j] -= (parseInt(document.modifyForm.posts.value) * MoneyPerPost[j])
}
document.modifyForm.customtitle.value += '[M:'+newMon.join(":")+':]';
return true;
}
var td = document.getElementsByTagName('td');
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).vAlign == 'top' && td.item(i).parentNode.innerHTML.match(/Posts: (.+?)</)) {
temp2=RegExp.$1.replace(/,/g,'');
curMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
curMon[j] = (temp2 * MoneyPerPost[j]);
curMon[j] += td.item(i).innerHTML.match(re)? parseInt(eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2))) : 0;
if(td.item(i).lastChild.nodeName.toLowerCase() != 'br')
td.item(i).appendChild(document.createElement('br'));
td.item(i).appendChild(document.createTextNode(NameOfMoney[j] +': '+ SymbolOfMoney[j] + fNum(curMon[j])));
}
td.item(i).innerHTML=td.item(i).innerHTML.replace(re2,"");
}
else if(location.href.match(/ion=viewpro/) && td.item(i).width == '25%' && td.item(i).innerHTML.match(/>Posts:</)) {
for(j=MoneyPerPost.length-1;j>=0;j--)
{
var monTitle = document.createElement('font');
monTitle.size = '2';
monTitle.appendChild(document.createTextNode(NameOfMoney[j]+':'));
var userMon = document.createElement('font');
userMon.size = '2';
userMon.appendChild(document.createTextNode(SymbolOfMoney[j]+fNum(curMon[j])));
monRow = td.item(i).parentNode.parentNode.insertRow(6);
monRow.insertCell(0).appendChild(monTitle);
monRow.insertCell(1).appendChild(userMon);
}
break;
}
}
if(document.modifyForm && document.modifyForm.customtitle) {
if(document.modifyForm.personaltext.value.match(re) && !document.modifyForm.customtitle.value.match(re))
{
document.modifyForm.customtitle.value += '[M:';
for(j=0;j<MoneyPerPost.length;j++)
document.modifyForm.customtitle.value+=eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2)+"");
document.modifyForm.customtitle.value+=']';
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(re,'');
}
Posts = document.modifyForm.posts.value.match(/(-)?(\d+)/)? parseInt(RegExp.$1+RegExp.$2) : 0;
curMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
curMon[j] = document.modifyForm.customtitle.value.match(re)? parseInt(eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2)+"")) : 0;
curMon[j] += (Posts * MoneyPerPost[j])
}
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(re,'');
document.modifyForm.customtitle.maxLength = 490;
for(j=MoneyPerPost.length-1;j>-1;j--)
{
var display = document.createElement('input');
display.type = 'text';
display.id = 'monDisplay'+j;
display.size = parseInt(curMon[j].toString().length) + 2;
display.disabled = true;
display.value = SymbolOfMoney[j] + curMon[j];
var type = document.createElement('select');
type.id = 'monType'+j;
type.appendChild(document.createElement('option'));
type.firstChild.appendChild(document.createTextNode('+'));
type.appendChild(document.createElement('option'));
type.lastChild.appendChild(document.createTextNode('-'));
type.lastChild.value = '-';
var mon = document.createElement('input');
mon.type = 'text';
mon.id = 'monChange'+j;
mon.size = 5;
mon.value = 0;
var update = document.createElement('input');
update.type = 'button';
update.value = 'Update';
update.onclick = function(){ updateMon(); };
var editMon = document.createElement('font');
editMon.appendChild(type);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(mon);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(update);
var newTitle = document.createElement('font');
newTitle.size = '2';
newTitle.appendChild(document.createTextNode(NameOfMoney[j] +': '));
newTitle.appendChild(display);
var newDes = document.createElement('font');
newDes.size = '1';
newDes.appendChild(document.createTextNode('Here you can edit the amount of '+NameOfMoney[j]+' a member has. Just enter the value of ' +NameOfMoney[j]+ ' to add or subtract.'));
var target = document.modifyForm.customtitle.parentNode.parentNode.parentNode.parentNode.insertRow(2);
target.insertCell(0).appendChild(newTitle);
target.insertCell(1).appendChild(editMon)
target.insertCell(2).appendChild(newDes);
}
document.getElementsByName('profileaction').item(0).onclick = function() { saveMon(); };
}
//-->
</script>
Note for When Removing this Code:
This code stores information in the "Custom Title" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the custom title until you or the user removes it. This information would look something like: [M:100:58:975:]
This uses the same coding as the Money Hack v3 except Wonder edited it to allow the use of more than one type of money. For example, so all members can have Pounds, Dollars and Euros in their mini-profile.
To edit it, modify the bits in purple, all come with comments as to what they do. List the variables for each type of money as shown, seperating each one with a comma. If you have any questions or problems, please use the Code Support Board
<script type="text/javascript">
<!--
/*
Multiply Money Hack v3.1 - Global footer
Created by Ross, Concept by Peter, Modified by Wonder
This code cannot be reposted at anywhere other than ProBoards Support without permission.
This header must stay intact at all times.
*/
// The value of money a member should gain for each post
var MoneyPerPost =[
5,
2,
3
];
// What do you want to call your money?
var NameOfMoney = [
'Dollars',
'Pounds',
'Euros'
];
// The symbol that will appear next to the money
var SymbolOfMoney = [
'$',
'£',
'€'
];
// No need to edit below
temp="\\[M:";
for(i=0;i<MoneyPerPost.length;i++)
temp+="(-)?([\\d\\.]+):";
temp+="\\]";
var re=new RegExp(temp, "im");
var re2=new RegExp("(<br>)?"+temp, "im");
function updateMon() {
for(j=0;j<MoneyPerPost.length;j++)
{
var monChange = document.getElementById('monChange'+j);
var curMon = document.getElementById('monDisplay'+j);
var monType = document.getElementById('monType'+j);
mon = parseInt("0"+curMon.value.replace( SymbolOfMoney[j] , '' ),10) + parseInt(( ( monType.value == '-' ) ? '-' : '' ) + "0"+monChange.value,10 )
monChange.value = 0;
curMon.value = SymbolOfMoney[j] + mon;
}
return true;
}
function fNum(num){
if(!isNaN(num)){
num = num.toLocaleString().replace(/\.\d+/, "");
} else {
num = 0;
}
return num;
}
function saveMon() {
updateMon();
newMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
newMon[j] = document.getElementById('monDisplay'+j).value.replace( SymbolOfMoney[j] , '' );
newMon[j] -= (parseInt(document.modifyForm.posts.value) * MoneyPerPost[j])
}
document.modifyForm.customtitle.value += '[M:'+newMon.join(":")+':]';
return true;
}
var td = document.getElementsByTagName('td');
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).vAlign == 'top' && td.item(i).parentNode.innerHTML.match(/Posts: (.+?)</)) {
temp2=RegExp.$1.replace(/,/g,'');
curMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
curMon[j] = (temp2 * MoneyPerPost[j]);
curMon[j] += td.item(i).innerHTML.match(re)? parseInt(eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2))) : 0;
if(td.item(i).lastChild.nodeName.toLowerCase() != 'br')
td.item(i).appendChild(document.createElement('br'));
td.item(i).appendChild(document.createTextNode(NameOfMoney[j] +': '+ SymbolOfMoney[j] + fNum(curMon[j])));
}
td.item(i).innerHTML=td.item(i).innerHTML.replace(re2,"");
}
else if(location.href.match(/ion=viewpro/) && td.item(i).width == '25%' && td.item(i).innerHTML.match(/>Posts:</)) {
for(j=MoneyPerPost.length-1;j>=0;j--)
{
var monTitle = document.createElement('font');
monTitle.size = '2';
monTitle.appendChild(document.createTextNode(NameOfMoney[j]+':'));
var userMon = document.createElement('font');
userMon.size = '2';
userMon.appendChild(document.createTextNode(SymbolOfMoney[j]+fNum(curMon[j])));
monRow = td.item(i).parentNode.parentNode.insertRow(6);
monRow.insertCell(0).appendChild(monTitle);
monRow.insertCell(1).appendChild(userMon);
}
break;
}
}
if(document.modifyForm && document.modifyForm.customtitle) {
if(document.modifyForm.personaltext.value.match(re) && !document.modifyForm.customtitle.value.match(re))
{
document.modifyForm.customtitle.value += '[M:';
for(j=0;j<MoneyPerPost.length;j++)
document.modifyForm.customtitle.value+=eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2)+"");
document.modifyForm.customtitle.value+=']';
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(re,'');
}
Posts = document.modifyForm.posts.value.match(/(-)?(\d+)/)? parseInt(RegExp.$1+RegExp.$2) : 0;
curMon=new Array();
for(j=0;j<MoneyPerPost.length;j++)
{
curMon[j] = document.modifyForm.customtitle.value.match(re)? parseInt(eval("RegExp.$"+((j*2)+1)+"+RegExp.$"+((j*2)+2)+"")) : 0;
curMon[j] += (Posts * MoneyPerPost[j])
}
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(re,'');
document.modifyForm.customtitle.maxLength = 490;
for(j=MoneyPerPost.length-1;j>-1;j--)
{
var display = document.createElement('input');
display.type = 'text';
display.id = 'monDisplay'+j;
display.size = parseInt(curMon[j].toString().length) + 2;
display.disabled = true;
display.value = SymbolOfMoney[j] + curMon[j];
var type = document.createElement('select');
type.id = 'monType'+j;
type.appendChild(document.createElement('option'));
type.firstChild.appendChild(document.createTextNode('+'));
type.appendChild(document.createElement('option'));
type.lastChild.appendChild(document.createTextNode('-'));
type.lastChild.value = '-';
var mon = document.createElement('input');
mon.type = 'text';
mon.id = 'monChange'+j;
mon.size = 5;
mon.value = 0;
var update = document.createElement('input');
update.type = 'button';
update.value = 'Update';
update.onclick = function(){ updateMon(); };
var editMon = document.createElement('font');
editMon.appendChild(type);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(mon);
editMon.appendChild(document.createTextNode(' '));
editMon.appendChild(update);
var newTitle = document.createElement('font');
newTitle.size = '2';
newTitle.appendChild(document.createTextNode(NameOfMoney[j] +': '));
newTitle.appendChild(display);
var newDes = document.createElement('font');
newDes.size = '1';
newDes.appendChild(document.createTextNode('Here you can edit the amount of '+NameOfMoney[j]+' a member has. Just enter the value of ' +NameOfMoney[j]+ ' to add or subtract.'));
var target = document.modifyForm.customtitle.parentNode.parentNode.parentNode.parentNode.insertRow(2);
target.insertCell(0).appendChild(newTitle);
target.insertCell(1).appendChild(editMon)
target.insertCell(2).appendChild(newDes);
}
document.getElementsByName('profileaction').item(0).onclick = function() { saveMon(); };
}
//-->
</script>
Note for When Removing this Code:
This code stores information in the "Custom Title" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the custom title until you or the user removes it. This information would look something like: [M:100:58:975:]