vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Lottery System v1

Lottery System v1 - Posted By Marc (cr0w) on 24th Jan 08 at 1:41am
This code is admin editable. It adds a link to your admin area. Click on the link, and it takes you to a page with instructions. Click on one of the links, and you will have your Lottery system up and running.

Every member sees the exact same numbers, and they do not change after every new page load. Only those with access to the admin area can enable/disable the lottery system.

The Code - Edit the footer. {Smile}


Part 1: Main Header
Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Lottery System v1 by Cr0w
  5. Copyright 2008
  6. Do not repost
  7. MAIN HEADER
  8. */
  9.  
  10. xxOn="yes"
  11. xx="26"
  12. xx1="10"
  13. xx2="66"
  14. xx3="53"
  15. LotteryNumbers = "";
  16.  
  17. if(xxOn=="yes"){
  18. LotteryNumbers += '<table width="250px" cellpadding="4" cellspacing="1" align="center" class="border" id="LottoTable">';
  19. LotteryNumbers += '<tr>';
  20. LotteryNumbers += '<td class="title1" width="100%" colspan="2" align="center">';
  21. LotteryNumbers += '<font size=2><b>Winning Lotto Numbers</B></font>';
  22. LotteryNumbers += '</td>';
  23. LotteryNumbers += '</tr>';
  24. LotteryNumbers += '<tr>';
  25. LotteryNumbers += '<td width="100%" class="window2" align="center" id="LotteryTable" style="height: 30px">';
  26. LotteryNumbers += '</td>';
  27. LotteryNumbers += '</tr>';
  28. LotteryNumbers += '</table>';
  29. }
  30. document.write(LotteryNumbers);
  31. //-->
  32. </script>
 



Part 2: Main Footer
Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /*
  4. Lottery System by Cr0w
  5. Copyright 2008
  6. Do not repost
  7. MAIN FOOTER
  8. */
  9.  
  10. var HighNum="99" //Edit this to the highest number the lottery can go up to
  11.  
  12. if(location.href.match(/system\/lottery/)){
  13. document.title = document.title.replace('Modify Headers and Footers','Lottery Settings');
  14. Table = document.getElementsByTagName('Table');
  15. for(t=4;t<Table.length;t++){
  16. Table.item(t).style.display = 'none'
  17. }
  18. var x=Math.round(Math.random()*HighNum)
  19. var x1=Math.round(Math.random()*HighNum)
  20. var x2=Math.round(Math.random()*HighNum)
  21. var x3=Math.round(Math.random()*HighNum)
  22. LottoBody = '<div style="display: none">';
  23. LottoBody += '<input type="text" value="'+x+'" id="Lottonum">';
  24. LottoBody += '<input type="text" value="'+x1+'" id="Lottonum1">';
  25. LottoBody += '<input type="text" value="'+x2+'" id="Lottonum2">';
  26. LottoBody += '<input type="text" value="'+x3+'" id="Lottonum3">';
  27. LottoBody += '</div>';
  28. LottoBody += '<table border="0" cellpadding="4" cellspacing="1" class="border" width="92%" align="center">';
  29. LottoBody += '<tr>';
  30. LottoBody += '<td class="title1"><b>Lottery Settings</b></td></tr>';
  31. LottoBody += '<tr><td class="window1">Click the "Activate Lottery" button to enable the lottery system. Once you click the button, the lottery table will be displayed, along with 4 randomly selected numbers. These numbers will remain the same to everyone on your forum.<br /><br /> Once you click the "De-activate Lottery" button, the table will disappear, and will once again be displayed when you click on "Activate Lottery" again.';
  32. LottoBody += '</td></tr><tr>';
  33. LottoBody += '<td class="window1">';
  34. LottoBody += '<center><input type="button" value="Activate Lottery" onclick="LottoSave()"> <input type="button" value="De-activate Lottery" onclick="LottoOff()"></center>';
  35. LottoBody += '</td></tr></table>';
  36. document.write(LottoBody);
  37. function LottoSave(){
  38. var xxxOn= document.getElementById('LottoOn');
  39. var xxx= document.getElementById('Lottonum');
  40. var xxx1= document.getElementById('Lottonum1');
  41. var xxx2= document.getElementById('Lottonum2');
  42. var xxx3= document.getElementById('Lottonum3');
  43.  
  44. header = document.getElementsByName('header').item(0);
  45. header.value = header.value.replace(new RegExp('xxOn="'+xxOn+'"',"i"),'xxOn="yes"');
  46. header.value = header.value.replace(new RegExp('xx="'+xx+'"',"i"),'xx="'+xxx.value+'"');
  47. header.value = header.value.replace(new RegExp('xx1="'+xx1+'"',"i"),'xx1="'+xxx1.value+'"');
  48. header.value = header.value.replace(new RegExp('xx2="'+xx2+'"',"i"),'xx2="'+xxx2.value+'"');
  49. header.value = header.value.replace(new RegExp('xx3="'+xx3+'"',"i"),'xx3="'+xxx3.value+'"');
  50. document.forms.item(0).submit(true);
  51. }
  52. function LottoOff(){
  53. header = document.getElementsByName('header').item(0);
  54. header.value = header.value.replace(new RegExp('xxOn="'+xxOn+'"',"i"),'xxOn="no"');
  55. document.forms.item(0).submit(true);
  56. }
  57. }
  58. document.getElementById("LotteryTable").innerHTML = +xx+', '+xx1+', '+xx2+', '+xx3;
  59.  
  60. var div = document.getElementsByTagName('ul');
  61. for(q=0;q<div.length;q++){
  62. if(div[q].innerHTML.match(/Recycle\sBin/i)){
  63. div[q].innerHTML+='<li><a href="/action/admin/page/headers_footers/header_footer_id/-/system/lottery">Lottery System</a></li>';
  64. }}
  65. //-->
  66. </script>
 

