-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
28 lines (25 loc) · 1.07 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var images = ['Stream', 'Snow', 'RainMetal', 'Rain', 'LightRain','HotTub', 'Fire','Driving', 'Clock', 'City', 'Birds', 'Airplane'];
$(document).ready(function(){// starts when page is loaded and ready
setTimeout(function() {
var scene = images[getRandomInt(0, images.length-1)];
var shellImage = "shells/" + scene + ".png"
var imageToShow = "backgrounds/" + scene + ".jpg";
$("#bg").css('background-image','url('+imageToShow+')').animate({opacity: 1});
$("#shell").attr('src',shellImage).animate({opacity: 1});
changeBackground();
}, 100); // 20 second timer
});
function changeBackground()
{
setTimeout(function() {
var scene = images[getRandomInt(0, images.length-1)];
var shellImage = "shells/" + scene + ".png"
var imageToShow = "backgrounds/" + scene + ".jpg";
$("#bg").css('background-image','url('+imageToShow+')').animate({opacity: 1});
$("#shell").attr('src',shellImage).animate({opacity: 1});
changeBackground();
}, 20000);
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}