-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
402 lines (342 loc) · 13.4 KB
/
script.js
File metadata and controls
402 lines (342 loc) · 13.4 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
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
// AI Tools Seminar Presentation Script
// Theme Management
class ThemeManager {
constructor() {
this.currentTheme = this.getStoredTheme() || this.getSystemTheme();
this.init();
}
init() {
this.applyTheme(this.currentTheme);
this.bindEvents();
}
getSystemTheme() {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
getStoredTheme() {
return localStorage.getItem('presentation-theme');
}
storeTheme(theme) {
localStorage.setItem('presentation-theme', theme);
}
applyTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
this.currentTheme = theme;
this.storeTheme(theme);
// Update theme toggle button
const themeToggle = document.getElementById('theme-toggle');
if (themeToggle) {
themeToggle.textContent = theme === 'dark' ? '☀️' : '🌙';
themeToggle.setAttribute('aria-label', `Switch to ${theme === 'dark' ? 'light' : 'dark'} mode`);
}
}
toggleTheme() {
const newTheme = this.currentTheme === 'dark' ? 'light' : 'dark';
this.applyTheme(newTheme);
// Provide visual feedback with reduced motion consideration
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
document.body.style.transition = 'background-color 250ms ease-in-out, color 250ms ease-in-out';
}
}
bindEvents() {
// Listen for system theme changes
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
if (!this.getStoredTheme()) {
this.applyTheme(e.matches ? 'dark' : 'light');
}
});
// Theme toggle button
const themeToggle = document.getElementById('theme-toggle');
if (themeToggle) {
themeToggle.addEventListener('click', () => this.toggleTheme());
}
}
}
class PresentationController {
constructor() {
this.currentSlide = 1;
this.totalSlides = 0;
this.slides = [];
this.presenterNotesVisible = false;
this.themeManager = new ThemeManager();
this.init();
}
init() {
this.cacheElements();
this.setupSlides();
this.bindEvents();
this.updateSlideCounter();
this.loadPresenterNotes();
}
cacheElements() {
this.slidesContainer = document.querySelector('.slides-container');
this.slides = document.querySelectorAll('.slide');
this.prevBtn = document.getElementById('prev-btn');
this.nextBtn = document.getElementById('next-btn');
this.slideCounter = document.getElementById('slide-counter');
this.fullscreenBtn = document.getElementById('fullscreen-btn');
this.themeToggle = document.getElementById('theme-toggle');
this.presenterNotes = document.getElementById('presenter-notes');
this.currentNotes = document.getElementById('current-notes');
}
setupSlides() {
this.totalSlides = this.slides.length;
// Ensure first slide is active
this.slides.forEach((slide, index) => {
slide.classList.remove('active', 'prev');
if (index === 0) {
slide.classList.add('active');
}
});
}
bindEvents() {
// Navigation buttons
this.prevBtn.addEventListener('click', () => this.previousSlide());
this.nextBtn.addEventListener('click', () => this.nextSlide());
this.fullscreenBtn.addEventListener('click', () => this.toggleFullscreen());
// Keyboard navigation
document.addEventListener('keydown', (e) => this.handleKeydown(e));
// Touch/swipe gestures for mobile
this.bindTouchEvents();
// Window resize handler
window.addEventListener('resize', () => this.handleResize());
}
handleKeydown(e) {
switch(e.key) {
case 'ArrowLeft':
case 'ArrowUp':
e.preventDefault();
this.previousSlide();
break;
case 'ArrowRight':
case 'ArrowDown':
case ' ': // Space bar
e.preventDefault();
this.nextSlide();
break;
case 'Home':
e.preventDefault();
this.goToSlide(1);
break;
case 'End':
e.preventDefault();
this.goToSlide(this.totalSlides);
break;
case 'Escape':
e.preventDefault();
if (document.fullscreenElement) {
this.exitFullscreen();
}
break;
case 'n':
case 'N':
e.preventDefault();
this.togglePresenterNotes();
break; case 'f':
case 'F':
e.preventDefault();
this.toggleFullscreen();
break;
case 't':
case 'T':
e.preventDefault();
this.themeManager.toggleTheme();
break;
}
}
bindTouchEvents() {
let startX = 0;
let startY = 0;
let endX = 0;
let endY = 0;
this.slidesContainer.addEventListener('touchstart', (e) => {
startX = e.touches[0].clientX;
startY = e.touches[0].clientY;
}, { passive: true });
this.slidesContainer.addEventListener('touchend', (e) => {
endX = e.changedTouches[0].clientX;
endY = e.changedTouches[0].clientY;
const deltaX = startX - endX;
const deltaY = startY - endY;
const minSwipeDistance = 50;
// Horizontal swipe detection
if (Math.abs(deltaX) > Math.abs(deltaY) && Math.abs(deltaX) > minSwipeDistance) {
if (deltaX > 0) {
// Swipe left - next slide
this.nextSlide();
} else {
// Swipe right - previous slide
this.previousSlide();
}
}
}, { passive: true });
}
nextSlide() {
if (this.currentSlide < this.totalSlides) {
this.goToSlide(this.currentSlide + 1);
}
}
previousSlide() {
if (this.currentSlide > 1) {
this.goToSlide(this.currentSlide - 1);
}
}
goToSlide(slideNumber) {
if (slideNumber < 1 || slideNumber > this.totalSlides) {
return;
}
const previousSlide = this.currentSlide;
this.currentSlide = slideNumber;
// Update slide visibility
this.slides.forEach((slide, index) => {
slide.classList.remove('active', 'prev');
if (index + 1 === this.currentSlide) {
slide.classList.add('active');
} else if (index + 1 < this.currentSlide) {
slide.classList.add('prev');
}
});
this.updateSlideCounter();
this.updateNavigationButtons();
this.updatePresenterNotes();
// Announce slide change for screen readers
this.announceSlideChange();
}
updateSlideCounter() {
this.slideCounter.textContent = `${this.currentSlide} / ${this.totalSlides}`;
}
updateNavigationButtons() {
this.prevBtn.disabled = this.currentSlide === 1;
this.nextBtn.disabled = this.currentSlide === this.totalSlides;
}
toggleFullscreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(err => {
console.log(`Error attempting to enable fullscreen: ${err.message}`);
});
} else {
this.exitFullscreen();
}
}
exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
togglePresenterNotes() {
this.presenterNotesVisible = !this.presenterNotesVisible;
if (this.presenterNotesVisible) {
this.presenterNotes.classList.add('show');
} else {
this.presenterNotes.classList.remove('show');
}
}
loadPresenterNotes() {
// Presenter notes data for each slide
this.notesData = {
1: "Welcome to the AI Tools seminar. This presentation will guide you through the current landscape of AI development tools.",
2: "Emphasize that this is about strategic selection, not just tool adoption. Highlight the practical, hands-on nature of the session.",
3: "Walk through each agenda item briefly. Mention this is a comprehensive journey from theory to practical implementation.",
4: "Section 1 introduction - set the stage for understanding AI's transformative impact on development.",
5: "Emphasize the speed of AI evolution. Share specific examples of how tools have become essential rather than experimental.",
6: "Address common fears directly. Use concrete examples of productivity gains. Mention the 20-40% improvement statistics.",
7: "This is crucial - emphasize that AI makes good practices MORE important, not less. Give examples of how poor naming hurts AI assistance."
};
this.updatePresenterNotes();
}
updatePresenterNotes() {
const notes = this.notesData[this.currentSlide] || "No notes for this slide.";
this.currentNotes.innerHTML = `
<p><strong>Slide ${this.currentSlide}:</strong> ${notes}</p>
<p><em>Press 'N' to toggle notes, 'F' for fullscreen, arrows or space to navigate.</em></p>
`;
}
announceSlideChange() {
// Create or update live region for screen readers
let announcer = document.getElementById('slide-announcer');
if (!announcer) {
announcer = document.createElement('div');
announcer.id = 'slide-announcer';
announcer.setAttribute('aria-live', 'polite');
announcer.setAttribute('aria-atomic', 'true');
announcer.style.position = 'absolute';
announcer.style.left = '-10000px';
announcer.style.width = '1px';
announcer.style.height = '1px';
announcer.style.overflow = 'hidden';
document.body.appendChild(announcer);
}
const currentSlideElement = this.slides[this.currentSlide - 1];
const slideTitle = currentSlideElement.querySelector('h1')?.textContent || `Slide ${this.currentSlide}`;
announcer.textContent = `${slideTitle}, slide ${this.currentSlide} of ${this.totalSlides}`;
}
handleResize() {
// Handle responsive updates if needed
// This can be extended for dynamic layout adjustments
}
// Public API methods
getCurrentSlide() {
return this.currentSlide;
}
getTotalSlides() {
return this.totalSlides;
}
// Add slide programmatically (for dynamic content)
addSlide(slideHTML, notes = '') {
const slideElement = document.createElement('section');
slideElement.className = 'slide';
slideElement.setAttribute('data-slide', this.totalSlides + 1);
slideElement.innerHTML = slideHTML;
this.slidesContainer.appendChild(slideElement);
this.slides = document.querySelectorAll('.slide');
this.totalSlides = this.slides.length;
if (notes) {
this.notesData[this.totalSlides] = notes;
}
this.updateSlideCounter();
}
}
// Utility functions for slide content
class SlideUtils {
static createCodeBlock(code, language = 'javascript') {
return `
<div class="code-block">
<pre><code class="language-${language}">${this.escapeHtml(code)}</code></pre>
</div>
`;
}
static createTable(headers, rows) {
const headerRow = headers.map(h => `<th>${h}</th>`).join('');
const dataRows = rows.map(row =>
`<tr>${row.map(cell => `<td>${cell}</td>`).join('')}</tr>`
).join('');
return `
<table class="slide-table">
<thead><tr>${headerRow}</tr></thead>
<tbody>${dataRows}</tbody>
</table>
`;
}
static escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
}
// Initialize presentation when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
window.presentation = new PresentationController();
// Add additional slides dynamically if needed
// This allows for modular slide construction
console.log('AI Tools Presentation loaded successfully!');
console.log('Keyboard shortcuts:');
console.log('- Arrow keys or Space: Navigate slides');
console.log('- N: Toggle presenter notes');
console.log('- F: Toggle fullscreen');
console.log('- T: Toggle theme');
console.log('- Home/End: Go to first/last slide');
console.log('- Esc: Exit fullscreen');
});
// Export for potential external use
if (typeof module !== 'undefined' && module.exports) {
module.exports = { PresentationController, SlideUtils };
}