Spaces:
Running

carrusel / index.html
zerocool19's picture
Add 3 files
b4d3fe4 verified
Raw History Blame Contribute Delete
33.6 kB
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SlideShow Manager</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.slide-enter-active, .slide-leave-active {
transition: opacity 0.5s, transform 0.5s;
}
.slide-enter-from {
opacity: 0;
transform: translateX(100%);
}
.slide-leave-to {
opacity: 0;
transform: translateX(-100%);
}
.fade-enter-active, .fade-leave-active {
transition: opacity 0.3s;
}
.fade-enter-from, .fade-leave-to {
opacity: 0;
}
.modal-overlay {
background-color: rgba(0, 0, 0, 0.7);
}
.carousel-container {
height: 70vh;
}
@media (max-width: 768px) {
.carousel-container {
height: 50vh;
}
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<!-- Navigation -->
<nav class="bg-blue-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
<h1 class="text-2xl font-bold">SlideShow Manager</h1>
<button id="toggleView" class="bg-blue-700 hover:bg-blue-800 px-4 py-2 rounded-lg transition">
<i class="fas fa-cog mr-2"></i>Backoffice
</button>
</div>
</nav>
<!-- Carousel View -->
<div id="carouselView" class="container mx-auto px-4 py-8">
<div class="carousel-container relative overflow-hidden rounded-xl shadow-2xl bg-gray-800">
<!-- Slides will be injected here by JavaScript -->
<div id="slidesContainer" class="h-full w-full relative">
<!-- Default slide when no slides are available -->
<div class="absolute inset-0 flex items-center justify-center bg-gradient-to-r from-blue-500 to-purple-600">
<div class="text-center text-white p-8">
<i class="fas fa-images text-6xl mb-4"></i>
<h2 class="text-3xl font-bold mb-2">No Slides Available</h2>
<p class="text-xl">Please add slides from the backoffice</p>
</div>
</div>
</div>
<!-- Navigation Arrows -->
<button id="prevSlide" class="absolute left-4 top-1/2 -translate-y-1/2 bg-black bg-opacity-50 text-white p-3 rounded-full hover:bg-opacity-70 transition">
<i class="fas fa-chevron-left"></i>
</button>
<button id="nextSlide" class="absolute right-4 top-1/2 -translate-y-1/2 bg-black bg-opacity-50 text-white p-3 rounded-full hover:bg-opacity-70 transition">
<i class="fas fa-chevron-right"></i>
</button>
<!-- Slide Indicator -->
<div id="slideIndicators" class="absolute bottom-4 left-1/2 -translate-x-1/2 flex space-x-2">
<!-- Indicators will be added here by JavaScript -->
</div>
</div>
<div class="mt-6 bg-white rounded-lg shadow p-4">
<div class="flex items-center justify-between">
<div>
<h3 class="text-lg font-semibold">Current Settings</h3>
<p class="text-gray-600">Transition time: <span id="currentTransitionTime" class="font-medium">5</span> seconds</p>
</div>
<button id="pausePlay" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition">
<i class="fas fa-pause mr-2"></i>Pause
</button>
</div>
</div>
</div>
<!-- Backoffice View (Hidden by default) -->
<div id="backofficeView" class="container mx-auto px-4 py-8 hidden">
<div class="bg-white rounded-lg shadow-lg overflow-hidden">
<!-- Header -->
<div class="bg-gray-800 text-white px-6 py-4">
<h2 class="text-xl font-bold">Slide Management</h2>
<p class="text-gray-300">Upload and organize your presentation slides</p>
</div>
<!-- Content -->
<div class="p-6">
<!-- Upload Section -->
<div class="mb-8">
<h3 class="text-lg font-semibold mb-4 border-b pb-2">Upload New Slides</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Image Upload -->
<div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-blue-500 transition">
<div class="mb-4 text-blue-500">
<i class="fas fa-image text-4xl"></i>
</div>
<h4 class="font-medium mb-2">Upload Images</h4>
<p class="text-gray-600 mb-4">JPG, PNG, GIF (Max 5MB each)</p>
<input type="file" id="imageUpload" class="hidden" accept="image/*" multiple>
<label for="imageUpload" class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg cursor-pointer transition">
<i class="fas fa-upload mr-2"></i>Select Images
</label>
<div id="imagePreview" class="mt-4 grid grid-cols-3 gap-2 hidden">
<!-- Image previews will appear here -->
</div>
</div>
<!-- PPT Upload -->
<div class="border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-blue-500 transition">
<div class="mb-4 text-purple-500">
<i class="fas fa-file-powerpoint text-4xl"></i>
</div>
<h4 class="font-medium mb-2">Upload PowerPoint</h4>
<p class="text-gray-600 mb-4">PPT, PPTX (Max 20MB)</p>
<input type="file" id="pptUpload" class="hidden" accept=".ppt,.pptx">
<label for="pptUpload" class="inline-block bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg cursor-pointer transition">
<i class="fas fa-upload mr-2"></i>Select PowerPoint
</label>
<div id="pptPreview" class="mt-4 hidden">
<div class="bg-gray-100 p-3 rounded-lg">
<i class="fas fa-file-powerpoint text-2xl text-purple-500 mr-2"></i>
<span id="pptFileName" class="font-medium"></span>
</div>
</div>
</div>
</div>
<div class="mt-6 flex justify-end">
<button id="uploadSlides" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg transition">
<i class="fas fa-save mr-2"></i>Upload All Slides
</button>
</div>
</div>
<!-- Current Slides Section -->
<div>
<div class="flex justify-between items-center mb-4 border-b pb-2">
<h3 class="text-lg font-semibold">Current Slides</h3>
<div class="flex items-center space-x-4">
<div class="flex items-center">
<span class="mr-2 text-gray-600">Transition Time:</span>
<input type="number" id="transitionTime" min="1" max="60" value="5" class="w-16 px-2 py-1 border rounded">
<span class="ml-1 text-gray-600">sec</span>
</div>
<button id="saveSettings" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-1 rounded-lg transition">
<i class="fas fa-save mr-1"></i>Save
</button>
</div>
</div>
<div id="slidesList" class="space-y-3">
<!-- Slides will be listed here -->
<div class="text-center py-8 text-gray-500">
<i class="fas fa-folder-open text-4xl mb-2"></i>
<p>No slides available. Upload some slides to get started.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal for PPT Processing -->
<div id="processingModal" class="fixed inset-0 flex items-center justify-center z-50 hidden">
<div class="modal-overlay absolute inset-0"></div>
<div class="bg-white rounded-lg shadow-xl z-50 w-full max-w-md p-6">
<div class="text-center">
<div class="mb-4 text-blue-500">
<i class="fas fa-cog fa-spin text-4xl"></i>
</div>
<h3 class="text-xl font-semibold mb-2">Processing PowerPoint</h3>
<p class="text-gray-600 mb-4">Please wait while we extract slides from your presentation...</p>
<div class="w-full bg-gray-200 rounded-full h-2.5">
<div id="progressBar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
</div>
<p id="progressText" class="text-sm text-gray-500 mt-2">0% completed</p>
</div>
</div>
</div>
<script>
// App State
const state = {
slides: JSON.parse(localStorage.getItem('slides')) || [],
currentSlideIndex: 0,
transitionTime: parseInt(localStorage.getItem('transitionTime')) || 5,
isPlaying: true,
timer: null,
pptFile: null,
selectedImages: []
};
// DOM Elements
const carouselView = document.getElementById('carouselView');
const backofficeView = document.getElementById('backofficeView');
const toggleViewBtn = document.getElementById('toggleView');
const slidesContainer = document.getElementById('slidesContainer');
const slideIndicators = document.getElementById('slideIndicators');
const prevSlideBtn = document.getElementById('prevSlide');
const nextSlideBtn = document.getElementById('nextSlide');
const pausePlayBtn = document.getElementById('pausePlay');
const currentTransitionTime = document.getElementById('currentTransitionTime');
const imageUpload = document.getElementById('imageUpload');
const pptUpload = document.getElementById('pptUpload');
const imagePreview = document.getElementById('imagePreview');
const pptPreview = document.getElementById('pptPreview');
const pptFileName = document.getElementById('pptFileName');
const uploadSlidesBtn = document.getElementById('uploadSlides');
const slidesList = document.getElementById('slidesList');
const transitionTimeInput = document.getElementById('transitionTime');
const saveSettingsBtn = document.getElementById('saveSettings');
const processingModal = document.getElementById('processingModal');
const progressBar = document.getElementById('progressBar');
const progressText = document.getElementById('progressText');
// Initialize the app
function init() {
renderCarousel();
renderSlidesList();
startTimer();
updateCurrentTransitionTime();
// Set initial transition time in backoffice
transitionTimeInput.value = state.transitionTime;
}
// Toggle between carousel and backoffice views
toggleViewBtn.addEventListener('click', () => {
carouselView.classList.toggle('hidden');
backofficeView.classList.toggle('hidden');
if (backofficeView.classList.contains('hidden')) {
toggleViewBtn.innerHTML = '<i class="fas fa-cog mr-2"></i>Backoffice';
// When returning to carousel view, restart timer if playing
if (state.isPlaying) {
startTimer();
}
} else {
toggleViewBtn.innerHTML = '<i class="fas fa-images mr-2"></i>View Slideshow';
// When going to backoffice, pause the slideshow
pauseSlideshow();
}
});
// Carousel Navigation
prevSlideBtn.addEventListener('click', () => {
navigateSlide(-1);
resetTimer();
});
nextSlideBtn.addEventListener('click', () => {
navigateSlide(1);
resetTimer();
});
pausePlayBtn.addEventListener('click', togglePlayPause);
// Backoffice functionality
imageUpload.addEventListener('change', handleImageUpload);
pptUpload.addEventListener('change', handlePPTUpload);
uploadSlidesBtn.addEventListener('click', handleUploadSlides);
saveSettingsBtn.addEventListener('click', saveSettings);
// Render the carousel with current slides
function renderCarousel() {
slidesContainer.innerHTML = '';
slideIndicators.innerHTML = '';
if (state.slides.length === 0) {
// Show default message when no slides
slidesContainer.innerHTML = `
<div class="absolute inset-0 flex items-center justify-center bg-gradient-to-r from-blue-500 to-purple-600">
<div class="text-center text-white p-8">
<i class="fas fa-images text-6xl mb-4"></i>
<h2 class="text-3xl font-bold mb-2">No Slides Available</h2>
<p class="text-xl">Please add slides from the backoffice</p>
</div>
</div>
`;
return;
}
// Create slides
state.slides.forEach((slide, index) => {
const slideElement = document.createElement('div');
slideElement.className = `absolute inset-0 transition-opacity duration-500 ${index === 0 ? 'opacity-100' : 'opacity-0 pointer-events-none'}`;
slideElement.dataset.index = index;
if (slide.type === 'image') {
slideElement.innerHTML = `
<img src="${slide.content}" alt="Slide ${index + 1}" class="w-full h-full object-contain bg-black">
`;
} else {
// For PPT slides (converted to images)
slideElement.innerHTML = `
<img src="${slide.content}" alt="PPT Slide ${index + 1}" class="w-full h-full object-contain bg-white">
`;
}
slidesContainer.appendChild(slideElement);
// Create indicator
const indicator = document.createElement('button');
indicator.className = `w-3 h-3 rounded-full ${index === 0 ? 'bg-white' : 'bg-gray-400'} hover:bg-white transition`;
indicator.dataset.index = index;
indicator.addEventListener('click', () => {
goToSlide(index);
resetTimer();
});
slideIndicators.appendChild(indicator);
});
// Update current slide indicator
updateActiveIndicator();
}
// Render the slides list in backoffice
function renderSlidesList() {
slidesList.innerHTML = '';
if (state.slides.length === 0) {
slidesList.innerHTML = `
<div class="text-center py-8 text-gray-500">
<i class="fas fa-folder-open text-4xl mb-2"></i>
<p>No slides available. Upload some slides to get started.</p>
</div>
`;
return;
}
state.slides.forEach((slide, index) => {
const slideElement = document.createElement('div');
slideElement.className = 'flex items-center bg-gray-50 p-3 rounded-lg hover:bg-gray-100 transition';
slideElement.innerHTML = `
<div class="flex-shrink-0 w-16 h-16 bg-gray-200 rounded flex items-center justify-center overflow-hidden">
${slide.type === 'image' ?
`<img src="${slide.content}" alt="Thumbnail" class="w-full h-full object-cover">` :
`<i class="fas fa-file-powerpoint text-3xl text-purple-500"></i>`}
</div>
<div class="ml-4 flex-grow">
<div class="font-medium">${slide.type === 'image' ? 'Image Slide' : 'PPT Slide'} #${index + 1}</div>
<div class="text-sm text-gray-500">${slide.type === 'image' ? 'Image' : 'PowerPoint'}</div>
</div>
<div class="flex space-x-2">
<button class="move-up-btn p-2 text-gray-500 hover:text-blue-600 transition" data-index="${index}" ${index === 0 ? 'disabled' : ''}>
<i class="fas fa-arrow-up"></i>
</button>
<button class="move-down-btn p-2 text-gray-500 hover:text-blue-600 transition" data-index="${index}" ${index === state.slides.length - 1 ? 'disabled' : ''}>
<i class="fas fa-arrow-down"></i>
</button>
<button class="delete-btn p-2 text-gray-500 hover:text-red-600 transition" data-index="${index}">
<i class="fas fa-trash"></i>
</button>
</div>
`;
slidesList.appendChild(slideElement);
});
// Add event listeners to buttons
document.querySelectorAll('.move-up-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
const index = parseInt(e.currentTarget.dataset.index);
moveSlideUp(index);
});
});
document.querySelectorAll('.move-down-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
const index = parseInt(e.currentTarget.dataset.index);
moveSlideDown(index);
});
});
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', (e) => {
const index = parseInt(e.currentTarget.dataset.index);
deleteSlide(index);
});
});
}
// Move slide up in the order
function moveSlideUp(index) {
if (index > 0) {
[state.slides[index], state.slides[index - 1]] = [state.slides[index - 1], state.slides[index]];
saveToLocalStorage();
renderSlidesList();
// If we're moving the current slide, update the index
if (state.currentSlideIndex === index) {
state.currentSlideIndex--;
} else if (state.currentSlideIndex === index - 1) {
state.currentSlideIndex++;
}
renderCarousel();
}
}
// Move slide down in the order
function moveSlideDown(index) {
if (index < state.slides.length - 1) {
[state.slides[index], state.slides[index + 1]] = [state.slides[index + 1], state.slides[index]];
saveToLocalStorage();
renderSlidesList();
// If we're moving the current slide, update the index
if (state.currentSlideIndex === index) {
state.currentSlideIndex++;
} else if (state.currentSlideIndex === index + 1) {
state.currentSlideIndex--;
}
renderCarousel();
}
}
// Delete a slide
function deleteSlide(index) {
state.slides.splice(index, 1);
// Adjust current slide index if needed
if (state.currentSlideIndex >= index) {
state.currentSlideIndex = Math.max(0, state.currentSlideIndex - 1);
}
// If we deleted the last slide, reset to 0
if (state.slides.length > 0 && state.currentSlideIndex >= state.slides.length) {
state.currentSlideIndex = 0;
}
saveToLocalStorage();
renderCarousel();
renderSlidesList();
// If we deleted all slides, stop the timer
if (state.slides.length === 0) {
stopTimer();
}
}
// Navigate between slides
function navigateSlide(direction) {
if (state.slides.length === 0) return;
const newIndex = (state.currentSlideIndex + direction + state.slides.length) % state.slides.length;
goToSlide(newIndex);
}
// Go to specific slide
function goToSlide(index) {
if (state.slides.length === 0 || index < 0 || index >= state.slides.length) return;
// Hide current slide
const currentSlide = document.querySelector(`[data-index="${state.currentSlideIndex}"]`);
if (currentSlide) {
currentSlide.classList.remove('opacity-100');
currentSlide.classList.add('opacity-0', 'pointer-events-none');
}
// Show new slide
state.currentSlideIndex = index;
const newSlide = document.querySelector(`[data-index="${state.currentSlideIndex}"]`);
if (newSlide) {
newSlide.classList.remove('opacity-0', 'pointer-events-none');
newSlide.classList.add('opacity-100');
}
updateActiveIndicator();
}
// Update the active indicator
function updateActiveIndicator() {
document.querySelectorAll('#slideIndicators button').forEach((indicator, index) => {
indicator.className = `w-3 h-3 rounded-full ${index === state.currentSlideIndex ? 'bg-white' : 'bg-gray-400'} hover:bg-white transition`;
});
}
// Timer functions
function startTimer() {
if (state.slides.length <= 1) return;
stopTimer();
state.timer = setInterval(() => {
navigateSlide(1);
}, state.transitionTime * 1000);
}
function stopTimer() {
if (state.timer) {
clearInterval(state.timer);
state.timer = null;
}
}
function resetTimer() {
if (state.isPlaying) {
stopTimer();
startTimer();
}
}
// Toggle play/pause
function togglePlayPause() {
state.isPlaying = !state.isPlaying;
if (state.isPlaying) {
pausePlayBtn.innerHTML = '<i class="fas fa-pause mr-2"></i>Pause';
startTimer();
} else {
pausePlayBtn.innerHTML = '<i class="fas fa-play mr-2"></i>Play';
stopTimer();
}
}
function pauseSlideshow() {
if (state.isPlaying) {
state.isPlaying = false;
pausePlayBtn.innerHTML = '<i class="fas fa-play mr-2"></i>Play';
stopTimer();
}
}
// Handle image upload
function handleImageUpload(e) {
const files = Array.from(e.target.files);
state.selectedImages = files;
// Clear previous previews
imagePreview.innerHTML = '';
if (files.length === 0) {
imagePreview.classList.add('hidden');
return;
}
// Show previews
files.forEach(file => {
if (!file.type.match('image.*')) return;
const reader = new FileReader();
reader.onload = (event) => {
const imgContainer = document.createElement('div');
imgContainer.className = 'relative group';
imgContainer.innerHTML = `
<img src="${event.target.result}" alt="Preview" class="w-full h-24 object-cover rounded">
<div class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition">
<button class="remove-image-btn text-white p-1 rounded-full bg-red-500 hover:bg-red-600">
<i class="fas fa-times"></i>
</button>
</div>
`;
imagePreview.appendChild(imgContainer);
// Add event listener to remove button
imgContainer.querySelector('.remove-image-btn').addEventListener('click', () => {
state.selectedImages = state.selectedImages.filter(f => f !== file);
imgContainer.remove();
if (imagePreview.children.length === 0) {
imagePreview.classList.add('hidden');
}
});
};
reader.readAsDataURL(file);
});
imagePreview.classList.remove('hidden');
}
// Handle PPT upload
function handlePPTUpload(e) {
const file = e.target.files[0];
if (!file) return;
state.pptFile = file;
pptFileName.textContent = file.name;
pptPreview.classList.remove('hidden');
}
// Handle upload of all slides
function handleUploadSlides() {
// Process images first
if (state.selectedImages.length > 0) {
state.selectedImages.forEach(file => {
const reader = new FileReader();
reader.onload = (event) => {
state.slides.push({
type: 'image',
content: event.target.result
});
saveToLocalStorage();
renderCarousel();
renderSlidesList();
// Start timer if this is the first slide
if (state.slides.length === 1 && state.isPlaying) {
startTimer();
}
};
reader.readAsDataURL(file);
});
// Reset image upload
state.selectedImages = [];
imageUpload.value = '';
imagePreview.innerHTML = '';
imagePreview.classList.add('hidden');
}
// Process PPT file if present
if (state.pptFile) {
// In a real app, you would upload the PPT to a server for processing
// Here we'll simulate processing with a progress bar
showProcessingModal();
// Simulate processing (in a real app, this would be an API call)
let progress = 0;
const interval = setInterval(() => {
progress += 10;
updateProgressBar(progress);
if (progress >= 100) {
clearInterval(interval);
// Simulate extracting 5 slides from PPT
setTimeout(() => {
for (let i = 0; i < 5; i++) {
state.slides.push({
type: 'ppt',
content: `https://via.placeholder.com/800x600/4F46E5/FFFFFF?text=PPT+Slide+${state.slides.length + 1}`
});
}
saveToLocalStorage();
renderCarousel();
renderSlidesList();
// Start timer if this is the first slide
if (state.slides.length === 5 && state.isPlaying) {
startTimer();
}
hideProcessingModal();
// Reset PPT upload
state.pptFile = null;
pptUpload.value = '';
pptPreview.classList.add('hidden');
}, 500);
}
}, 200);
}
}
// Show processing modal
function showProcessingModal() {
processingModal.classList.remove('hidden');
progressBar.style.width = '0%';
progressText.textContent = '0% completed';
}
// Hide processing modal
function hideProcessingModal() {
processingModal.classList.add('hidden');
}
// Update progress bar
function updateProgressBar(progress) {
progress = Math.min(100, Math.max(0, progress));
progressBar.style.width = `${progress}%`;
progressText.textContent = `${progress}% completed`;
}
// Save settings (transition time)
function saveSettings() {
const newTime = parseInt(transitionTimeInput.value);
if (!isNaN(newTime) && newTime >= 1 && newTime <= 60) {
state.transitionTime = newTime;
state.isPlaying = true; // Auto-play when changing settings
saveToLocalStorage();
updateCurrentTransitionTime();
startTimer();
// Show success feedback
const originalText = saveSettingsBtn.innerHTML;
saveSettingsBtn.innerHTML = '<i class="fas fa-check mr-1"></i>Saved!';
saveSettingsBtn.classList.remove('bg-blue-600', 'hover:bg-blue-700');
saveSettingsBtn.classList.add('bg-green-600', 'hover:bg-green-700');
setTimeout(() => {
saveSettingsBtn.innerHTML = originalText;
saveSettingsBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
saveSettingsBtn.classList.add('bg-blue-600', 'hover:bg-blue-700');
}, 2000);
} else {
alert('Please enter a valid time between 1 and 60 seconds');
}
}
// Update the displayed transition time
function updateCurrentTransitionTime() {
currentTransitionTime.textContent = state.transitionTime;
}
// Save state to localStorage
function saveToLocalStorage() {
localStorage.setItem('slides', JSON.stringify(state.slides));
localStorage.setItem('transitionTime', state.transitionTime.toString());
}
// Initialize the app
init();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=zerocool19/carrusel" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>