|
SP Bar
May 4, 2011 16:49:21 GMT -5
Post by zetsumei on May 4, 2011 16:49:21 GMT -5
<script> <!--
var showstats=true; //show actual values below bar
if (location.href.match(/action=(display|recent|userrecentposts)/)) { td=document.getElementsByTagName('td'); for (a=0;a<td.length; a++) { if (td[a].width=='80%' && td[a].innerHTML.match(/\[SP=(.+?)\/(.+?)\]/i)) { currentsp=RegExp.$1; maxSp=RegExp.$2; if (maxSp!='') { td[a].innerHTML = td[a].innerHTML.replace(/\[SP=(.+?)\/(.+?)\]/i,healthbar(parseInt(RegExp.$1),parseInt(RegExp.$2))); a--; } } } }
function healthbar(currentSp,maxSp) { endLeftOfUpperBarGreen='<img CLSCHK src="http://i291.photobucket.com/albums/ll317/Zenjin213/vg1sgz.png" />'; endLeftOfUpperBarGrey='<img src="http://i36.tinypic.com/2cyo6lz.png" />'; middleOfUpperBarGrey='<img src="http://i36.tinypic.com/dmpp3n.png" />'; middleOfUpperBarGreen='<img CLSCHK src="http://i291.photobucket.com/albums/ll317/Zenjin213/28vyq8i.png" />'; endRightOfUpperBarGreen='<img src="http://i291.photobucket.com/albums/ll317/Zenjin213/t5rkee.png" />'; endRightOfUpperBarGrey='<img src="http://i37.tinypic.com/2n0lq40.png" />'; endLeftOfLowerBar='<img src="http://i34.tinypic.com/21jyuky.png" />'; greyBlip='<img src="http://i37.tinypic.com/2n6ugkx.png" />'; greenBlip='<img src="http://i291.photobucket.com/albums/ll317/Zenjin213/2lbj6tx.png" />'; endRightOfLowerBar='<img src="http://i291.photobucket.com/albums/ll317/Zenjin213/jzb3us.png" />'; leftEndBracket='<img style="right:-1px; position: relative; z-index:1;" src="http://i49.tinypic.com/30mq355.png" />';
hb_result="";
var maxSpBar = 16;
var healthlost = maxSp-currentsp;
blipMax=Math.floor((maxSp-1)/maxSpBar); greenBlipCnt=Math.floor((currentsp-1)/maxSpBar); greyBlipCnt=(currentsp>0 ? blipMax-greenBlipCnt : blipMax); zeroHealth= (currentsp == 0); // 16/18 if ((maxSpBar * blipMax) < currentsp && maxSp%maxSpBar!=0) { //top HB level chk='A'; greenBarCnt=(currentsp%maxSpBar==0 ? (currentsp>0 ? 16: 0) : currentsp%maxSpBar); greyBarCnt=(maxSp%maxSpBar==0 ? 16 : maxSp%maxSpBar)-greenBarCnt; //=0 remainderCnt=(blipMax==0 ? 0 : maxSpBar-greyBarCnt-greenBarCnt); //=0 leftEnd=(maxSp%maxSpBar==0 ? (currentsp==0 ? endLeftOfUpperBarGrey : endLeftOfUpperBarGreen.replace('CLSCHK',' ')) : (blipMax==0 ? leftEndBracket : endLeftOfUpperBarGreen.replace('CLSCHK','class="faded" ')) ); } else { chk='B'; remainderCnt=0; greenBarCnt=(currentsp%maxSpBar==0 ? (currentsp>0 ? 15 : 1) : currentsp%maxSpBar); greyBarCnt=(maxSp<maxSpBar ? maxSp : maxSpBar)-greenBarCnt-1; leftEnd=(currentsp%maxSpBar==0 ? (currentsp==0 ? endLeftOfUpperBarGrey : endLeftOfUpperBarGreen.replace('CLSCHK',' ')) : endLeftOfUpperBarGrey ); }
hb_result="<br><table><tr><td align='right'>"; //begin upper bar construction
hb_result+=leftEnd; for (i=0; i<remainderCnt-1; i++) hb_result += middleOfUpperBarGreen.replace('CLSCHK','class="faded" '); hb_result+=(remainderCnt>0 ? leftEndBracket : ""); for (i=0; i<greyBarCnt; i++) hb_result+=middleOfUpperBarGrey; for (i=0; i<greenBarCnt-1; i++) hb_result+=middleOfUpperBarGreen; hb_result+=(zeroHealth ? endRightOfUpperBarGrey : endRightOfUpperBarGreen) + "<br>";
//begin lower bar construction hb_result+=endLeftOfLowerBar; for (i=0; i<greyBlipCnt; i++) hb_result+=greyBlip; for (i=0; i<greenBlipCnt; i++) hb_result+=greenBlip; hb_result+=endRightOfLowerBar+"<br>";
hb_result+=(showstats ? currentsp+"/"+maxSp : '')+"</td></tr></table>";
return hb_result; } //--> </script>
|
|