Post by Cr0w on Jul 28, 2006 0:33:52 GMT
Previews:
I was browsing through the Code Database, and realized there was no Lottery code in it...so i decided to make one.
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 - No editting required.
Part 1: Main Header
Part 2: Main Footer
I was browsing through the Code Database, and realized there was no Lottery code in it...so i decided to make one.
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 - No editting required.
Part 1: Main Header
<script type="text/javascript">
<!--
/*
Lottery System v1 by Cr0w
Copyright 2006
Do not repost and keep this header intact
MAIN HEADER
*/
xxOn="no"
xx=""
xx1=""
xx2=""
xx3=""
if(xxOn=="yes"){
LotteryNumbers = '<table width="250px" cellpadding="4" cellspacing="1" align="center" class="bordercolor" id="LottoTable">';
LotteryNumbers += '<tr>';
LotteryNumbers += '<td class="titlebg" width="100%" colspan="2" align="center">';
LotteryNumbers += '<font size=2><b>Winning Lotto Numbers</B></font>';
LotteryNumbers += '</td>';
LotteryNumbers += '</tr>';
LotteryNumbers += '<tr>';
LotteryNumbers += '<td width="100%" class="windowbg2" vAlign="top" align="center" id="LotteryTable">';
LotteryNumbers += '</td>';
LotteryNumbers += '</tr>';
LotteryNumbers += '</table>';
}
else if(xxOn=="no"){
LotteryNumbers = '<table width="250px" cellpadding="4" cellspacing="1" align="center" class="bordercolor" id="LottoTable" style="display: none">';
LotteryNumbers += '<tr>';
LotteryNumbers += '<td class="titlebg" width="100%" colspan="2" align="center">';
LotteryNumbers += '<font size=2><b>Winning Lotto Numbers</B></font>';
LotteryNumbers += '</td>';
LotteryNumbers += '</tr>';
LotteryNumbers += '<tr>';
LotteryNumbers += '<td width="100%" class="windowbg2" vAlign="top" align="center" id="LotteryTable">';
LotteryNumbers += '</td>';
LotteryNumbers += '</tr>';
LotteryNumbers += '</table>';
}
document.write(LotteryNumbers);
//-->
</script>
Part 2: Main Footer
<script type="text/javascript">
<!--
/*
Lottery System by Cr0w
Copyright 2006
Do not repost and keep this header intact
MAIN FOOTER
*/
if(location.href.match(/system=Lottery/)){
document.title = document.title.replace('Modify Headers and Footers','Lottery Settings');
Table = document.getElementsByTagName('Table');
for(t=4;t<Table.length;t++){
Table.item(t).style.display = 'none'
}
var x=Math.round(Math.random()*7)
var x1=Math.round(Math.random()*9)
var x2=Math.round(Math.random()*3)
var x3=Math.round(Math.random()*7)
LottoBody = '<div style="display: none">';
LottoBody += '<input type="text" value="'+x+'" id="Lottonum">';
LottoBody += '<input type="text" value="'+x1+'" id="Lottonum1">';
LottoBody += '<input type="text" value="'+x2+'" id="Lottonum2">';
LottoBody += '<input type="text" value="'+x3+'" id="Lottonum3">';
LottoBody += '</div>';
LottoBody += '<table border="0" cellpadding="4" cellspacing="1" class="bordercolor" width="92%" align="center">';
LottoBody += '<tr>';
LottoBody += '<td class="titlebg"><b>Lottery Settings</b></td></tr>';
LottoBody += '<tr><td class="windowbg">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.';
LottoBody += '</td></tr><tr>';
LottoBody += '<td class="windowbg">';
LottoBody += '<center><input type="button" value="Activate Lottery" onclick="LottoSave()"> <input type="button" value="De-activate Lottery" onclick="LottoOff()"></center>';
LottoBody += '</td></tr></table>';
document.write(LottoBody);
function LottoSave(){
var xxxOn= document.getElementById('LottoOn');
var xxx= document.getElementById('Lottonum');
var xxx1= document.getElementById('Lottonum1');
var xxx2= document.getElementById('Lottonum2');
var xxx3= document.getElementById('Lottonum3');
header = document.getElementsByName('header').item(0);
header.value = header.value.replace(new RegExp('xxOn="'+xxOn+'"',"i"),'xxOn="yes"');
header.value = header.value.replace(new RegExp('xx="'+xx+'"',"i"),'xx="'+xxx.value+'"');
header.value = header.value.replace(new RegExp('xx1="'+xx1+'"',"i"),'xx1="'+xxx1.value+'"');
header.value = header.value.replace(new RegExp('xx2="'+xx2+'"',"i"),'xx2="'+xxx2.value+'"');
header.value = header.value.replace(new RegExp('xx3="'+xx3+'"',"i"),'xx3="'+xxx3.value+'"');
document.forms.item(0).submit(true);
}
function LottoOff(){
header = document.getElementsByName('header').item(0);
header.value = header.value.replace(new RegExp('xxOn="'+xxOn+'"',"i"),'xxOn="no"');
document.forms.item(0).submit(true);
}
}
document.getElementById("LotteryTable").innerHTML = +xx+', '+xx1+', '+xx2+', '+xx3;
var div = document.getElementsByTagName('div');
for(q=0;q<div.length;q++){
if(div[q].innerHTML.match(/Headers\sand\sFooters/i)){
div[q].innerHTML+='<br /><a href="index.cgi?action=headersfooters2&id=-&system=Lottery">Lottery System</a>';
}}
//-->
</script>