|
Post by Wormopolis on Mar 24, 2010 9:07:06 GMT -8
Browser Tested: IE and FF placement: Global Footer (if you have a MP remodel, this should go above it) lets your members create a new character at certain post counts that will "grow" with the post count from that point on. The older characters will be more powerful. Currently supports "Strength" and "Defense" but a mod could be made to add in more stats. Once a character has been created, it can be "linked" to a specific post that is a bio of the character. staff with ability to edit custom title have access to the character editor which allows for editing character data or deletion. <style type="text/css"> .newcharbox {border-color: FFFF00; border-style: solid; background-color:000000; color:FF0000;} .charnames {background-color: 222222; color: FF0000; font-weight: bold;} .charstrengths {background-color: 222222; color: 0000FF; font-weight: bold;} .chardefenses {background-color: 222222; color: 00FF99; font-weight: bold;} .chartitle {background-color: CCCCCC;} #newcharbox {width: 40%; left: expression((ign=document.body.clientWidth*.3) + 'px'); top: expression((ign=document.body.scrollTop+document.body.clientHeight/2)+'px'); z-index: 50;} #editcharbox {width: 60%; left: expression((ign=document.body.clientWidth*.2) + 'px'); top: expression((ign=document.body.scrollTop+document.body.clientHeight/6)+'px'); z-index: 51;} </style>
<div id="newcharbox" align="center" style="display: none"><table width="100%" class="bordercolor" cellpadding=1 cellspacing=0><tr><td><table cellspacing=1 cellpadding=1 height="50px" width="100%"><tr><td class="titlebg" colspan=3><center>Create New Character</center></td></tr><tr><td class="windowbg" width="25%" valign="middle" align="center">Class:<br><select><option value=''>Choose Class</option></select></td><td class="windowbg2" width="50%" valign="middle" align="center">Name:<br><input style="height:18px; width:90%;" value="Enter name"></td><td class="windowbg" width="25%" valign="middle" align="center">Alignment:<br><select><option value=''>Choose Alignment</option></select></td></tr><tr><td colspan=3 class="titlebg" align="center"><input type="button" onclick="this.disabled=true; addCharNow();" value="submit"></td></tr></table></td></tr></table></div>
<div id="editcharbox" align="center" style="display: none"><table width="100%" class="bordercolor" cellpadding=1 cellspacing=0><tr><td><table cellspacing=1 cellpadding=1 height="50px" width="100%"><tr><td class="titlebg" colspan=5><center>Edit Character</center></td></tr><tr> <td class="windowbg" width="10%" valign="middle" align="center">Start Posts:<br><input style="height:18px; width:90%" ></td> <td class="windowbg" width="20%" valign="middle" align="center">Class:<br><select><option value=''>Choose Class</option></select></td> <td class="windowbg2" width="40%" valign="middle" align="center">Name:<br><input style="height:18px; width:90%;" value="name"></td> <td class="windowbg" width="20%" valign="middle" align="center">Alignment:<br><select><option value=''>Choose Alignment</option></select></td> <td class="windowbg" width="10%" valign="middle" align="center">Post Link:<br>board: <input style="height:18px; width:90%;"><br>thread: <input style="height:18px; width:90%;"><br>post: <input style="height:18px; width:90%;"></td></tr><tr><td colspan=5 class="titlebg" align="center"><input type="button" onclick="editCharNow(); document.getElementById('editcharbox').style.display='none';" value="submit"><input type="button" onclick="document.getElementById('editcharbox').style.display='none';" value="cancel"> (to delete a character, erase the name)</td></tr></table></td></tr></table></div>
<script type="text/javascript"> <!-- // Characters w stats earned by post count v1.1 // Concept by stockholmsyndrome // By Wormopolis - www.wormocodes.com // Do not repost - keep header intact
// VARIABLES TO EDIT
var postCountToEarnNewChars=[1, 100, 500, 1000, 2000]; var StrengthPerPostCount = 1; var DefensePerPostCount = 1.5;
var disablePersonalText=true; //keeps PT from overwriting characters var displayAlignmentCell=false;
var plusSignImage="http://www.clker.com/cliparts/9/9/9/8/1197114493409022005enki_enki.svg.med.png";
var alignmentArray=[ // alignment name, image it shows ["evil","http://i740.photobucket.com/albums/xx47/saphira5910/126813-simple-black-square-icon-cul.png"], ["neutral","http://i740.photobucket.com/albums/xx47/saphira5910/imagestruce.jpg"], ["good","http://i740.photobucket.com/albums/xx47/saphira5910/126814-simple-black-square-icon-cul.png"] ];
var classArray=[ ["fighter","FF0000"], //class name, color it shows in MP ["wizard","FF00FF"], ["thief","CCCC00"], ["poet","00DDDD"] ];
// END USER VARIABLES
if (location.href.match(/action=(viewprofile|display|recent|userecentposts)/) || pb_action=='search2') { for (tds=document.getElementsByTagName('td'), t=0; t<tds.length; t++) { if (tds[t].width=='20%' && tds[t].className.match(/windowbg/) && tds[t].vAlign=='top') { cpostCount=0; uname=''; if (tds[t].getElementsByTagName('b')[0] && tds[t].getElementsByTagName('b')[0].getElementsByTagName('a')[0]) { pers=tds[t].getElementsByTagName('b')[0].getElementsByTagName('a')[0]; if (pers.href.match(/user=(.*?)$/)) { uname=RegExp.$1; if (tds[t].innerHTML.match(/Posts: (.*?)<br>/i)) { cpostCount=parseInt(RegExp.$1.replace(/,/g,'')); if (uname==pb_username) document.cookie='cpostcount='+cpostCount; } } cspace=tds[t].getElementsByTagName('center')[0]; ccount=0; while (cspace.innerHTML.match(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/)) { ccount++; cname=RegExp.$2; cstart=RegExp.$1; calign=RegExp.$4; cclass=RegExp.$3; bname=RegExp.$6; tnum=RegExp.$7; pnum=RegExp.$8;
cspace.innerHTML= cspace.innerHTML.replace(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/,''); ctbl=(cspace.lastChild.nodeName.match(/table/i) ? cspace.lastChild : cspace.appendChild(document.createElement('table'))); ctbl.width='100%'; //4642538 nwtbl=ctbl.cloneNode(true); if (nwtbl.rows.length==0) { nrow=nwtbl.insertRow(0); nrow.insertCell(0); nrow.insertCell(0); nrow.insertCell(0); nrow.insertCell(0); nrow.cells[0].width="4%"; nrow.cells[0].className="chartitle"; nrow.cells[0].style.display=(displayAlignmentCell ? '' : 'none'); nrow.cells[1].width="60%"; nrow.cells[1].className="chartitle"; nrow.cells[2].width="18%"; nrow.cells[2].className="chartitle"; nrow.cells[3].width="18%"; nrow.cells[3].className="chartitle"; nrow.cells[0].innerHTML="Align"; nrow.cells[1].innerHTML="Name"; nrow.cells[2].innerHTML="Strength"; nrow.cells[3].innerHTML="Defense"; } nrow=nwtbl.insertRow(-1); nrow.insertCell(0); nrow.insertCell(0); nrow.insertCell(0); nrow.insertCell(0); nrow.cells[0].width="4%"; nrow.cells[0].className="charnames"; nrow.cells[0].vAlign='middle'; nrow.cells[0].style.display=(displayAlignmentCell ? '' : 'none'); nrow.cells[1].width="60%"; nrow.cells[1].className="charnames"; nrow.cells[1].vAlign='middle'; nrow.cells[2].width="18%"; nrow.cells[2].className="charstrengths"; nrow.cells[2].vAlign='middle'; nrow.cells[3].width="18%"; nrow.cells[3].className="chardefenses"; nrow.cells[3].vAlign='middle'; nrow.cells[0].innerHTML=(calign ? '<img src="'+alignmentArray[calign][1]+'" height="30" width="30">' : ''); tnumL=(location.href.match(/thread=(\d+)(&|$)/) ? RegExp.$1 : 'invalid'); pnumL=(location.href.match(/thread=(\d+)/) ? tds[t].firstChild.name : 'invalid'); bnumL=(location.href.match(/board=(.*?)&/) ? RegExp.$1 : 'invalid'); threadadd=(uname==pb_username && location.href.match(/thread=/) ? '<img src="'+plusSignImage+'" height="10" width="10" style="background-color: 111111" onclick= "location.href=\'/index.cgi?action=modifyprofile&user='+ pb_username+'&addcharthread='+ (bnumL+'%20'+tnumL+'%20'+pnumL)+'&addtochar='+ cname+'\'" alt="Attach post to this character" title="Attach post to this character" >' : ''); nrow.cells[1].innerHTML=(bname ? '<a class="charnames" href="/index.cgi?action=gotopost&board='+bname+'&thread='+tnum+'&post='+pnum+'">' : '') + '<font color="'+ classArray[cclass][1] +'" title="'+classArray[cclass][0]+'">' + cname + '</font>' + (bname ? '</a>' : threadadd); nrow.cells[2].innerHTML=(cpostCount>cstart ? parseInt((cpostCount-cstart)*StrengthPerPostCount ) : 0); nrow.cells[3].innerHTML=(cpostCount>cstart ? parseInt((cpostCount-cstart)*DefensePerPostCount ) : 0); ctbl.parentNode.replaceChild(nwtbl,ctbl);
} // check to see if new char can be added if (cpostCount>=postCountToEarnNewChars[ccount] && uname==pb_username) { ctbl=(cspace.lastChild.nodeName.match(/table/i) ? cspace.lastChild : cspace.appendChild(document.createElement('table'))); nrow=ctbl.insertRow(-1); nrow.insertCell(0); nrow.cells[0].className="newcharbox"; nrow.cells[0].colSpan=ctbl.rows.length>1 ? (displayAlignmentCell ? 4 : 3) : 1; nrow.cells[0].align="center"; nrow.cells[0].style.cursor="pointer"; nrow.cells[0].onclick=function() {window.location='/index.cgi?action=modifyprofile&user='+pb_username+'&newchar';}; nrow.cells[0].innerHTML="<a href='/index.cgi?action=modifyprofile&user="+pb_username+"&newchar' >YOU HAVE EARNED A NEW CHARACTER</a>"; } } } } } if (document.modifyForm) { cb=document.getElementById('newcharbox'); cb.style.position=(document.all ? 'absolute' : 'fixed'); cb.style.top=((document.body.scrollTop+document.body.clientHeight/2)+'px'); cb.style.left=((document.body.clientWidth*.3) + 'px'); ecb=document.getElementById('editcharbox'); ecb.style.position=(document.all ? 'absolute' : 'fixed'); ecb.style.top=((document.body.scrollTop+document.body.clientHeight/6)+'px'); ecb.style.left=((document.body.clientWidth*.2) + 'px'); ddowns=cb.getElementsByTagName('select'); eddowns=ecb.getElementsByTagName('select'); for (c=0; c<classArray.length; c++) { tmpOpt=document.createElement('option'); tmpOpt.value=c; tmpOpt.innerHTML=classArray[c][0]; ddowns[0].appendChild(tmpOpt); eddowns[0].appendChild(tmpOpt.cloneNode(true)); } for (a=0; a<alignmentArray.length; a++) { tmpOpt=document.createElement('option'); tmpOpt.value=a; tmpOpt.innerHTML=alignmentArray[a][0]; ddowns[1].appendChild(tmpOpt); eddowns[1].appendChild(tmpOpt.cloneNode(true)); } if (location.href.match(/newchar/)) { cb.style.display=''; hideit=modifyForm.parentNode.parentNode.parentNode.parentNode.parentNode; hideit=hideit.parentNode.parentNode.parentNode.parentNode.parentNode; hideit.style.display="none"; if (modifyForm.password) modifyForm.password.value=''; } modifyForm.personaltext.storeit=''; ccount=0; while (modifyForm.personaltext.value.match(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/)) { ccount++; modifyForm.personaltext.storeit+=' ['+RegExp.$1 + ':'+RegExp.$2+ ':'+RegExp.$3+ ':'+RegExp.$4+ (RegExp.$6 ? '%'+RegExp.$6 + ' ' + RegExp.$7 + ':' + RegExp.$8 : '' ) + ']'; modifyForm.personaltext.value= modifyForm.personaltext.value.replace(/\s*?\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/,''); } if (disablePersonalText) { if (!modifyForm.customtitle) modifyForm.personaltext.disabled=true; modifyForm.personaltext.style.backgroundColor='DDDDDD'; modifyForm.personaltext.parentNode.parentNode.nextSibling.firstChild.firstChild.nodeValue = "Personal Text has been disabled"; } if (modifyForm.customtitle) { ctrw=modifyForm.customtitle.parentNode.parentNode.parentNode; nwrw=ctrw.cloneNode(true); cls=nwrw.getElementsByTagName('td'); cls[0].firstChild.innerHTML="Characters:"; cls[1].firstChild.innerHTML=(ccount>0 ? '<input type="button" onclick="ecb=document.getElementById(\'editcharbox\'); ecb.style.display=\'\';" value="Edit">' : ''); cls[2].firstChild.innerHTML="Member has "+ccount+" characters."; ctrw.parentNode.insertBefore(nwrw, ctrw.nextSibling); erow=ecb.getElementsByTagName('input')[0].parentNode.parentNode; ecount=ccount; tmpstoreit=modifyForm.personaltext.storeit; while (ecount>0) { imps=erow.getElementsByTagName('input'); drps=erow.getElementsByTagName('select'); if (tmpstoreit.match(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/)) { imps[0].value=RegExp.$1; imps[1].value=RegExp.$2; imps[2].value=RegExp.$6; imps[3].value=RegExp.$7; imps[4].value=RegExp.$8; drps[0].selectedIndex=(RegExp.$3=='' ? 0 : parseInt(RegExp.$3)+1); drps[1].selectedIndex=(RegExp.$4=='' ? 0 : parseInt(RegExp.$4)+1); tmpstoreit=tmpstoreit.replace(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/,''); ecount--; if (ecount>0) { nwrw=erow.cloneNode(true); erow.parentNode.insertBefore(nwrw, erow.nextSibling); erow=nwrw } } } }
function putback() { modifyForm.personaltext.disabled=false; while (modifyForm.personaltext.storeit && modifyForm.personaltext.storeit.match(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/)) { modifyForm.personaltext.value+=' ['+RegExp.$1+':'+RegExp.$2+':'+RegExp.$3+':'+RegExp.$4+(RegExp.$6 ? '%'+RegExp.$6 + ' ' + RegExp.$7 + ':' + RegExp.$8 : '' ) + ']'; modifyForm.personaltext.storeit=modifyForm.personaltext.storeit.replace(/\[(\d+):(.*?):(\d+)?:(\d+)?(\%(.*?)\s(\d+):(\d+))?\]/,''); } }
function addCharNow() { if (document.cookie.match(/cpostcount=(\d+)/)) pcnt=RegExp.$1; cb=document.getElementById('newcharbox'); ddowns=cb.getElementsByTagName('select'); inp=cb.getElementsByTagName('input'); if (pcnt) { keepstring=' ['+pcnt+':'+inp[0].value+':'+ddowns[0].options[ddowns[0].selectedIndex].value+':'+ddowns[1].options[ddowns[1].selectedIndex].value+']'; if (!modifyForm.personaltext.storeit) modifyForm.personaltext.storeit=''; modifyForm.personaltext.storeit+=keepstring; } if (modifyForm.password) modifyForm.password.value=''; putback(); modifyForm.submit(); }
function editCharNow() { if (!document.modifyForm || !document.modifyForm.customtitle) return 0; ecb=document.getElementById('editcharbox'); modifyForm.personaltext.storeit=''; for (wr=ecb.getElementsByTagName('input')[0].parentNode.parentNode.parentNode.parentNode.rows, w=1; w<wr.length-1; w++) { ddowns=wr[w].getElementsByTagName('select'); inp=wr[w].getElementsByTagName('input'); keepstring=' ['+inp[0].value+':'+inp[1].value+':'+ddowns[0].options[ddowns[0].selectedIndex].value+':'+ddowns[1].options[ddowns[1].selectedIndex].value; keepstring+=(inp[2].value ? '%' + inp[2].value + ' ' + inp[3].value + ':' + inp[4].value : ''); keepstring+=']'; if (inp[1].value) modifyForm.personaltext.storeit+=keepstring; } if (modifyForm.password) modifyForm.password.value=''; putback(); modifyForm.submit(); }
if (document.addEventListener) { modifyForm.addEventListener('submit',putback,false); } else { modifyForm.attachEvent('onsubmit',putback); }
if (location.href.match(/addcharthread=(.*?)&addtochar=(.*?)$/)) { charname=RegExp.$2; postStuff=RegExp.$1.split(/%20/); hideit=modifyForm.parentNode.parentNode.parentNode.parentNode.parentNode; hideit=hideit.parentNode.parentNode.parentNode.parentNode.parentNode; hideit.style.display="none"; if (confirm("Do you want to attach that thread to character "+charname+"?")) { hold=modifyForm.personaltext.storeit.split('['); for (h=0; h<hold.length; h++) { if (hold[h].match(charname)) { tmp=hold[h].split(']')[0]; hold[h]=tmp+'%'+postStuff[0] + ' ' + postStuff[1] + ':' + postStuff[2] + ']'; } } modifyForm.personaltext.storeit=hold.join('['); if (modifyForm.password) modifyForm.password.value=''; putback(); modifyForm.submit(); } else { location.href="/index.cgi?action=gotopost&board="+postStuff[0]+"&thread="+postStuff[1]+"&post="+postStuff[2]; } }
}
// --> </script>
Preview: When a member has earned the right to create a character he will see this in his MP when he clicks the box, it will take him to this screen where he can name his character and choose alignment and class. after creating character, this will be seen in his MP. if alignments are turned on, the alignment is shown to the left of the character name. hovering over the name also show the character class. to link the character name to a specific post, member just finds the post and there will be a + sign next to the name. click the + sign and it will verify linking the post. then the name will be clickable and take everyone directly to that post (for character bios) the admin will be able to edit characters via this button under custom title. it also states how many characters the member has. clicking the edit button will bring up the character editor.
|
|
|
Post by Wormopolis on Apr 6, 2010 0:56:13 GMT -8
so I was thinking about beefing this up some. currently, it supports 2 stats, strength and defense based off post count. It shows those stats right next to the name. the alignment shows up to the left of the name as an image, and the class will show up if you hover over the character name. what if we mixed that up a bit... we could add in an array of multiple stats, based off post count AND karma. as many as you wanted. statsArray=[ ['Strength',0.5,1.5], ['Defense',0.75, 1.5], ['Charisma',0.25,2.5], ['Intelligence',1.5,0.25] ]; you can add more into the array easily. the first number would be the multiplier of post counts, the second the multiplier of karma. just put a 0 if you didnt want post count/karma to affect the stat. Karma of course would still be global like post count, but karma could also be snapshot saved like post count is when a character is created. if the member gains karma, all his characters do as well, but the older characters would have a smaller starting point. since karma can go negative, the stats COULD be affected negatively then (wont drop below 0 however). what if we had it like: and when you hovered or clicked on stats, it popped up a little box with ALL the rpg stats. the character name would still be clickable and go to whatever post was attached to it. Any thoughts?
|
|
jsay
Not New Member
Posts: 8
jsay said 0 great things
|
Post by jsay on Mar 14, 2011 13:49:26 GMT -8
ok so i had problems at the begining with it not showing up so that i could creat a chacter. i fixed it but now its not letting me make it it takes me 2 the edit acc page and nothign after that plz help me
|
|
|
Post by Wormopolis on Mar 14, 2011 18:35:07 GMT -8
Need to see a URL to see what all else you got running. if another code is hijacking the submit button, it wont use the right form.
try putting this code at very bottom of global footer to start with.
|
|