I have a simple code that shows one image at night and one image during the day. For some reason the day image always shows.
The javascript is a bit split. This part is on the page:
<script>
//waits until document is open
$(window).load(function() {
//if it's night time when you read this it displays a night time photo, if it's day time it's a day time photo... don't know how many people might notice
if (time === "night"){
$.backstretch("cafenight.jpg");
//makes the font white with a black outline so you can read it easily on the night photo
$("#content").css("color","#FFFFFF");
$("#content").css("text-shadow","1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000");
}
else {
$.backstretch("cafeday.jpg");
$("#content").css("text-shadow","1px 0 0 #fff, 0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 Ωfff");}});
$(document).ready(function(){
//fades in the first line of text
$("#partFive").fadeIn(2000)
setTimeout(function () {
//fades in the second line of text
$("#partFive").fadeOut(2000)
setTimeout(function () {
$("#partSix").fadeIn(3000)
setTimeout(function () {
$("#partSix").fadeOut(3000)
setTimeout(function () {
window.location.href = "6.html";
}, 4000);
}, 2000);
}, 2000);
}, 3000);
});
</script>
This part is in basic2.js
// Javascript and Jquery rock!
//Variables to be used throughout
//The user's current hour
var hour = (new Date()).getHours()
//use the variable 'time' to know if it is day or night. Can use to change background even wording.
//The variable 'time' will either be Day or Night depending on what time it is
var time = []
if (hour < 20){
time.push("day");
}
else {
time.push("night");
}
//Gets the user's city based on IP and replaces #homeCity span with the name of their city
// not perfectly accurate but fun
$.getJSON("http://www.telize.com/geoip?callback=?",
function(json) {
$("#homeCity").html(json.city);
}
);
//The user's username, they enter it near the beginning
var userName = []