Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (53 loc) · 1.49 KB
/
Copy pathscript.js
File metadata and controls
61 lines (53 loc) · 1.49 KB
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
const slides = [
{
img: "img/besaid_beach.jpg",
text: "Tip: If you hear 'HA HA HA', your audio is working perfectly.",
author: "-Lulu (probably)"
},
{
img: "img/besaid_island_1.jpg",
text: "Reminder: The sphere grid is not a suggestion. It is a lifestyle.",
author: "-Wakka"
},
{
img: "img/besaid_island_2.jpg",
text: "If Blitzball makes no sense, congratulations—you are playing it correctly.",
author: "-Jecht"
},
{
img: "img/besaid_lake.jpg",
text: "Tip: Save often. Especially right before you decide, 'I'll just check what's next.'",
author: "-Auron"
},
{
img: "img/besaid_temple.jpg",
text: "Warning: Touching suspicious glowing spheres may cause plot progression.",
author: "-Rikku"
}
];
const bg = document.querySelector(".bg-slideshow");
const tipEl = document.querySelector(".loading__text");
const authorEl = document.querySelector(".loading__author");
let i = 0;
const FADE_MS = 1200;
const INTERVAL_MS = 6500;
function applySlide(index) {
const s = slides[index];
bg.style.backgroundImage = `url("${s.img}")`;
tipEl.textContent = s.text;
authorEl.textContent = s.author;
}
function nextSlide() {
bg.style.opacity = "0";
tipEl.style.opacity = "0";
authorEl.style.opacity = "0";
setTimeout(() => {
i = (i + 1) % slides.length;
applySlide(i);
bg.style.opacity = "1";
tipEl.style.opacity = "1";
authorEl.style.opacity = "1";
}, FADE_MS);
}
applySlide(i);
setInterval(nextSlide, INTERVAL_MS);