-
Notifications
You must be signed in to change notification settings - Fork 0
/
massive-pitch.js
34 lines (29 loc) · 1.28 KB
/
massive-pitch.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
async function getDeck() {
const location = new URL(document.location)
const deckId = location.searchParams.get('deck');
if (deckId) {
const response = await fetch(`${deckId}.json`)
const deckData = await response.json()
const currentSlideIndex = deckData.slides.findIndex(s => s === location.pathname)
// Add "previous" button
if (currentSlideIndex > 0) {
const prevButton = document.createElement("a")
prevButton.href = deckData.slides[currentSlideIndex - 1] + location.search
prevButton.innerHTML = "<-previous"
document.body.appendChild(prevButton)
} else {
document.body.appendChild(document.createTextNode("<-previous"))
}
document.body.appendChild(document.createTextNode(" | "))
// Add "next" Button
if (currentSlideIndex > -1 && currentSlideIndex !== deckData.slides.length - 1) {
const nextButton = document.createElement("a")
nextButton.href = deckData.slides[currentSlideIndex + 1] + location.search
nextButton.innerHTML = "next->"
document.body.appendChild(nextButton)
} else {
document.body.appendChild(document.createTextNode("next->"))
}
}
}
getDeck();