-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
74 lines (68 loc) · 1.75 KB
/
script.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
let index = Math.floor(Math.random() * 25);
const body = document.querySelector("body");
let timeout = 500;
add = -50;
body.addEventListener("click", () => {
if (!document.fullscreenElement) {
openFullscreen(document.documentElement); // Fullscreen the entire page
} else {
closeFullscreen();
}
});
const bginterval = setInterval(() => {
let bg = "url('./assets/cr" + index + ".jpg')";
body.style.backgroundImage = bg;
index++;
timeout += add;
if (index >= 26) {
index = 1;
}
if (timeout < 100) {
add = 50;
}
if (timeout > 1000) {
add = -50;
}
console.log(timeout);
}, timeout);
setTimeout(() => {
let i = 1;
let interval = setInterval(() => {
let div = document.createElement("div");
div.style.backgroundImage = "url('./assets/cr" + index + ".jpg')";
body.appendChild(div);
i++;
if (i == 26) {
clearInterval(interval);
clearInterval(bginterval);
}
}, timeout);
}, 15000);
function openFullscreen(elem) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) {
// Firefox
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
// Chrome, Safari, and Opera
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) {
// Internet Explorer/Edge
elem.msRequestFullscreen();
}
}
function closeFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
// Firefox
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
// Chrome, Safari, and Opera
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
// Internet Explorer/Edge
document.msExitFullscreen();
}
}