Re: Lottery System v1 - Posted By Vanquish (scott1707) on 24th Jan 08 at 1:50am
I cant find the link in the admin panel =/

Maybe im just blind and tired... but I dont think its there.
Got a good idea on how this code can be used too {Cheesy}

Re: Lottery System v1 - Posted By Marc (cr0w) on 24th Jan 08 at 1:51am
At the bottom of "General Settings" {Wink}

Re: Lottery System v1 - Posted By Vanquish (scott1707) on 24th Jan 08 at 1:52am
Ah that would be why...

Was going to try to add it to one board only.

Re: Lottery System v1 - Posted By Marc (cr0w) on 24th Jan 08 at 1:53am
 
Ah that would be why...

Was going to try to add it to one board only.


Ahh, I'll keep that in mind for v2. {Smile} [I made this code back in 2006; I think it's time for an update. {Tongue Out} ]

Re: Lottery System v1 - Posted By dog199200 (dog199200) on 24th Jan 08 at 5:13am
so umm i suggested this like back when it was made..umm again..can you please make it so members can be inserted again if so this would be an awesome code for deciding the member of the month.

Re: Lottery System v1 - Posted By Marc (cr0w) on 24th Jan 08 at 5:41pm
Yep, that's also in the works for v2. {Smile}

Just post here if you have any other suggestions for it. {Wink}

Re: Lottery System v1 - Posted By MiNiCliP™ (miniclip238) on 20th Apr 08 at 4:58am
Oh Never Mind I Misplaced The code on The Global H/F's

So It's Resolved {Cheesy}

Re: Lottery System v1 - Posted By Marc (cr0w) on 20th Apr 08 at 4:59am
Alright, glad you got it working. {Smile}

Re: Lottery System v1 - Posted By dog199200 (dog199200) on 17th Oct 08 at 8:20am
Still planning on making an update for it Marc?

Re: Lottery System v1 - Posted By Marc (cr0w) on 20th Oct 08 at 9:47pm
v2's sitting on one of my test boards about half complete; I might toss together some loose ends and release a v1.5 sometime soon if I've got time. {Smile}

Re: Lottery System v1 - Posted By dog199200 (dog199200) on 20th Oct 08 at 10:05pm
ah ok I see, well i hope it comes together nicely

Re: Lottery System v1 - Posted By Aiken (ionfortuna) on 23rd May 10 at 6:57am
Over a year and still no v2?

Re: Lottery System v1 - Posted By dog199200 (dog199200) on 24th May 10 at 3:45am
Nope, but we are talking about Marc here, the one who openly admits to procrastination {Tongue Out}

Re: Lottery System v1 - Posted By Marc (cr0w) on 24th May 10 at 8:54pm
Posted By dog199200 on 24th May 10 at 3:45am
 
Nope, but we are talking about Marc here, the one who openly admits to procrastination {Tongue Out}


Don't forget laziness; procrastination and laziness...one dangerous combination. {Tongue Out}

But yeah, in a few weeks (when my Co-op is done and my summer officially starts) I plan to go through all of my old codes and revamp them, as well as hopefully get a few more up. {Smile}

Re: Lottery System v1 - Posted By dog199200 (dog199200) on 25th May 10 at 4:31am
Well that is nice to hear. I don't use a lot of codes here at all, all the codes I used all got replaced by the template system but it would be nice to see some new codes around since you, ross, and michael are the only people here that do any codes for the community.

Re: Lottery System v1 - Posted By Aiken (ionfortuna) on 25th May 10 at 5:36pm
I just added this code to one of my forums, I'm a code-aholic {Tongue Out}