This commit is contained in:
Fabio 2026-02-21 13:27:29 +01:00
parent 889cfea6cc
commit a7e1440630
3 changed files with 58 additions and 18 deletions

54
app.js
View file

@ -63,6 +63,14 @@ function renderGallery(photos) {
thumbDiv.appendChild(img); thumbDiv.appendChild(img);
// ICONA PLAY SE È VIDEO
if (photo.mime_type.startsWith("video/")) {
const play = document.createElement("div");
play.className = "play-icon";
play.textContent = "▶";
thumbDiv.appendChild(play);
}
// Fallback se thub2 manca // Fallback se thub2 manca
const preview = photo.thub2 const preview = photo.thub2
? `https://prova.patachina.it/${photo.thub2}` ? `https://prova.patachina.it/${photo.thub2}`
@ -82,28 +90,48 @@ function renderGallery(photos) {
// =============================== // ===============================
// MODALE IMMAGINE // MODALE (FOTO + VIDEO)
// =============================== // ===============================
const modal = document.getElementById('modal'); const modal = document.getElementById('modal');
const modalImg = document.getElementById('modalImage'); const modalImg = document.getElementById('modalImage'); // NON USATO PIÙ
const modalClose = document.getElementById('modalClose'); const modalClose = document.getElementById('modalClose');
function openModal(srcOriginal, srcPreview, photo) { function openModal(srcOriginal, srcPreview, photo) {
currentPhoto = photo; currentPhoto = photo;
modalImg.src = srcPreview; const container = document.getElementById("modalMediaContainer");
modal.classList.add('open'); container.innerHTML = ""; // pulizia
const img = new Image(); if (photo.mime_type.startsWith("video/")) {
img.src = srcOriginal; // VIDEO
img.onload = () => { const video = document.createElement("video");
modalImg.src = srcOriginal; video.src = srcOriginal;
}; video.controls = true;
video.autoplay = true;
video.style.maxWidth = "100%";
video.style.maxHeight = "100%";
container.appendChild(video);
} else {
// FOTO
const img = document.createElement("img");
img.src = srcPreview;
img.style.maxWidth = "100%";
img.style.maxHeight = "100%";
container.appendChild(img);
const full = new Image();
full.src = srcOriginal;
full.onload = () => {
img.src = srcOriginal;
};
}
modal.classList.add('open');
} }
function closeModal() { function closeModal() {
modal.classList.remove('open'); modal.classList.remove('open');
modalImg.src = ''; document.getElementById("modalMediaContainer").innerHTML = "";
} }
modalClose.addEventListener('click', closeModal); modalClose.addEventListener('click', closeModal);
@ -121,13 +149,9 @@ const infoBtn = document.getElementById('modalInfoBtn');
infoBtn.addEventListener('click', () => { infoBtn.addEventListener('click', () => {
if (!currentPhoto) return; if (!currentPhoto) return;
// Gestione sicura GPS null
const gps = currentPhoto.gps || { lat: '-', lng: '-', alt: '-' }; const gps = currentPhoto.gps || { lat: '-', lng: '-', alt: '-' };
// Cartella estratta dal path
const folder = currentPhoto.path.split('/').slice(2, -1).join('/'); const folder = currentPhoto.path.split('/').slice(2, -1).join('/');
// HTML del pannello
infoPanel.innerHTML = ` infoPanel.innerHTML = `
<h3>Informazioni</h3> <h3>Informazioni</h3>
@ -149,7 +173,6 @@ infoBtn.addEventListener('click', () => {
infoPanel.classList.add('open'); infoPanel.classList.add('open');
// Se la foto ha coordinate GPS, crea la mappa
if (gps.lat !== '-' && gps.lng !== '-') { if (gps.lat !== '-' && gps.lng !== '-') {
setTimeout(() => { setTimeout(() => {
const map = L.map('infoMap', { const map = L.map('infoMap', {
@ -166,7 +189,6 @@ infoBtn.addEventListener('click', () => {
} }
}); });
// Chiudi pannello cliccando fuori
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
if (!infoPanel.classList.contains('open')) return; if (!infoPanel.classList.contains('open')) return;

View file

@ -21,11 +21,14 @@
<div id="gallery" class="gallery"></div> <div id="gallery" class="gallery"></div>
</main> </main>
<!-- Modal Immagine --> <!-- Modal Media (foto + video) -->
<div id="modal" class="modal"> <div id="modal" class="modal">
<div class="modal-content"> <div class="modal-content">
<div class="modal-close" id="modalClose">×</div> <div class="modal-close" id="modalClose">×</div>
<img id="modalImage" src="" alt="">
<!-- CONTENITORE DINAMICO -->
<div id="modalMediaContainer"></div>
<div class="modal-info-btn" id="modalInfoBtn"></div> <div class="modal-info-btn" id="modalInfoBtn"></div>
</div> </div>
</div> </div>

View file

@ -140,3 +140,18 @@ header {
background: #ddd; background: #ddd;
outline: none; outline: none;
} }
.video-thumb {
position: relative;
}
.play-icon {
position: absolute;
bottom: 8px;
right: 8px;
background: rgba(0,0,0,0.6);
color: white;
padding: 4px 6px;
border-radius: 4px;
font-size: 14px;
}