-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
311 lines (292 loc) · 11 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Boont.ai</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;400;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"/>
<style>
body, html {
height: 100%;
margin: 0;
font-family: 'Montserrat', sans-serif;
font-weight: 100;
background: black;
color: white;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow: hidden;
}
p
{
margin-bottom: 0.5em;
margin-top: 0.5em;
}
.fullscreen-button {
position: absolute;
top: 10px;
right: 10px;
padding: 10px;
background: rgba(0, 0, 0, 0);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
z-index: 1000;
font-size: 24px;
line-height: 1;
opacity: 0.4;
}
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
display: flex;
justify-content: center;
align-items: center;
background-size: cover;
background-position: center;
position: relative;
}
.cover-slide {
font-size: 2em;
color: white;
text-align: left;
width: 90%;
font-weight: 400;
}
.text-overlay-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
padding: 20px;
}
.text-overlay {
width: 100%;
max-width: 400px;
padding: 20px;
background: #000000a6; /* Semi-transparent background */
border-radius: 15px;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
overflow-y: auto;
text-align: left;
font-weight: 400;
}
.image-slide-text {
padding: 20px;
text-align: left;
width: 90%;
font-size: 1.6em; /* Larger text */
font-weight: 800; /* Bolder text */
}
.bold-text {
font-weight: 800;
font-size: 1.6em;
}
.regular-text {
font-weight: 400;
font-size: 1em;
}
.image-slide-indicator {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 5px;
width: 80%;
}
.image-slide-indicator div {
flex: 1;
height: 4px;
background: rgba(255, 255, 255, 0.5);
border-radius: 2px;
overflow: hidden;
position: relative;
}
.image-slide-indicator div.active::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
animation: progress 0s linear forwards;
}
@keyframes progress {
from {
width: 0;
}
to {
width: 100%;
}
}
.swiper-pagination {
display: none;
}
/* Fullscreen styles */
:fullscreen {
width: 100%;
height: 100%;
}
/* Message for non-mobile devices */
.non-mobile-message {
display: none;
justify-content: center;
align-items: center;
text-align: center;
height: 100%;
font-size: 2em;
background: black;
color: white;
}
@media (min-width: 768px) {
.fullscreen-button, .swiper {
display: none;
}
.non-mobile-message {
display: flex;
}
}
</style>
</head>
<body>
<!-- Fullscreen Button -->
<button class="fullscreen-button" id="fullscreen-button" onclick="toggleFullscreen()">⛶</button>
<!-- Non-Mobile Message -->
<div class="non-mobile-message">Please open on your phone</div>
<!-- Main Swiper -->
<div class="swiper main-swiper">
<div class="swiper-wrapper">
<!-- Slides will be inserted here dynamically -->
</div>
<!-- Add Pagination -->
<div class="swiper-pagination main-pagination"></div>
</div>
<!-- Swiper JS -->
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<script>
// Initialize main Swiper
const mainSwiper = new Swiper('.main-swiper', {
direction: 'horizontal',
loop: false,
pagination: {
el: '.main-pagination',
clickable: true,
},
});
// Function to load slides from JSON data
async function loadSlides() {
try {
const response = await fetch('content.json');
const bookData = await response.json();
const swiperWrapper = document.querySelector('.main-swiper .swiper-wrapper');
// Add the cover slide
const coverSlide = document.createElement('div');
coverSlide.className = 'swiper-slide';
coverSlide.style.backgroundImage = `url('${bookData[1].Cover}')`;
coverSlide.innerHTML = `<div class="cover-slide">${bookData[0].Title}</div>`;
swiperWrapper.appendChild(coverSlide);
// Add all slides in sequence
const sections = bookData[2].Chapters[0].sections;
sections.forEach(section => {
const totalSlides = section.slides.length;
section.slides.forEach((slide, index) => {
const slideElement = document.createElement('div');
slideElement.className = 'swiper-slide';
slideElement.style.backgroundImage = `url('${slide.image}')`;
if (section.type === 'text') {
const overlayContainer = document.createElement('div');
overlayContainer.className = 'text-overlay-container';
const overlay = document.createElement('div');
overlay.className = 'text-overlay';
overlay.innerHTML = `<p>${slide.text}</p>`;
overlayContainer.appendChild(overlay);
slideElement.appendChild(overlayContainer);
} else if (section.type === 'image') {
const imageText = document.createElement('div');
imageText.className = 'image-slide-text';
imageText.innerHTML = slide.text; // Use the text directly from JSON
slideElement.appendChild(imageText);
// Add slide indicator for image type slides
const indicatorContainer = document.createElement('div');
indicatorContainer.className = 'image-slide-indicator';
for (let i = 0; i < totalSlides; i++) {
const indicator = document.createElement('div');
if (i === index) {
indicator.classList.add('active');
}
indicatorContainer.appendChild(indicator);
}
slideElement.appendChild(indicatorContainer);
}
swiperWrapper.appendChild(slideElement);
});
});
mainSwiper.update(); // Update main Swiper after dynamically adding slides
// Add click event listeners for slide navigation
document.querySelector('.main-swiper').addEventListener('click', (event) => {
const swiperWidth = event.currentTarget.offsetWidth;
const clickX = event.clientX;
if (clickX < swiperWidth / 2) {
mainSwiper.slidePrev();
} else {
mainSwiper.slideNext();
}
});
} catch (error) {
console.error('Error loading slides:', error);
}
}
// Load slides when the document is ready
document.addEventListener('DOMContentLoaded', () => {
// Check if the device is mobile
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if (isMobile) {
loadSlides();
} else {
// Show the non-mobile message
document.querySelector('.non-mobile-message').style.display = 'flex';
document.querySelector('.fullscreen-button').style.display = 'none';
document.querySelector('.swiper').style.display = 'none';
}
});
// Function to toggle fullscreen mode
function toggleFullscreen() {
const doc = document.documentElement;
const fullscreenButton = document.getElementById('fullscreen-button');
if (!document.fullscreenElement) {
if (doc.requestFullscreen) {
doc.requestFullscreen();
} else if (doc.mozRequestFullScreen) { // Firefox
doc.mozRequestFullScreen();
} else if (doc.webkitRequestFullscreen) { // Chrome, Safari and Opera
doc.webkitRequestFullscreen();
} else if (doc.msRequestFullscreen) { // IE/Edge
doc.msRequestFullscreen();
}
fullscreenButton.textContent = '⛌';
} else {
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) { // IE/Edge
document.msExitFullscreen();
}
fullscreenButton.textContent = '⛶';
}
}
</script>
</body>
</html>