I am building an interactive "web wallpaper" using the aptly named Wallpaper Engine. It's been an on-going project since the beginning of February-- and while I'm completely new to this I have managed to get a lot done! This site's answered questions, W3Schools and countless YouTube tutorials are to thank. . but I've hit a wall (....paper?).
The current problem on my hand is the apparent lack of understanding in methods "Date()", "getHours", "getMinutes". In the below code, I try to express that I desire that the image source change to a different one depending on what time of day it is. But it fails to operate as the images don't display whatsoever.
The intent is that it performs like a more limited clock.. so some sort of "sun" or "moon" should always be visible.
(To be clear, the intervals for each image go like this:
- 9 AM - 1:59 PM = www.morningsun.png
- 2 PM - 4:59 PM = www.restingsun.png
- 5 PM - 5:30 PM = www.afternoon.png
- 5:30 PM - 5:59 PM = www.daybreak.png
- 6 PM - 8:59 PM = www.fullmoon.png
- 9 PM - 12:59 AM = www.darkhour.png
- 1 AM - 4:59 AM = www.restingmoon.png
- 5 AM - 8:59 AM = www.waningmoonlight.png
- REPEAT)
function showcaseTIME() {
var currentTIME = new Date();
var hoursNOW = currentTIME.getHours();
var minutesNOW = currentTIME.getMinutes();
if ((9 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 13 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src="' + '"core folder/www.morningsun"' + '">');
}
if ((14 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 16 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.restingsun.png"' + '">');
}
if ((17 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 17 && 30 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.afternoon.png"' + '">');
}
if ((17 <= hoursNOW && minutesNOW <= 31) || (hoursNOW < 18 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.daybreak.png"' + '">');
}
if ((18 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 20 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.fullmoon.png"' + '">');
}
if ((21 <= hoursNOW && minutesNOW <= 00) || ( hoursNOW < 0 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.darkhour.png"' + '">');
}
if ((1 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 4 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.restingmoon.png"' + '">');
}
if ((5 <= hoursNOW && minutesNOW <= 00) || (hoursNOW < 8 && 59 < minutesNOW))
{document.write('<img id="Solunar"' + 'src=' + '"core folder/www.waningmoonlight.png"' + '">');
}
}
// Thank you for any that have read this! In the meantime, I'll continue working at it all and seeing what can be found