Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BentleyDavis committed Sep 18, 2022
0 parents commit da3f7f9
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
7 changes: 7 additions & 0 deletions 1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"slides": [
"/a.html",
"/b.html",
"/c.html"
]
}
7 changes: 7 additions & 0 deletions 2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"slides": [
"/c.html",
"/b.html",
"/a.html"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Bentley Davis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# massive-pitch

16 changes: 16 additions & 0 deletions a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>A</title>
<script src="massive-pitch.js"></script>
</head>

<body>
<h1>Slide A</h1>
</body>

</html>
16 changes: 16 additions & 0 deletions b.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>B</title>
<script src="massive-pitch.js"></script>
</head>

<body>
<h1>Slide B</h1>
</body>

</html>
16 changes: 16 additions & 0 deletions c.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>C</title>
<script src="massive-pitch.js"></script>
</head>

<body>
<h1>Slide C</h1>
</body>

</html>
27 changes: 27 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Massive Pitch</title>
</head>

<body>
<h2><a href="a.html?deck=1">Slide Deck 1</a></h2>
<ul>
<li>Page A</li>
<li>Page B</li>
<li>Page C</li>
</ul>
<h2><a href="c.html?deck=2">Slide Deck 2</a></h2>
<ul>
<li>Page C</li>
<li>Page B</li>
<li>Page A</li>
</ul>

</body>

</html>
34 changes: 34 additions & 0 deletions massive-pitch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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();
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "massive-pitch",
"version": "0.0.1",
"description": "",
"main": "massive-pitch.js",
"scripts": {},
"author": "",
"license": "ISC"
}

0 comments on commit da3f7f9

Please sign in to comment.