Galerie des Véhicules Miniatures : Voitures, Motos & Trains

`; } descEl.innerHTML = authorLink + (photo.description ? vmNl2brSafe(photo.description) : ''); const photoId = photo.id; const likes = parseInt(photo.likes_count) || 0; const isLiked = localStorage.getItem('vm_liked_' + photoId) ? 'liked' : ''; const safeImg = String(photo.img_url || '').replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/[\r\n]/g, ' '); const safeDesc = photo.description ? String(photo.description).replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/[\r\n]/g, ' ').substring(0, 150) : ''; shareEl.innerHTML = ` `; imgEl.style.opacity = '1'; }, 150); const prevBtn = document.getElementById('vm-lb-prev'); const nextBtn = document.getElementById('vm-lb-next'); if(prevBtn) prevBtn.style.display = currentPhotoIndex === 0 ? 'none' : 'flex'; if(nextBtn) nextBtn.style.display = currentPhotoIndex === currentGalleryPhotos.length - 1 ? 'none' : 'flex'; } function openVmLightbox(index) { currentPhotoIndex = index; initLightboxUI(); updateLightboxContent(); const lb = document.getElementById('vm-lightbox'); lb.style.display = 'flex'; setTimeout(() => lb.classList.add('active'), 10); document.body.style.overflow = 'hidden'; document.getElementById('vm-lightbox-img').style.transition = 'opacity 0.2s ease-in-out'; } function closeVmLightbox() { const lb = document.getElementById('vm-lightbox'); lb.classList.remove('active'); setTimeout(() => { lb.style.display = 'none'; document.getElementById('vm-lightbox-img').src = ''; document.body.style.overflow = ''; }, 300); } function nextPhoto(e) { if(e) e.stopPropagation(); if (currentPhotoIndex 0) { currentPhotoIndex--; updateLightboxContent(); } } document.addEventListener('keydown', e => { const lb = document.getElementById('vm-lightbox'); if (lb && lb.style.display === 'flex') { if (e.key === 'Escape') closeVmLightbox(); if (e.key === 'ArrowRight') nextPhoto(); if (e.key === 'ArrowLeft') prevPhoto(); } });