|
Post by Wormopolis on Apr 18, 2009 4:47:51 GMT -8
Browser tested: IE and FF placement: board or global footer.
Converts a poll into a contest entry form where the user just has to click a button to enter.
users with access to view poll voters will be able to see the results. variables for turning off total entries, and custom buttons.
users in allowed list will see instructions on how to convert poll to contest in the create poll form.
knoiwn bugs: selecting the checkbox for allowing ppl to change their vote will cause this script to bug. working on a fix for that. locking a poll makes it so the script has no way of knowing if the user has already entered or not. that cannot be fixed.
code:
<script type="text/javascript"> <!-- // convert poll into "click to enter" form. // v 1.0 // by Wormopolis - wormocodes.proboards.com // keep header intact - do not repost
//EDIT THESE VARIABLES var showContestEntriesTotal=true; var whoCanCreateContests = /^(admin|user1|user2|wormopolis)$/; var alreadyEnteredMessage = "You are already entered in this contest!"; var noLongerAcceptingMsg = "This contest is closed to new participants. sorry";
var lockContestBtnImg="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/lock_ent.gif"; var viewContestEntriesBtnImg="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/view_ent.gif"; //--------------------
for (tds=document.getElementsByTagName('td'), i=0; i<tds.length; i++) { if (tds[i].align=="left" && tds[i].className=="catbg" && tds[i].vAlign=="bottom" && tds[i].width=="20%" && tds[i].firstChild && tds[i].firstChild.firstChild && tds[i].firstChild.firstChild.nodeName.match(/img/i) && tds[i].firstChild.firstChild.alt.match(/poll/)) {
if (tds[i].parentNode.nextSibling.getElementsByTagName('table')[0].rows[1].cells[0].innerHTML.match(/\[contest\]/i) && tds[i].parentNode.nextSibling.getElementsByTagName('table')[0].rows[2].cells[0].innerHTML.match(/\[contest\]/i)) {
marks=tds[i].parentNode.nextSibling.getElementsByTagName('input'); donechecked=false; lckedpl=(tds[i].firstChild.firstChild.alt.match(/locked/i)); for (j=0; j<marks.length; j++) { if (marks[j].type=="radio") { if (!donechecked) marks[j].checked=true; marks[j].parentNode.parentNode.style.display="none"; } if (marks[j].type=="submit") { marks[j].value="ENTER ME!"; marks[j].parentNode.align="center"; tst=marks[j].parentNode.parentNode.cells[1]; tst.align="right"; if (tst.innerHTML.match(/img/i)) { for (fximg=tst.getElementsByTagName('img'), k=0; k<fximg.length; k++) { if (fximg[k].alt=="[Lock Poll]") fximg[k].src=lockContestBtnImg; if (fximg[k].alt=="[View Poll Voters]") fximg[k].src=viewContestEntriesBtnImg;
} } marks[j].parentNode.colSpan=2; marks[j].parentNode.parentNode.nextSibling.cells[0].colSpan=1; marks[j].parentNode.parentNode.nextSibling.appendChild(tst); if (marks[j].parentNode.parentNode.nextSibling.cells[0].innerHTML.match(/voters: (\d+)/i)) { nm=RegExp.$1; marks[j].parentNode.parentNode.nextSibling.cells[0].getElementsByTagName('b')[0].style.display="none"; marks[j].parentNode.parentNode.nextSibling.cells[0].getElementsByTagName('table')[0].style.display="none"; entriesTotal=document.createElement('b'); entriesTotal.appendChild(document.createTextNode((showContestEntriesTotal ? "ENTRIES TOTAL: "+nm : ""))); marks[j].parentNode.parentNode.nextSibling.cells[0].appendChild(entriesTotal); } } } tds[i].firstChild.firstChild.nextSibling.nextSibling.innerHTML="Entry Form"; tds[i].nextSibling.innerHTML=tds[i].nextSibling.innerHTML.replace(/poll question/i,"Contest"); if (tds[i].parentNode.nextSibling.getElementsByTagName('input').length==0) { wrktbl=tds[i].parentNode.nextSibling.getElementsByTagName('table')[0]; for (m=wrktbl.rows.length-2; m>0; m--) { wrktbl.rows[m].style.display="none"; if (wrktbl.rows[m].getElementsByTagName('a').length) { wrktbl.rows[wrktbl.rows.length-1].appendChild(wrktbl.rows[m].cells[1]); wrktbl.rows[wrktbl.rows.length-1].cells[0].colSpan=1; tst=wrktbl.rows[wrktbl.rows.length-1].cells[1]; tst.align="right"; for (fximg=tst.getElementsByTagName('img'), k=0; k<fximg.length; k++) { if (fximg[k].alt=="[Lock Poll]") fximg[k].src=lockContestBtnImg; if (fximg[k].alt=="[View Poll Voters]") fximg[k].src=viewContestEntriesBtnImg;
} } } nwRw=wrktbl.insertRow(0); nwCl=nwRw.insertCell(0); nwCl.colSpan=2; nwCl.align="center"; nwCl.className="windowbg2"; nwMsg=document.createElement('b'); nwMsg.appendChild(document.createTextNode((lckedpl ? noLongerAcceptingMsg : alreadyEnteredMessage))); nwCl.appendChild(nwMsg); if (wrktbl.innerHTML.match(/voters: (\d+)/i)) { nm=RegExp.$1; wrktbl.rows[wrktbl.rows.length-1].cells[0].getElementsByTagName('b')[0].style.display="none"; wrktbl.rows[wrktbl.rows.length-1].cells[0].getElementsByTagName('table')[0].style.display="none"; entriesTotal=document.createElement('b'); entriesTotal.appendChild(document.createTextNode((showContestEntriesTotal ? "ENTRIES TOTAL: "+nm : ""))); wrktbl.rows[wrktbl.rows.length-1].cells[0].appendChild(entriesTotal); }
} } } if (location.href.match(/createpoll/) && pb_username.match(whoCanCreateContests) && tds[i].align=="right" && tds[i].className=="windowbg" && tds[i].width=="30%" && tds[i].nextSibling.innerHTML.match(/answer-1/)) { tds[i].align="center"; tds[i].valign="middle"; ckbx=document.createElement('input'); ckbx.type="checkbox"; tmpmsg=document.createTextNode("SET ANSWER 1 and ANSWER 2 to be '[contest]' if you want to make this poll into a contest entry. Set the Poll Question to be the name of the contest"); tds[i].appendChild(tmpmsg); } }
// --> </script>
preview: comign soon
version update: coming soon - 1 click to convert poll to contest from createpoll screen.
|
|
marlis
Not New Member
Posts: 6
marlis said 0 great things
|
Post by marlis on Sept 19, 2009 1:42:49 GMT -8
Would it be possibel to change the entries into a poll afterwards. So there names apair to vote on once it is locked?
We do photo contest on our sight, so the members entering would also post the photo they want to enter.
Thanks.
|
|
|
Post by Wormopolis on Sept 19, 2009 3:36:58 GMT -8
except it would show everyone voting for the same option... and their names would only appear to members with that access from the usergroup definition.
In your situation, I would create a thread where anyone who wants to submit a photo would do so in that thread. When you decide no more entries will be allowed, THEN create a poll that lists all the entries. I believe it only allows 20 choices however.
I can see what you are wanting, but it isnt possible to change the poll choices once it has been created.
|
|
marlis
Not New Member
Posts: 6
marlis said 0 great things
|
Post by marlis on Sept 19, 2009 5:11:16 GMT -8
OK, thanks, Yeh, that is more or less the way we have been doing it. Thanks though.
|
|