Hi guys,
I apologise for any complexity of the following script, but what I am trying to achieve is
1.) At 6:51 am, the image sunrise.png is written as the background of #wrap
2.) At 12:04 midnight through 12:07 midnight, the background of #wrap is green.png
then
3.) Then, at a random time at night that is not 6:51 am nor in-between 12:04 midnight & 12:07 midnight, the background of #wrap is set as aurora.png
This is the code of if statments that I wrote to achieve it:
<script type="text/javascript">
var timeMinutes=new Date();
var timeHours=new Date();
var sunriseHour=6;
var sunriseMinutes=51;
var greenHour=0;
var greenMinutes=4;
var greenMinutesEnd=7;
var randomTime=Math.floor(Math.random()*11);
var randomTimeEnd=randomTime + 1;
if(randomTime=sunriseHour)
{
randomTime=Math.floor(Math.random()*11);
}
else if(randomTime=greenHour)
{
randomTime=Math.floor(Math.random()*11);
}
else {
if(timeHours.getHours()=sunriseHour && timeMinutes.getMinutes()=sunriseMinutes)
{
document.write('<style type="text/css">#wrap{background:transparent url(img/sunrise.png) center top no-repeat;}.headerText span{color:#3c0376; text-shadow:none;}</style>');
}
else if((timeHours.getHours()=greenHour && timeMinutes.getMinutes()=greenMinutes) || (timeHours.getHours()=greenHour && ((timeMinutes.getMinutes()<greenMinutesEnd) && (timeMinutes.getMinutes()>greenMinutes))))
{
document.write('<style type="text/css">#wrap{background:transparent url(img/green.png) center top no-repeat;}.headerText span{color:#3c0376; text-shadow:none;}</style>');
}
else if(timeHours.getHours()=randomTime || timeHours.getHours()<randomTimeEnd)
{
document.write('<style type="text/css">#wrap{background:transparent url(img/aurora.png) center top no-repeat;}</style>');
}
else{
document.write('<style type="text/css">#wrap{background:transparent url(img/space.png) center top no-repeat;}</style>');
}
}
</script>
It is not producing any errors, but it is not wroking either.
Would anyone be willing to help me fix it and see if I am trim it down any?
I would really appreciate any help
Thanks in Advance & I hope to hear from you soon,
Team 1504