-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslides.js
37 lines (29 loc) · 909 Bytes
/
slides.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
function slidesActivated() {
return new URLSearchParams(window.location.search).get("slides") !== null;
}
function abridgedActivated() {
return new URLSearchParams(window.location.search).get("abridged") !== null;
}
function initializeSlides() {
document.body.classList.add("slides");
if (abridgedActivated()) {
document.body.classList.add("abridged");
}
let main = document.querySelector("main");
main.querySelectorAll("main > section").forEach((e, i) => {
initializeSlide(e, i);
});
main.addEventListener("scroll", (event) => {
console.log(event);
})
}
function initializeSlide(slide, index) {
slide.setAttribute("data-slide-nr", index);
slide.id = slide.id || `s${index}`;
let heading = slide.querySelector("h1, h2, h3, h4, h5, h6");
heading.id = heading.id || `s${index}h`;
slide.setAttribute("aria-describedby", heading.id);
}
if (slidesActivated()) {
initializeSlides();
}