File size: 4,482 Bytes
ae1ff91 188df87 ae1ff91 188df87 ae1ff91 188df87 ae1ff91 188df87 ae1ff91 |
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 |
const slideTitle = document.getElementById('slide-title');
const slideImage = document.getElementById('slide-image');
const prevBtn = document.getElementById('prev-btn');
const nextBtn = document.getElementById('next-btn');
const promptBox = document.getElementById('promptBox');
const promptText = document.getElementById('promptText');
const responseBox = document.getElementById('responseBox');
const responseContent = document.getElementById('responseContent');
const promptIcon = document.getElementById('promptIcon');
const videoIcon = document.getElementById('videoIcon');
const videoOverlay = document.getElementById('videoOverlay');
const videoPlayer = document.getElementById('videoPlayer');
const closeVideo = document.getElementById('closeVideo');
const queryButton = document.getElementById('queryButton');
const websiteIcon = document.getElementById('websiteIcon');
const websiteLayer = document.getElementById('websiteLayer');
const websiteFrame = document.getElementById('websiteFrame');
const textboxIcon = document.getElementById('textboxIcon');
const textboxLayer = document.getElementById('textboxLayer');
const textboxContent = document.getElementById('textboxContent');
let slides = [];
let currentIndex = 0;
let websiteVisible = false;
let textboxVisible = false;
async function fetchSlides() {
try {
const response = await fetch('config.json');
const data = await response.json();
slides = data.slides;
loadSlide(currentIndex);
} catch (error) {
console.error('Error loading slides:', error);
}
}
function loadSlide(index) {
if (!slides.length) return;
const slide = slides[index];
slideTitle.textContent = slide.id.replace('_', ' ');
slideImage.src = slide.image;
promptBox.style.display = 'none';
responseBox.style.display = 'none';
responseContent.innerHTML = '';
videoPlayer.src = '';
textboxLayer.style.transform = 'translateX(100%)';
textboxLayer.style.display = 'none';
textboxContent.innerHTML = '';
textboxVisible = false;
if (websiteVisible) {
toggleWebsiteLayer();
}
}
function toggleWebsiteLayer() {
if (websiteVisible) {
websiteLayer.style.display = 'none';
websiteFrame.src = '';
} else {
const websiteURL = slides[currentIndex]?.website || '';
if (websiteURL) {
window.open(websiteURL, '_blank');
} else {
console.warn('No website URL defined for this slide.');
}
}
websiteVisible = !websiteVisible;
}
function toggleTextboxLayer() {
if (textboxVisible) {
textboxLayer.style.transform = 'translateX(100%)';
setTimeout(() => {
textboxLayer.style.display = 'none';
}, 300);
textboxContent.innerHTML = '';
} else {
const markdownText = slides[currentIndex]?.text || "No additional text available.";
textboxContent.innerHTML = marked(markdownText);
textboxLayer.style.display = 'block';
setTimeout(() => {
textboxLayer.style.transform = 'translateX(0)';
}, 10);
}
textboxVisible = !textboxVisible;
}
prevBtn.addEventListener('click', () => {
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
loadSlide(currentIndex);
});
nextBtn.addEventListener('click', () => {
currentIndex = (currentIndex + 1) % slides.length;
loadSlide(currentIndex);
});
promptIcon.addEventListener('click', () => {
const slideText = slides[currentIndex]?.text || "No prompt text available.";
promptBox.style.display = promptBox.style.display === 'block' ? 'none' : 'block';
promptText.value = slideText;
});
videoIcon.addEventListener('click', () => {
const videoURL = slides[currentIndex]?.video || '';
if (videoURL) {
videoPlayer.src = videoURL;
videoOverlay.style.display = 'flex';
}
});
closeVideo.addEventListener('click', () => {
videoOverlay.style.display = 'none';
videoPlayer.src = '';
});
websiteIcon.addEventListener('click', toggleWebsiteLayer);
textboxIcon.addEventListener('click', toggleTextboxLayer);
queryButton.addEventListener('click', async () => {
const userPrompt = promptText.value.trim();
if (!userPrompt) return;
responseBox.style.display = "block";
responseContent.innerHTML = "Processing...";
setTimeout(() => {
responseContent.innerHTML = "Response received: " + userPrompt;
}, 2000);
});
fetchSlides();
|