|
Post by Wormopolis on Aug 6, 2010 1:41:51 GMT -8
Browser Tested: IE and FF placement: Global footer Lets you set up a points system for a limited number of groups that can be displayed in a table either in a board or main page (see notes) User defines array of group names and admin creates a new thread. a link will appear next to subject input that lets you create a new points system. Upon clicking, it will display a custom template that shows all your defined groups and inputs next to their names. You can assign points then, or just create the thread. The code looks for specific divs/spans/td with unique ids matching your group names to insert the points from the thread title. click the modify button at the top of the thread and it will bring back the inputs again where you can edit the points for each group. upon submitting, the thread will show a log of what was changed, and new points will appear in the table. variables: threadTitleReplace="House Points"; //replaces the displayed thread titleThis is what the thread title will be replaced with instead of the encoding onlyShowInBoards="board1|board2|board3";this will make it where threads can only be created in certain boards HPgroupArray=['gryffindor','hufflepuff','ravenclaw','slytherin']; //group titles. spans must match.this is the array you define group names in. the elements on the page must match these entries userswhocanseelog="admin|user2|user3";these are the members that can view the change log. only the admin can actually edit the log. *disclaimer* you only get so much space. I did some number encoding to try and shrink down the size, but if you have a lot of groups or insanely large point totals, things will get cut off. I cant do anything about that. I suggest resetting points occasionally for all groups. The log will eventually max out as well since a post can only hold 60K characters. You will need to empty it occasionally. The main page will show the last post of whatever thread was updated for each board, so if it is your points thread, I have it masking the title. If you are putting the points table on the main page, understand there is even LESS room for a thread title in that last post cell. so it most likely will fail. I suggest putting the points table in the same board as the thread will exist. code:
<script type="text/javascript"> <!-- // House Points System v1.5 // By Wormopolis - www.wormocodes.com // request by Trill // Updates a table based off a thread title, logs changes
threadTitleReplace="House Points"; //replaces the displayed thread title
onlyShowInBoards="graphreqaswell|board2|board3";
HPgroupArray=['gryffindor','hufflepuff','ravenclaw','slytherin']; //group titles. spans must match.
userswhocanseelog="admin|Guest|user3";
// no need to edit below, unless you know what you are doing
boardcheck=new RegExp('board=('+onlyShowInBoards+')($|&)',''); if (location.href.match(boardcheck) && document.postForm) { pointSpread=''; hold=postForm.subject.value; if (hold.match(/\[Þ(.*?)\]/)) { pointSpread=RegExp.$1; postForm.subject.value=hold.replace(/\[Þ(.*?)\]/,threadTitleReplace); } else if (hold.match(/\[Ð(.*?)\]/)) { pointSpread=RegExp.$1; postForm.subject.value=hold.replace(/\[Ð(.*?)\]/,threadTitleReplace); tmpPointsArray=pointSpread.split(':'); for (tt=0; tt<tmpPointsArray.length; tt++) tmpPointsArray[tt]=parseInt(tmpPointsArray[tt],36); pointSpread=tmpPointsArray.join(':'); } if (location.href.match(/&newHousePointThread/) || (!location.href.match(/action=post/) && hold.match(/\[(Þ|Ð)(.*?)\]/))) { if (location.href.match(/&newHousePointThread/)) { document.postForm.subject.value=threadTitleReplace; nwDate=new Date(); document.postForm.message.value="New "+threadTitleReplace+" Thread Created ... by "+pb_displayname+" on "+nwDate.toDateString()+"\n\n"; } pointsArray=pointSpread.split(':'); postTable=document.postForm.subject.parentNode.parentNode.parentNode.parentNode; postRows=postTable.rows; for (rr=2; rr<postRows.length-1; rr++) postRows[rr].style.display="none"; postRows[postRows.length-1].cells[0].firstChild.style.display="none"; for (imps=postRows[postRows.length-1].cells[0].getElementsByTagName('input'), ii=0; ii<imps.length; ii++) { if (imps[ii].accessKey && imps[ii].accessKey!='s') imps[ii].style.display="none"; } nwimp=document.createElement('input'); nwimp.type="button"; nwimp.value="modify log"; nwimp.onclick=function() {document.postForm.message.parentNode.parentNode.parentNode.style.display="";}; if (pb_username=='admin') postRows[postRows.length-1].cells[0].appendChild(nwimp); nwdv=document.createElement('div'); nwdv.id="pointsMod"; nwdv.appendChild(document.createElement('br')); for (p=0; p<HPgroupArray.length; p++) { nwdv.appendChild(document.createTextNode(HPgroupArray[p]+" ")); nwimp=document.createElement('input'); nwimp.id=nwimp.name="HPpointsMod_"+HPgroupArray[p]; nwdv.appendChild(nwimp); nwimp.value=(pointsArray[p] ? pointsArray[p] : '0'); nwimp.storeVal=nwimp.value; nwdv.appendChild(document.createElement('br')); } nwdv.appendChild(document.createElement('br')); nwrw=postTable.insertRow(2); nwcl=nwrw.insertCell(0); nwcl.colSpan=2; nwcl.align="center"; nwcl.className="windowbg"; nwcl.appendChild(nwdv); if (location.href.match(/thread=/)) TS=document.postForm.nextSibling.nextSibling.nextSibling, TS.style.display="none";
function HPupdatePoints() { nwPoints=document.getElementById('pointsMod').getElementsByTagName('input'); nwtitle="[Ð"; changedStuff=""; for (np=0; np<nwPoints.length; np++) { nwtitle+=parseInt(nwPoints[np].value).toString(36)+(np<(nwPoints.length-1) ? ":" : ""); if (nwPoints[np].value!=nwPoints[np].storeVal) { ch=parseInt(nwPoints[np].value) - parseInt(nwPoints[np].storeVal); changedStuff+=nwPoints[np].previousSibling.nodeValue+(ch>0 ? "+" : "")+ch+" ... "; } } nwtitle+="]"; nwDate=new Date(); if (changedStuff!="") document.postForm.message.value +="\n"+changedStuff+"by "+pb_displayname+' on '+nwDate.toDateString(); document.postForm.subject.value=nwtitle; }
if (document.addEventListener) { document.postForm.addEventListener('submit',HPupdatePoints,false); } else { document.postForm.attachEvent('onsubmit',HPupdatePoints); } } else { if (pb_username=='admin') { cl=document.postForm.subject.parentNode; cl.appendChild(document.createTextNode(' ')); nwlnk=document.createElement('a'); nwlnk.href=location.href+"&newHousePointThread"; nwlnk.innerHTML='Create '+threadTitleReplace+' Thread'; cl.appendChild(nwlnk); } } }
if (!location.href.match(/headers&footers/) && document.body.innerHTML.match(/\[(Þ|Ð)(.*?)\]/)) { for (tdsD=document.getElementsByTagName('td'), wD=tdsD.length-1; wD>0; wD--) {
if (tdsD[wD].innerHTML.match(/\[(Þ|Ð)(.*?)\]/) && !tdsD[wD].innerHTML.match(/postForm/)) { pointSpreadD=RegExp.$2; encoded=RegExp.$1; tdsD[wD].innerHTML=tdsD[wD].innerHTML.replace(/\[(Þ|Ð)(.*?)\]/,threadTitleReplace); pointsArrayD=pointSpreadD.split(':'); if (encoded=='Ð') { for (tt=0; tt<pointsArrayD.length; tt++) pointsArrayD[tt]=parseInt(pointsArrayD[tt],36); } for (p=0; p<HPgroupArray.length; p++) { if (document.getElementById(HPgroupArray[p])) document.getElementById(HPgroupArray[p]).innerHTML=pointsArrayD[p]; } if (location.href.match(boardcheck)) { if (tdsD[wD].nextSibling && tdsD[wD].nextSibling.width=='40%' && tdsD[wD].nextSibling.innerHTML.match(/quote=/)) { tdsD[wD].parentNode.nextSibling.nextSibling.style.display="none"; nwcl=document.createElement('td'); for (lnks=tdsD[wD].nextSibling.getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { if (lnks[ll].href.match(/(quote=|action=deletepost)/)) lnks[ll].style.display="none"; if (lnks[ll].href.match(/modifypost/)) nwcl.appendChild(lnks[ll--]); } hidepost=tdsD[wD].parentNode.parentNode.parentNode.parentNode.parentNode; hidepost=hidepost.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; if (!pb_username.match(new RegExp("^("+userswhocanseelog+")$",""))) hidepost.style.display="none"; if (nwcl.firstChild) { nwtbl=document.createElement('table'); nwtbl.align="center"; nwtbl.width="100%"; nwtbl.insertRow(0); nwtbl.className="bordercolor"; nwtbl.cellPadding=nwtbl.cellSpacing=0; nwtbl.rows[0].insertCell(0); nwtbl2=nwtbl.rows[0].cells[0].appendChild(document.createElement('table')); nwtbl2.insertRow(0); nwtbl2.rows[0].insertCell(0); nwtbl2.rows[0].cells[0].className="windowbg"; nwtbl2.width="100%"; nwtbl2.rows[0].cells[0].innerHTML="Click modify button to update points"; nwtbl2.rows[0].appendChild(nwcl); nwcl.className="windowbg2"; hidepost.parentNode.insertBefore(nwtbl, hidepost); } } for (ma=document.getElementsByTagName('textarea'), m=0; m<ma.length; m++) { if (ma[m].accessKey=='q') { qrtbl=ma[m].parentNode.parentNode.parentNode.parentNode.parentNode; qrtbl=qrtbl.parentNode.parentNode.parentNode.parentNode.parentNode; qrtbl.style.display="none"; } } } } } } if (document.getElementById('pointsTable')) document.getElementById('pointsTable').style.display=''; // --> </script>
preview: www.wormocodes.com/index.cgi?action=display&board=graphreqaswell&thread=713
|
|
kimz
Not New Member
Posts: 2
kimz said 0 great things
|
Post by kimz on Jun 7, 2011 23:34:49 GMT -8
What if I wanted it to work in every board? Instead of having to type in every board name? Considering I have over 100 boards. :/
|
|
|
Post by Wormopolis on Jun 8, 2011 13:58:11 GMT -8
so you want the ability to create a housepoints log in ANY board? or are you looking for the table to display in every board?
|
|
kimz
Not New Member
Posts: 2
kimz said 0 great things
|
Post by kimz on Jun 8, 2011 21:54:08 GMT -8
*thinks* If I understand the code correctly, to have points work you have to add every board that you want the points to count in? So, meaning for it to count in all boards, rather than certain boards? That or I don't get how to install it lol.
|
|
|
Post by Wormopolis on Jun 9, 2011 21:27:53 GMT -8
the board list variable is for when you want to have it be able to create a new points log. if you have a board with a table already, and the code finds a thread with the embed in the title, it should fill it.
|
|