Post by Todge on May 23, 2011 11:52:17 GMT -8
This is a points system, similar to the Money Hack, in that it will allow you to give or take points from any of your members.
The points can be given (or taken) in the member's profile, down near the bottom in the Admin only area. It uses the Personal Text area to save the points, so it will reduce the available space there a little for other things, but should be compatable with most other codes that use that field for storage. The member's points will appear in their mini-profile.
It goes in your Global Footer.
The points can be given (or taken) in the member's profile, down near the bottom in the Admin only area. It uses the Personal Text area to save the points, so it will reduce the available space there a little for other things, but should be compatable with most other codes that use that field for storage. The member's points will appear in their mini-profile.
It goes in your Global Footer.
<script type="text/javascript">
<!--
/*
Points system by Todge
Copyright © 2011
Please keep this header intact
Global or Board Footer
*/
// Profile stuffs..
if(document.modifyForm && document.modifyForm.customtitle)
{
function addpoints(toadd)
{
if(isNaN(toadd) == true)
{
alert('Please use only numbers.');
input.value = 0;
return;
}
currentpoints = currentpoints+parseInt(toadd);
td3.innerHTML = '<font size="-2">'+document.modifyForm.name.value+' currently has <font color="red">'+currentpoints+'</font> points.</font>';
td3.innerHTML += '<font size="-2"><br>To give or take points from '+document.modifyForm.name.value+' enter the number and click on the \'+\' or \'-\' symbol.</font>';
input.value = 0;
return;
}
function pointstoCT()
{
document.modifyForm.customtitle.value = '[p:'+currentpoints+']'+document.modifyForm.customtitle.value;
return;
}
// Get current points and remove code from CT..
var currentpoints = document.modifyForm.customtitle.value;
if(currentpoints.match(/\[p:/))
{
currentpoints = parseInt(currentpoints.split('[p:')[1]);
document.modifyForm.customtitle.value = document.modifyForm.customtitle.value.replace(/\[p:\d+\]/,'');
}
else
{
currentpoints = 0;
}
// Create and add the 'Points' field to profile..
var pointsrow = document.modifyForm.customtitle.parentNode.parentNode.parentNode;
var tr = document.createElement('tr')
var td1 = document.createElement('td');
var td2 = document.createElement('td');
var td3 = document.createElement('td');
var input = document.createElement('input');
var plus = document.createElement('font');
var minus = document.createElement('font');
with(plus){
style.cursor = 'pointer';
innerHTML = '<font size="4">+</font>';
onclick = function(){addpoints(input.value);}
}
with(minus){
style.cursor = 'pointer';
innerHTML = '<font size="4">-</font>';
onclick = function(){addpoints(0-input.value);}
}
with(input){
value = 0;
name = 'points';
type = 'text';
maxLength = 4;
size = "5";
}
with(td1){
innerHTML = '<font size="-1">Points:</font>';
vAlign='top';
}
with(td2){
vAlign = 'top';
appendChild(input);
appendChild(plus);
appendChild(minus);
}
with(tr){
appendChild(td1);
appendChild(document.createTextNode(' '));
appendChild(td2);
appendChild(document.createTextNode(' '));
appendChild(td3);
}
pointsrow.parentNode.insertBefore(tr,pointsrow);
addpoints(0);
if(window.addEventListener)
{
document.modifyForm.addEventListener('submit', pointstoCT, false);
}
else
{
document.modifyForm.attachEvent('onsubmit', pointstoCT);
}
}
// Remove code and add points to mini-profile..
var td = document.getElementsByTagName('td');
for(t=0; t<td.length; t++)
{
if(td[t].width == '20%' && td[t].className.match(/windowbg/) && td[t].innerHTML.match(/\[p:\d+\]/))
{
var miniPro = td[t].innerHTML;
var currentpoints = parseInt(miniPro.split(/\[p:/)[1]);
miniPro = miniPro.replace(/\[p:\d+\](<br\/?>)?/i,'').split(/<br\/?>/i);
miniPro[miniPro.length] = miniPro[miniPro.length-1];
miniPro[miniPro.length-2] = 'Points: '+currentpoints;
td[t].innerHTML = miniPro.join('<br>');
}}
// -->
</script>