Post by ⓦ৹₪deⓡ on Nov 19, 2005 0:11:36 GMT -8
This code will allow 1 board to only be displayed during a random time during the day for a random amount of minutes. So one day that board will only be displayed from 2:01am til 2:11am while the next day it will be displayed from 5:32pm til 6:02pm. You just sent the board id, and the range of time the board is allowed to be open. It will not prevent members from accessing that board or anything like that, it will just remove it from the main page. Do NOT PM me for support or request, that's what the coding boards are for. Edit where indicated. Enjoy.
~Wonder
Top of Main Header: If you already use the advanced warning meter, you don't need this part.
~Wonder
Top of Main Header: If you already use the advanced warning meter, you don't need this part.
<script>
//Board only displayed at random times
//Copyright 11-19-2005 by ~Wonder
//May be reposted anywhere as long as this header remains in tact. Make sure you include instructions.
function getDate()
{
months=new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");te=0;
curDate=document.getElementsByTagName("table")[0].innerHTML.match(/\.<br>.+ (\d{1,2}\:\d{2}(a|pm)?)/i)[0];
time=RegExp.$1;
curDate=curDate.toLowerCase().replace(/\.<br>/i,"").replace(time,"").replace(/ at /i,"").replace(/,/g,"").replace(/\.|\-|\//g," ").split(" ");
time=time.split(":");
if(time[1].match(/am/) && time[0].match(/12/)){time[0]=parseInt(time[0],10)-12;}
if(time[1].match(/pm/) && !time[0].match(/12/)){time[0]=parseInt(time[0],10)+12;}time[1]=time[1].replace(/[^\d]/g,"");
for(k=0;k<12;k++){if(curDate[0].match(months[k]) || curDate[1].match(months[k])){break;}}
if((t=curDate[0].match(months[k]))!=null && t!=""){curDate[0]=(k+1)+"";te=1;}else if((t=curDate[1].match(months[k]))!=null && t!=""){curDate[1]=(k+1)+"";temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;te=1;}
curDate[0]=curDate[0].replace(/[^\d]/g,"");curDate[1]=curDate[1].replace(/[^\d]/g,"");
if(parseInt(curDate[0],10)>12){temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;}
if(parseInt(curDate[1],10)<13 && te==0){now = new Date();if(parseInt(curDate[1],10)==(now.getMonth()+1)){temp2=curDate[1];curDate[1]=curDate[0];curDate[0]=temp2;}}
if(curDate[2].length<=2){curDate[2]=parseInt(curDate[2],10)+2000;}
return new Date(parseInt(curDate[2],10),parseInt(curDate[0],10)-1,parseInt(curDate[1],10),parseInt(time[0],10),parseInt(time[1],10));
}
mainDate=getDate();
</script>
Main Footer<script>
//Board only displayed at random times v1.0
//Copyright 11-19-2005 by ~Wonder
//May be reposted anywhere as long as this header remains in tact. Make sure you include instructions.
//Enter the boards ID and the min and max amount of time for the board to be displayed in minutes.
randomBoardID="aaa";
minOpen=1;
maxOpen=30;
if(!location.href.match(/\=/))
{
randomBoardID=new RegExp("board="+randomBoardID+"$");
timeOpen=Math.ceil(Math.abs(Math.cos(mainDate.getDate()*(1+mainDate.getMonth()))*((maxOpen-minOpen)+1)))+(minOpen)-1;
hour=Math.round(Math.abs(Math.cos(mainDate.getDate()*(1+mainDate.getMonth()))*24)*3600000);
beg=new Date(mainDate.getFullYear(),mainDate.getMonth(),mainDate.getDate())-0+hour;
end=beg+(timeOpen*60*1000);
if(mainDate>end || mainDate<beg)
{
for(i=0;i<document.links.length;i++)
{
if(document.links[i].href.match(randomBoardID))
{
document.links[i].parentNode.parentNode.parentNode.style.display="none";
break;
}
}
}
}
</script>