|
Post by Wormopolis on Sept 1, 2010 16:10:25 GMT -8
Browser tested: IE and FF placement: Global footer
Allows staff with power to edit custom title to be able to modify a custom point system (like "XP") and have the mini-profile show a ranking based on that point system
updated: added in progress bar and ability to have post count affect rank.
code
<script type="text/javascript"> <!-- // custom ranking by custom points // v2.11 // by Wormopolis - www.wormocodes.com // request by Dakota // keep header intact
var nameOfPoints='XP'; var MPtext="Site Rank: ";
var useProgressBar=true; // turn on progress bar below site rank var pgStartColor="0033FF"; //starting fade color var pgEndColor="00FF33"; //ending fade color
var postCountAffected=true; //if you want postCount to affect site rank var postCountWeight=0.1; //how much of post count should affect site rank
var onlyAffectEditedUsers=true; //set to false to work on everyone
var nwRankArray=[ [0,'noob'], //points count , 'title' add in more to your hearts desire [1,'lessnoob'], [10,'Squire'], [50,'Knight'], [100,'King'], [500,'Deity'], [1000,'Super Deity'], [5000,'Way too much time on their hands'], [10000,'FractionOfWormo'] //no comma last line ];
if (document.modifyForm && document.modifyForm.customtitle) { // see if points already exist var wcurPoints=0; if (document.modifyForm.customtitle.value.match(/\[wCP:(\d+)\]/)) { wcurPoints=RegExp.$1; document.modifyForm.customtitle.value=document.modifyForm.customtitle.value.replace(/\[wCP:(\d+)\]/,'') } // create area for editing points var ctArea=document.modifyForm.customtitle.parentNode.parentNode.parentNode; var clnArea=ctArea.cloneNode(true); clnArea.firstChild.firstChild.innerHTML=nameOfPoints+':'; clnArea.firstChild.nextSibling.firstChild.innerHTML = clnArea.firstChild.nextSibling.firstChild.innerHTML.replace(/customtitle/,'custpoints'); clnArea.firstChild.nextSibling.firstChild.firstChild.value=wcurPoints; clnArea.firstChild.nextSibling.nextSibling.firstChild.innerHTML="Edit "+nameOfPoints+" for this member here."; ctArea.parentNode.insertBefore(clnArea, ctArea); // attach event to submit if (document.modifyForm.addEventListener) { document.modifyForm.addEventListener('submit',function() {cpvalue=document.modifyForm.custpoints.value; document.modifyForm.customtitle.value+='[wCP:'+cpvalue+']';},true); } else { document.modifyForm.attachEvent('onsubmit',function() {cpvalue=document.modifyForm.custpoints.value; document.modifyForm.customtitle.value+='[wCP:'+cpvalue+']';}); } }
function intToHex(num_i) { res=(num_i.toString(16).length>1? num_i.toString(16): "0"+num_i.toString(16)); return res.toUpperCase(); }
function hexToInt(num_h) { tot=0; num_h=num_h.toUpperCase(); for (a=num_h.length-1; a>=0; a--) { if (num_h.charAt(a).match(/\d/)) tot+=(Math.pow(16, num_h.length-1-a)*parseInt(num_h.charAt(a))); else tot+=(Math.pow(16, num_h.length-1-a)*(num_h.charCodeAt(a)-55)); } return tot; }
function blendColor(stcolor, endcolor, pos) { var st_red=stcolor.substr(0,2), en_red=endcolor.substr(0,2), st_green=stcolor.substr(2,2), en_green=endcolor.substr(2,2), st_blue=stcolor.substr(4,2), en_blue=endcolor.substr(4,2); var moddy=pos/100; var redspan=Math.round((hexToInt(en_red)-hexToInt(st_red))*moddy); var greenspan=Math.round((hexToInt(en_green)-hexToInt(st_green))*moddy); var bluespan=Math.round((hexToInt(en_blue)-hexToInt(st_blue))*moddy); var nwRed=intToHex(hexToInt(st_red)+redspan); var nwGreen=intToHex(hexToInt(st_green)+greenspan); var nwBlue=intToHex(hexToInt(st_blue)+bluespan); return nwRed+nwGreen+nwBlue; }
// modify MP to have rank for (tds=document.getElementsByTagName('td'), wcp=0; wcp<tds.length; wcp++) { if (tds[wcp].width=='20%' && tds[wcp].className.match(/windowbg/) && (!onlyAffectEditedUsers || tds[wcp].innerHTML.match(/\[wCP:(\d+)\]/))) { cptmpval=(tds[wcp].innerHTML.match(/\[wCP:(\d+)\]/) ? parseInt(RegExp.$1) : 0); var pstcnt=(tds[wcp].innerHTML.match(/Posts:\s(\d+(\,\d+)?)/) ? parseInt(RegExp.$1.replace(',','')) : 0); if (postCountAffected) cptmpval+=parseInt(pstcnt*postCountWeight); for (aa=nwRankArray.length-1; aa>=0; aa--) { if (cptmpval>=nwRankArray[aa][0]) { rankresult=nwRankArray[aa][1]; break; } } var rplstuff='<br>'+MPtext+rankresult+'<br>'; if (useProgressBar) { var nxtHit=(aa<nwRankArray.length-1 ? nwRankArray[aa+1][0] : cptmpval); var percPoint=parseInt((cptmpval / nxtHit)*100); var tmptbl='<table width="80%" cellSpacing="0" style="height: 20px; border: #000000 1px solid"><tr>'; for (bc=1; bc<=100; bc++) { tmptbl+='<td width="1%" style="'+(bc==percPoint ? 'background-color:#FFFFFF; border:#000000 1px solid' : 'background-color: '+blendColor(pgStartColor, pgEndColor, bc))+'"></td>'; } tmptbl+='</tr></table>'; rplstuff+=tmptbl+'<br>'; } if (tds[wcp].innerHTML.match(/\[wCP:(\d+)\]/)) { tds[wcp].innerHTML=tds[wcp].innerHTML.replace(/\[wCP:(\d+)\]/,rplstuff); } else { tds[wcp].innerHTML=tds[wcp].innerHTML.replace(/member is/,rplstuff+'member is'); } } }
// --> </script>
Preview: not yet.
|
|
|
Post by Wormopolis on Oct 10, 2010 20:24:46 GMT -8
version update 2.0: added in progress bar (with start and end color customization), added in ability to have post count affect rank.
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Oct 31, 2011 8:43:03 GMT -8
I can't get this to work - anything I've mis-edited?
<script type="text/javascript"> <!-- // custom ranking by custom points // v2.0 // by Wormopolis - [url]www.wormocodes.com[/url] // request by Dakota // keep header intact
var nameOfPoints='XP'; var MPtext="Assassin Rank: ";
var useProgressBar=false; // turn on progress bar below site rank var pgStartColor="0033FF"; //starting fade color var pgEndColor="00FF33"; //ending fade color
var postCountAffected=true; //if you want postCount to affect site rank var postCountWeight=0.1; //how much of post count should affect site rank
var nwRankArray=[ [0,'Interested'], //points count , 'title' add in more to your hearts desire [1,'New Initiate'], [10,'Novice'], [50,'Messenger'], [100,'Assassin'], [500,'Skilled Assassin'], [1000,'Infamous'], [5000,'Highly Regarded'], [10000,'Grand Master'] //no comma last line ];
if (document.modifyForm && document.modifyForm.customtitle) { // see if points already exist var wcurPoints=0; if (document.modifyForm.customtitle.value.match(/\[wCP:(\d+)\]/)) { wcurPoints=RegExp.$1; document.modifyForm.customtitle.value=document.modifyForm.customtitle.value.replace(/\[wCP:(\d+)\]/,'') } // create area for editing points var ctArea=document.modifyForm.customtitle.parentNode.parentNode.parentNode; var clnArea=ctArea.cloneNode(true); clnArea.firstChild.firstChild.innerHTML=nameOfPoints+':'; clnArea.firstChild.nextSibling.firstChild.innerHTML=clnArea.firstChild.nextSibling.firstChild.innerHTML.replace(/customt itle/,'custpoints'); clnArea.firstChild.nextSibling.firstChild.firstChild.value=wcurPoints; clnArea.firstChild.nextSibling.nextSibling.firstChild.innerHTML="Edit "+nameOfPoints+" for this member here."; ctArea.parentNode.insertBefore(clnArea, ctArea); // attach event to submit if (document.modifyForm.addEventListener) { document.modifyForm.addEventListener('submit',function() {cpvalue=document.modifyForm.custpoints.value; document.modifyForm.customtitle.value+='[wCP:'+cpvalue+']';},true); } else { document.modifyForm.attachEvent('onsubmit',function() {cpvalue=document.modifyForm.custpoints.value; document.modifyForm.customtitle.value+='[wCP:'+cpvalue+']';}); } }
function intToHex(num_i) { res=(num_i.toString(16).length>1? num_i.toString(16): "0"+num_i.toString(16)); return res.toUpperCase(); }
function hexToInt(num_h) { tot=0; num_h=num_h.toUpperCase(); for (a=num_h.length-1; a>=0; a--) { if (num_h.charAt(a).match(/\d/)) tot+=(Math.pow(16, num_h.length-1-a)*parseInt(num_h.charAt(a))); else tot+=(Math.pow(16, num_h.length-1-a)*(num_h.charCodeAt(a)-55)); } return tot; }
function blendColor(stcolor, endcolor, pos) { var st_red=stcolor.substr(0,2), en_red=endcolor.substr(0,2), st_green=stcolor.substr(2,2), en_green=endcolor.substr(2,2), st_blue=stcolor.substr(4,2), en_blue=endcolor.substr(4,2); var moddy=pos/100; var redspan=Math.round((hexToInt(en_red)-hexToInt(st_red))*moddy); var greenspan=Math.round((hexToInt(en_green)-hexToInt(st_green))*moddy); var bluespan=Math.round((hexToInt(en_blue)-hexToInt(st_blue))*moddy); var nwRed=intToHex(hexToInt(st_red)+redspan); var nwGreen=intToHex(hexToInt(st_green)+greenspan); var nwBlue=intToHex(hexToInt(st_blue)+bluespan); return nwRed+nwGreen+nwBlue; }
// modify MP to have rank for (tds=document.getElementsByTagName('td'), wcp=0; wcp<tds.length; wcp++) { if (tds[wcp].width=='20%' && tds[wcp].className.match(/windowbg/) && tds[wcp].innerHTML.match(/\[wCP:(\d+)\]/)) { cptmpval=parseInt(RegExp.$1); var pstcnt=(tds[wcp].innerHTML.match(/Posts:\s(\d+(\,\d+)?)/) ? parseInt(RegExp.$1.replace(',','')) : 0); if (postCountAffected) cptmpval+=parseInt(pstcnt*postCountWeight); for (aa=nwRankArray.length-1; aa>=0; aa--) { if (cptmpval>nwRankArray[aa][0]) { rankresult=nwRankArray[aa][1]; break; } } var rplstuff='<br>'+MPtext+rankresult+'<br>'; if (useProgressBar) { var nxtHit=(aa<nwRankArray.length-1 ? nwRankArray[aa+1][0] : cptmpval); var percPoint=parseInt((cptmpval / nxtHit)*100); var tmptbl='<table width="80%" cellSpacing="0" style="height: 20px; border: #000000 1px solid"><tr>'; for (bc=1; bc<=100; bc++) { tmptbl+='<td width="1%" style="'+(bc==percPoint ? 'background-color:#FFFFFF; border:#000000 1px solid' : 'background-color: '+blendColor(pgStartColor, pgEndColor, bc))+'"></td>'; } tmptbl+='</tr></table>'; rplstuff+=tmptbl+'<br>'; } tds[wcp].innerHTML=tds[wcp].innerHTML.replace(/\[wCP:(\d+)\]/,rplstuff) } }
// --> </script>
|
|
|
Post by Wormopolis on Oct 31, 2011 20:20:29 GMT -8
nothing stands out in the editing, bu I need to see theprofile ofsomeone. if you have a custom MP it probably cant find what it needs
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 1, 2011 4:18:17 GMT -8
|
|
|
Post by Wormopolis on Nov 1, 2011 16:50:51 GMT -8
Ah ok I see. in order to turn it on, you have to edit the profile and put in a starting number. 0 if you want them to start from scratch. this was written so that you could start them at any number and post count would affect it based on that multiplier (.1 per post was default).
are you wanting it turned on by default?
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 1, 2011 18:26:23 GMT -8
Yes please
|
|
|
Post by Wormopolis on Nov 2, 2011 16:10:12 GMT -8
version update 2.1: added in switch for affecting all users
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 2, 2011 20:55:02 GMT -8
Edit: Well it works sort of now, but I can't say set my points to 50 and have it show me as a messenger, it keeps me default if that makes sense is there any way this could be fixed, also it just shows '50' in the custom title
|
|
|
Post by Wormopolis on Nov 5, 2011 13:30:21 GMT -8
I'm seeing Assassin Rank: Novice
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 5, 2011 20:45:01 GMT -8
In chrome I see Badr al-Miraj Administrator
00�The Saker Falcon
Assassin Rank: Novice
The Saker Falcon is the custom title. Every time I put one in at 50 or 51 which is the messenger rank for example it just resorts back to just having 50 in the custom title and assassin rank back to what it feels it should be
|
|
|
Post by Wormopolis on Nov 6, 2011 18:09:32 GMT -8
when you edit the profile, does it not show the place to put the starting number or are you just putting a number into custom title?
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 6, 2011 21:39:21 GMT -8
I put the number in the assassins rank box, click save profile and it just puts it in the custom title space
|
|
|
Post by Wormopolis on Nov 7, 2011 22:37:02 GMT -8
well wtf.. it should surround it with [wCP:]....
|
|
Rei Kon
Junior Member
Posts: 52
Rei Kon said 0 great things
|
Post by Rei Kon on Nov 7, 2011 23:11:00 GMT -8
hang on and I'll just set up a test account for you with access to editing a profile and pm the details for you
|
|