Conforums Support
Board Enhancements >> Hacks >> Points Hack - July 2012
http://support.conforums.com/index.cgi?board=code&action=display&num=1343225804

Points Hack - July 2012
Post by Dalton on Jul 25th, 2012, 09:16am

Main Footers
Code:
<script language="javascript" type="text/javascript">
var CurrentPoints='0';
var PointsPattern=/\{Points\[<(\d+)>\]\}/i;

var PointsMiniPro='Points: ';
var PointsName='<font size="2"><b>Points:</b></font>';
var PointsProfileDesc='<font size="2"><b>Points:</b></font>';

function SavePointsChange () {
   var websiteURL=document.creator.websiteurl;
   var NewPoints=CurrentPoints;
   if (document.creator.settings6 && CurrentPoints!=document.getElementById('_Points').value) {
      NewPoints=document.getElementById('_Points').value;
   }
   if (websiteURL.value=='' || !websiteURL.value.match(/^http/i)) {
      websiteURL.value=location.href.split('?')[0];
      document.creator.websitetitle.value=document.title.split('-')[0];
   }
   websiteURL.value+=encodeURIComponent('{Points[<')+NewPoints+encodeURIComponent('>]}');
}

if (document.creator) {
   var websiteURL=document.creator.websiteurl;
   if (decodeURI(websiteURL.value).match(PointsPattern)) {
      CurrentPoints=RegExp.$1;
      websiteURL.value=decodeURI(websiteURL.value).replace(PointsPattern,'');
   }
   if (document.creator.settings6) {
      var newInput=document.createElement('input');
      newInput.type='text';
      newInput.id='_Points';
      newInput.value=CurrentPoints;
      var oneTR=document.creator.settings6.parentNode.parentNode.parentNode;
      var primaTR=oneTR.parentNode.parentNode.insertRow(oneTR.rowIndex);
      primaTR.insertCell(0).innerHTML=PointsProfileDesc;
      primaTR.insertCell(1).appendChild(newInput);
   }
   document.creator.onsubmit=SavePointsChange;
}

if (location.href.match(/action=(profile2|viewprofile)/i)) {
   var tables=document.getElementsByTagName('table');
   for (var h=0;h<tables.length;h++) {
      if (tables[h].width=='100%' && tables[h].cellPadding=='2' && tables[h].rows[0].cells[0].firstChild.firstChild.innerHTML=='Name: ') {
         var AWithPoints=tables[h].rows[11].getElementsByTagName('a')[0];
         var DecodedA=decodeURI(AWithPoints.href);
         if (AWithPoints.href!=location.href.split('index.cgi')[0] && DecodedA.match(PointsPattern)) {
            CurrentPoints=PointsPattern.exec(DecodedA)[1];
            AWithPoints.href=DecodedA.replace(PointsPattern,'');
         }
         tables[h].insertRow(13);
         tables[h].rows[13].insertCell(0).innerHTML=PointsName;
         tables[h].rows[13].insertCell(1).innerHTML='<font size="2">'+CurrentPoints+'</font>';
      }
   }
   var tds=document.getElementsByTagName('td');
   for (var e=0;e<tds.length;e++) {
      if (tds[e].width=='30%' && tds[e].vAlign=='middle' && tds[e].className=='windowbg') {
         var TDLinks=tds[e].getElementsByTagName('a');
         for (var c=0;c<TDLinks.length;c++) {
            if (decodeURI(TDLinks[c].href).match(PointsPattern)) {
               TDLinks[c].href=decodeURI(TDLinks[c].href).replace(PointsPattern,'');
            }
         }
         var newText=document.createTextNode(PointsMiniPro+CurrentPoints);
         var TDFonts=tds[e].getElementsByTagName('font');
         TDFonts[TDFonts.length-1].appendChild(newText);
      }
   }
}

if (location.href.match(/action=(calendarview|imshow)/i)) {
   var tds=document.getElementsByTagName('td');
   for (var h=0;h<tds.length;h++) {
      if (tds[h].width=='20%' && tds[h].className.match(/windowbg/i) && tds[h].rowSpan=='2' && tds[h].getElementsByTagName('a').length>0) {
         var TDLinks=tds[h].getElementsByTagName('a');
         for (var e=0;e<TDLinks.length;e++) {
            if (decodeURI(TDLinks[e].href).match(PointsPattern)) {
               CurrentPoints=RegExp.$1;
               TDLinks[e].href=decodeURI(TDLinks[e].href).replace(PointsPattern,'');
               break;
            }
         }
         var newText=document.createTextNode(PointsMiniPro+CurrentPoints);
         var TDFonts=tds[h].getElementsByTagName('font');
         TDFonts[TDFonts.length-1].appendChild(newText);
         CurrentPoints='0';
      }
   }
}

if (location.href.match(/action=ml(all|letter|top|staff)/i)) {
   var trs=document.getElementsByTagName('tr');
   for (var h=0;h<trs.length;h++) {
      if (trs[h].cells.length>2 && trs[h].cells[2].className=='windowbg' && trs[h].cells[2].firstChild.nodeName=='FONT' && trs[h].cells[2].getElementsByTagName('a').length>0) {
         var oneA=trs[h].cells[2].getElementsByTagName('a')[0];
         oneA.href=decodeURI(oneA.href).replace(PointsPattern,'');
      }
   }
}
</script>  


ALL BOARD FOOTERS

Code:
<script language="javascript" type="text/javascript">
var CurrentPoints='0';
var PointsPattern=/\{Points\[<(\d+)>\]\}/i;

var PointsMiniPro='Points: ';

if (location.href.match(/action=display/i)) {
   var tds=document.getElementsByTagName('td');
   for (var h=0;h<tds.length;h++) {
      if (tds[h].width=='20%' && tds[h].className.match(/windowbg/i) && tds[h].rowSpan=='2' && tds[h].getElementsByTagName('a').length>0) {
         var TDLinks=tds[h].getElementsByTagName('a');
         for (var e=0;e<TDLinks.length;e++) {
            if (decodeURI(TDLinks[e].href).match(PointsPattern)) {
               CurrentPoints=RegExp.$1;
               TDLinks[e].href=decodeURI(TDLinks[e].href).replace(PointsPattern,'');
               break;
            }
         }
         var newText=document.createTextNode(PointsMiniPro+CurrentPoints);
         var TDFonts=tds[h].getElementsByTagName('font');
         TDFonts[TDFonts.length-1].appendChild(newText);
         CurrentPoints='0';
      }
   }
}
</script>  



To modify the name of points look for this variable in both codes

Code:
var PointsMiniPro='Points: '; 
and change Points: to your desired form of currency