|
Post by Wormopolis on Feb 23, 2009 20:16:18 GMT -8
Browser tested: IE and FF placement: global footer
Places a button in someone's mini-profile that lets you challenge them to a fight. Lets you put place and time, and customize backgrounds.
mods made if necessary. This is version 2.
2 variables at the top: FCprofileShow and FCboardsShow determine where fight button is displayed in MiniProfile. Set to true if you want to display the button.
<script type="text/javascript"> <!-- // Profile Fight Challenge // v 2.01 // By Wormopolis (wormocodes.proboards.com) // Do not repost - keep header intact
var fightBtnImg="http://i280.photobucket.com/albums/kk168/SKBundy/fight_img.gif"; var fightMsgBG="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/3174331633_25f5d37262.jpg"; var challengeMsgBG="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/fightpic.jpg"; var confirmMsgBG="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/364671877_ec05e87e8d.jpg"; var declineMsgBG="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/211482969_1417bbf19a.jpg"; var acceptMsgBG="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/699065304_25856850d9.jpg";
var FCprofileShow=true; //show challenge button in profile view var FCboardsShow=true; //show challenge button in miniprofile in boards
// place link to challenge form tds=document.getElementsByTagName('td'); for (d=0; d<tds.length; d++) { if (tds[d].className.match(/windowbg/) && tds[d].width=="20%" && tds[d].vAlign=="top" && tds[d].getElementsByTagName('b')[0] && tds[d].getElementsByTagName('b')[0].firstChild && tds[d].getElementsByTagName('b')[0].firstChild.className.match(/group/i)) { if ((FCprofileShow && location.href.match(/tion=viewprofile/i)) || (FCboardsShow && location.href.match(/board=/i))) { challenged=tds[d].getElementsByTagName('b')[0].firstChild.href.split("user=")[1]; challenged2=tds[d].getElementsByTagName('b')[0].firstChild.innerHTML; nwDiv=document.createElement('div'); nwDiv.vAlign="bottom"; nwBtn=document.createElement('img'); nwBtn.src=fightBtnImg; nwBtn.border="0"; nwLnk=document.createElement('a'); nwLnk.href="index.cgi?action=pmsend&to="+challenged+"&fight="+escape(challenged2); nwLnk.appendChild(nwBtn); nwDiv.appendChild(nwLnk); tds[d].appendChild(nwDiv); } } }
// create challenge form if (location.href.match(/fight=/i) && document.postForm) { fc=document.postForm.parentNode.getElementsByTagName('table')[0]; fcr=fc.getElementsByTagName('tr'); document.postForm.subject.value="YOU HAVE BEEN CHALLENGED"; for (a=1; a<fcr.length-1; a++) { fcr[a].style.display="none"; } fcr[a].getElementsByTagName('font')[0].style.display="none"; btns=fcr[a].getElementsByTagName('input'); btns[1].value="SEND CHALLENGE!"; function challPost() { plcData=document.getElementById('plc').value; tmData=document.getElementById('tm').value; msgData=document.getElementById('msg').value; if (plcData=="") plcData="anywhere"; if (tmData=="") tmData="anytime"; msg="{[FIGHT:"+pb_username+"::"+pb_displayname+"::"+plcData+"::"+tmData+"]}"; document.postForm.message.value=msg+'\n'+msgData; }
if (document.addEventListener) { btns[1].addEventListener("click",challPost, true); } else { btns[1].attachEvent("onclick",challPost); }
btns[2].style.display="none"; btns[3].style.display="none"; btns[4].style.display="none"; fc.cellSpacing=0; fc.cellPadding=0; fc.parentNode.parentNode.parentNode.parentNode.width="60%"; if (document.all) fc.parentNode.parentNode.parentNode.parentNode.parentNode.width="60%";
nwrw=fc.insertRow(0); nwcl=document.createElement('td'); nwcl.className="windowbg2"; nwcl.colSpan=2; nwcl.style.backgroundImage="url("+fightMsgBG+")"; dispNm=unescape(location.href.split("fight=")[1]); nwcl.innerHTML="<center><font size='4'>YOU ARE CHALLENGING<br><br>"+dispNm+"<br><br><br><table width='50%' class='windowbg'><tr><td align='right'>PLACE: <input style='width:80%' id='plc'><br><br>TIME: <input style='width:80%' id='tm'><br><br><br>MESSAGE: <textarea style='width:80%' id='msg'></textarea><br></td></tr></table></center>"; nwrw.appendChild(nwcl); }
// create response form to challenge if (location.href.match(/ion=pmview/i)) { tds=document.getElementsByTagName('td'); for (q=0; q<tds.length; q++) { if (tds[q].vAlign=="top" && tds[q].colSpan==3 && tds[q].innerHTML.match(/\{\[FIGHT\:(.*?)\:\:(.*?)\:\:(.*?)\:\:(.*?)\]\}/)) { unme=RegExp.$1; dnme=RegExp.$2; plce=RegExp.$3; tme=RegExp.$4; tds[q].removeChild(tds[q].firstChild); fmsg=tds[q].innerHTML.replace(/\{\[FIGHT\:(.*?)\:\:(.*?)\:\:(.*?)\:\:(.*?)\]\}/,''); tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none"; tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling.style.display="none"; nwrw=tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.insertRow(0); nwcl=document.createElement('td'); nwcl.style.backgroundImage="url("+challengeMsgBG+")"; nwcl.innerHTML="<center><b><font size='4' color='white'>YOU HAVE BEEN CHALLENGED BY<br><br>"+dnme+"<br><br><font size='2'>LOCATION: "+plce+"<br><br>TIME: "+tme+"<br><br>MESSAGE: "+fmsg+"<br><br><br><br><table width='100%' id='outbx'><tr><td width='50%' align='center'><input type='button' value='ACCEPT' onclick='location.href=\"/index.cgi?action=pmsend&to="+unme+"&fightverify=accept\"'></td><td align='center'><input type='button' value='DECLINE' onclick='location.href=\"/index.cgi?action=pmsend&to="+unme+"&fightverify=decline\"'></td></tr></table><br></font></font ></b></center>"; nwrw.appendChild(nwcl); if (location.href.match(/view=2/i)) document.getElementById('outbx').style.display="none"; break; } } }
// create verification form if (location.href.match(/fightverify=/i) && document.postForm) { fc=document.postForm.parentNode.getElementsByTagName('table')[0]; fcr=fc.getElementsByTagName('tr'); res=location.href.split("fightverify=")[1]; res=res.toUpperCase(); res2=res+(res.charAt(res.length-1)=="E"?"D":"ED"); document.postForm.subject.value="YOUR CHALLENGE HAS BEEN "+res2; for (a=1; a<fcr.length-1; a++) { fcr[a].style.display="none"; } fcr[a].getElementsByTagName('font')[0].style.display="none"; btns=fcr[a].getElementsByTagName('input'); btns[1].value="CONFIRM!";
function confPost() { msg="{[FIGHT:verify::"+pb_displayname+"::"+location.href.split("fightverify=")[1]+"]}";
document.postForm.message.value=msg; }
if (document.addEventListener) { btns[1].addEventListener("click",confPost, true); } else { btns[1].attachEvent("onclick",confPost); } btns[2].style.display="none"; btns[3].style.display="none"; btns[4].style.display="none"; fc.cellSpacing=0; fc.cellPadding=0; fc.width=500; fc.parentNode.parentNode.parentNode.parentNode.width="60%"; if (document.all) fc.parentNode.parentNode.parentNode.parentNode.parentNode.width="60%"; nwrw=fc.insertRow(0); nwcl=document.createElement('td'); nwcl.className="windowbg2"; nwcl.colSpan=2; nwcl.style.backgroundImage="url("+confirmMsgBG+")"; dispNm=location.href.split("fight=")[1]; res3=(res.charAt(res.length-1)=="E"? res.substring(0,res.length-1):res); nwcl.innerHTML="<center><font color='red' size='4'><br><br><br>YOU ARE "+res3+"ING THE CHALLENGE<br><br><br><br><br><br><br><br></font></center>"; nwrw.appendChild(nwcl);
} // And finally... The form for how the confirms look like if (location.href.match(/ion=pmview/i)) { tds=document.getElementsByTagName('td'); for (q=0; q<tds.length; q++) { if (tds[q].vAlign=="top" && tds[q].colSpan==3 && tds[q].innerHTML.match(/\{\[FIGHT\:verify\:\:(.*?)\:\:(.*?)\]\}/)) { dnme=RegExp.$1; ans=RegExp.$2; tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none"; tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling.style.display="none"; temp=tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; temp.parentNode.parentNode.parentNode.width="50%"; nwrw=tds[q].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.insertRow(0); nwcl=document.createElement('td'); ansMsgBG=(ans=="accept" ? acceptMsgBG : declineMsgBG); nwcl.style.backgroundImage="url("+ansMsgBG+")"; ans=ans.toUpperCase(); ans+=(ans.charAt(ans.length-1)=="E" ? "D" : "ED"); nwcl.align="right"; nwcl.innerHTML="<br><b><font size='5' color='blue' align='right'>"+dnme+" HAS "+ans+" YOUR CHALLENGE<br><br><br><br><br><br><br><br><br></font></b>" nwrw.appendChild(nwcl); break; } } }
// --> </script>
Preview: umm.. yeah.. maybe later
|
|
|
Post by Wormopolis on Feb 24, 2009 23:45:00 GMT -8
Preview pics: What the button looks like on miniprofile: pressing that button brings up the form to fill out for place and time: Submitting that form will send a PM to whoever you challenged. they will see a new PM that looks like: opening the PM they will see: if they click accept or decline, they will get a confirmation screen: after confirming, the person who challenged them will now recieve a new PM: opening that PM, they will see: (a different picture if declined) all images are customizable however.
|
|
|
Post by DangerKart on Mar 5, 2009 21:56:20 GMT -8
Haha, this cracked me up. A great and silly idea at the same time. It may actually help with any future 1v1 tourneys too.
|
|
|
Post by Wormopolis on Mar 6, 2009 4:10:16 GMT -8
bug fix for display names with a bunch of alt codes in them.
|
|
iNsPiRe
Junior Member
Graphics Specialist
Posts: 72
iNsPiRe said 0 great things
|
Post by iNsPiRe on Mar 7, 2009 23:46:38 GMT -8
I really like this code. (Is there any way to change the FIGHT to something different?)
such as RACE
Thanks for the help. (I was browsing through some proboards and found you, seems neat. Thought I would give it a shot)
I see the accepted/denied images are change-able.
|
|
|
Post by Wormopolis on Mar 8, 2009 0:23:13 GMT -8
You mean the text on the button? The button is an image.. you can change the image URL at the top to whatever image you wish!
all images are changeable as well!
|
|
iNsPiRe
Junior Member
Graphics Specialist
Posts: 72
iNsPiRe said 0 great things
|
Post by iNsPiRe on Mar 8, 2009 0:25:35 GMT -8
SORRY TO BUMP BUT THIS CODE IS AMAZING. I REALLY APPRECIATE YOUR WORK AND THIS JUST MADE MY SITE A WHOLE STEP BETTER! THANK0YOU VERY MUCH. EDIT----- THIS ONLY WORKS IN PROFILE PAGE AND NOT IN MINI-PROFILE IN POSTS? WHY IS THIS? IF ITS POSSIBLE TO DO THIS WITH THE CODE PROVIDED I WOULD APPRECIATE IT. THANKS AGAIN
|
|
|
Post by Wormopolis on Mar 8, 2009 0:29:45 GMT -8
dont worry about bumping or double posting here. I dont care that much. If it gets out of hand.. I have an automerge script I can add.
|
|
iNsPiRe
Junior Member
Graphics Specialist
Posts: 72
iNsPiRe said 0 great things
|
Post by iNsPiRe on Mar 8, 2009 0:43:23 GMT -8
Alright. Please read edit above!
That is Something tht concerns me
|
|
|
Post by Wormopolis on Mar 8, 2009 2:26:46 GMT -8
originally, it was a request to only have it show up in profile view or PM views.
I havent tested it, but see what happens if you add it to global footer instead of main footer.
|
|
iNsPiRe
Junior Member
Graphics Specialist
Posts: 72
iNsPiRe said 0 great things
|
Post by iNsPiRe on Mar 8, 2009 11:17:18 GMT -8
It repeats the process and just adds it to the Profile page still.
|
|
|
Post by Wormopolis on Mar 8, 2009 14:03:08 GMT -8
I will look.
|
|
|
Post by Wormopolis on Mar 8, 2009 14:35:59 GMT -8
version update:
Fight link now shows in ALL miniprofiles.
|
|
|
Post by DangerKart on Mar 9, 2009 16:14:31 GMT -8
Is it possible to make it admin editable? (if it isnt already)
|
|
iNsPiRe
Junior Member
Graphics Specialist
Posts: 72
iNsPiRe said 0 great things
|
Post by iNsPiRe on Mar 9, 2009 16:54:03 GMT -8
It is not admin editable. Not very hard to self edit though. Would be nice to a portion in admin for it though
|
|