First
This commit is contained in:
@@ -0,0 +1,535 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Нейрофотосессия - Галерея</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Главный контейнер - сплит экран */
|
||||
.split-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Левая половина - галерея фото (50%) */
|
||||
.gallery-section {
|
||||
flex: 1;
|
||||
width: 50%;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
max-height: 100vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Правая половина - QR код (50%) */
|
||||
.qr-section {
|
||||
flex: 1;
|
||||
width: 50%;
|
||||
background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
/* Заголовки */
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.main-title {
|
||||
font-size: 3rem;
|
||||
font-weight: 800;
|
||||
color: white;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 4px;
|
||||
text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.2rem;
|
||||
color: rgba(255,255,255,0.95);
|
||||
font-weight: 500;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
/* Галерея фото */
|
||||
.photos-gallery {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 25px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.photo-item {
|
||||
background: white;
|
||||
border-radius: 20px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
animation: fadeInUp 0.5s ease;
|
||||
}
|
||||
|
||||
.photo-item:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 15px 40px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.photo-item img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.photo-info {
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.photo-date {
|
||||
color: #667eea;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.download-btn {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 25px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.download-btn:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* QR секция */
|
||||
.qr-container {
|
||||
background: white;
|
||||
border-radius: 30px;
|
||||
padding: 40px;
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 50px rgba(0,0,0,0.3);
|
||||
animation: fadeInUp 0.5s ease;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
.qr-title {
|
||||
font-size: 1.8rem;
|
||||
font-weight: 700;
|
||||
color: #667eea;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.qr-subtitle {
|
||||
font-size: 1rem;
|
||||
color: #666;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.qr-code-wrapper {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
display: inline-block;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.qr-code-wrapper img {
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.current-photo-preview {
|
||||
margin-top: 20px;
|
||||
padding-top: 20px;
|
||||
border-top: 2px solid #eee;
|
||||
}
|
||||
|
||||
.current-photo-preview img {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
object-fit: cover;
|
||||
border-radius: 10px;
|
||||
margin-top: 10px;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.qr-instruction {
|
||||
font-size: 14px;
|
||||
color: #888;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
color: white;
|
||||
padding: 60px 20px;
|
||||
font-size: 1.2rem;
|
||||
background: rgba(255,255,255,0.1);
|
||||
border-radius: 20px;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.empty-state-icon {
|
||||
font-size: 64px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Анимации */
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Адаптивность для мобильных устройств */
|
||||
@media (max-width: 768px) {
|
||||
.split-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.gallery-section,
|
||||
.qr-section {
|
||||
width: 100%;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.gallery-section {
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.qr-section {
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.main-title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.qr-container {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.qr-code-wrapper img {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Стиль скроллбара */
|
||||
.gallery-section::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.gallery-section::-webkit-scrollbar-track {
|
||||
background: rgba(255,255,255,0.2);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.gallery-section::-webkit-scrollbar-thumb {
|
||||
background: rgba(255,255,255,0.5);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.gallery-section::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255,255,255,0.8);
|
||||
}
|
||||
|
||||
/* Уведомление о новом фото */
|
||||
.notification {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
background: #48bb78;
|
||||
color: white;
|
||||
padding: 12px 24px;
|
||||
border-radius: 50px;
|
||||
font-weight: 600;
|
||||
animation: slideInRight 0.5s ease;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 5px 20px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
@keyframes slideInRight {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="split-container">
|
||||
<!-- Левая половина: Галерея фото -->
|
||||
<div class="gallery-section">
|
||||
<div class="header">
|
||||
<div class="main-title">НЕЙРОФОТОСЕССИЯ</div>
|
||||
<div class="subtitle">Молодежный Парламент ДНР</div>
|
||||
</div>
|
||||
<div id="gallery" class="photos-gallery">
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">📸</div>
|
||||
<p>Здесь появятся опубликованные фото</p>
|
||||
<p style="font-size: 0.9rem; margin-top: 10px;">Оператор опубликует фото, и они сразу появятся здесь</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Правая половина: QR Code -->
|
||||
<div class="qr-section">
|
||||
<div id="qrContainer" class="qr-container">
|
||||
<div class="qr-title">📱 СКАЧАТЬ ФОТО</div>
|
||||
<div class="qr-subtitle">Отсканируйте QR-код, чтобы скачать последнее фото</div>
|
||||
<div id="qrCodeWrapper" class="qr-code-wrapper">
|
||||
<div id="qrPlaceholder" style="width: 250px; height: 250px; display: flex; align-items: center; justify-content: center; background: #f5f5f5; border-radius: 20px;">
|
||||
<span style="color: #999;">Ожидание фото...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="currentPhotoPreview" class="current-photo-preview" style="display: none;">
|
||||
<div style="font-size: 12px; color: #888;">Текущее фото:</div>
|
||||
<img id="currentPhotoImg" src="" alt="Текущее фото">
|
||||
</div>
|
||||
<div class="qr-instruction">
|
||||
✨ QR-код обновляется автоматически при публикации нового фото
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let currentPhotos = [];
|
||||
let updateInterval = null;
|
||||
let lastPhotoId = null;
|
||||
|
||||
// Загрузка опубликованных фото
|
||||
async function loadPublishedPhotos() {
|
||||
try {
|
||||
const response = await fetch('/get-published-photos');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.photos && data.photos.length > 0) {
|
||||
updateGallery(data.photos);
|
||||
|
||||
// Проверяем, есть ли новое фото
|
||||
if (lastPhotoId !== data.photos[data.photos.length - 1]?.id) {
|
||||
const lastPhoto = data.photos[data.photos.length - 1];
|
||||
if (lastPhoto && lastPhoto.id !== lastPhotoId) {
|
||||
lastPhotoId = lastPhoto.id;
|
||||
showNotification('Новое фото опубликовано!');
|
||||
updateQRCode(lastPhoto);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updateGallery([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки фото:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Обновление галереи
|
||||
function updateGallery(photos) {
|
||||
const gallery = document.getElementById('gallery');
|
||||
|
||||
if (!photos || photos.length === 0) {
|
||||
gallery.innerHTML = `<div class="empty-state">
|
||||
<div class="empty-state-icon">📸</div>
|
||||
<p>Здесь появятся опубликованные фото</p>
|
||||
<p style="font-size: 0.9rem; margin-top: 10px;">Оператор опубликует фото, и они сразу появятся здесь</p>
|
||||
</div>`;
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем наличие новых фото
|
||||
const newPhotos = photos.filter(photo => !currentPhotos.find(p => p.id === photo.id));
|
||||
|
||||
if (newPhotos.length > 0 || currentPhotos.length !== photos.length) {
|
||||
// Перестраиваем галерею
|
||||
gallery.innerHTML = '';
|
||||
|
||||
// Показываем фото в обратном порядке (новые сверху)
|
||||
[...photos].reverse().forEach(photo => {
|
||||
const photoDiv = createPhotoElement(photo);
|
||||
gallery.appendChild(photoDiv);
|
||||
});
|
||||
|
||||
currentPhotos = [...photos];
|
||||
|
||||
// Если есть новое фото, обновляем QR для последнего
|
||||
if (newPhotos.length > 0) {
|
||||
updateQRCode(newPhotos[0]);
|
||||
|
||||
// Прокручиваем галерею к новому фото
|
||||
setTimeout(() => {
|
||||
const firstPhoto = gallery.firstChild;
|
||||
if (firstPhoto) {
|
||||
firstPhoto.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}, 100);
|
||||
} else if (photos.length > 0) {
|
||||
// Обновляем QR для последнего фото
|
||||
updateQRCode(photos[photos.length - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Создание элемента фото
|
||||
function createPhotoElement(photo) {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'photo-item';
|
||||
|
||||
const downloadUrl = `${window.location.origin}/download-photo/${photo.id}`;
|
||||
const date = new Date(photo.published_at);
|
||||
const formattedDate = date.toLocaleString('ru-RU', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
|
||||
div.innerHTML = `
|
||||
<img src="${photo.path}" alt="Фото" loading="lazy" onclick="viewFullImage('${photo.path}')">
|
||||
<div class="photo-info">
|
||||
<div class="photo-date">📅 ${formattedDate}</div>
|
||||
<a href="${downloadUrl}" class="download-btn" download>💾 Скачать фото</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
return div;
|
||||
}
|
||||
|
||||
// Просмотр полноразмерного изображения
|
||||
window.viewFullImage = function(url) {
|
||||
const modal = document.createElement('div');
|
||||
modal.style.position = 'fixed';
|
||||
modal.style.top = '0';
|
||||
modal.style.left = '0';
|
||||
modal.style.width = '100%';
|
||||
modal.style.height = '100%';
|
||||
modal.style.backgroundColor = 'rgba(0,0,0,0.95)';
|
||||
modal.style.zIndex = '1001';
|
||||
modal.style.display = 'flex';
|
||||
modal.style.alignItems = 'center';
|
||||
modal.style.justifyContent = 'center';
|
||||
modal.style.cursor = 'pointer';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = url;
|
||||
img.style.maxWidth = '90%';
|
||||
img.style.maxHeight = '90%';
|
||||
img.style.borderRadius = '10px';
|
||||
img.style.objectFit = 'contain';
|
||||
|
||||
modal.appendChild(img);
|
||||
modal.onclick = () => modal.remove();
|
||||
document.body.appendChild(modal);
|
||||
};
|
||||
|
||||
// Обновление QR-кода
|
||||
function updateQRCode(photo) {
|
||||
if (!photo) return;
|
||||
|
||||
const downloadUrl = `${window.location.origin}/download-photo/${photo.id}`;
|
||||
const qrWrapper = document.getElementById('qrCodeWrapper');
|
||||
const previewContainer = document.getElementById('currentPhotoPreview');
|
||||
const previewImg = document.getElementById('currentPhotoImg');
|
||||
|
||||
// Создаем QR код через API
|
||||
const qrImg = document.createElement('img');
|
||||
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=250x250&margin=10&data=${encodeURIComponent(downloadUrl)}`;
|
||||
qrImg.alt = 'QR Code';
|
||||
qrImg.style.width = '250px';
|
||||
qrImg.style.height = '250px';
|
||||
qrImg.style.borderRadius = '10px';
|
||||
|
||||
qrWrapper.innerHTML = '';
|
||||
qrWrapper.appendChild(qrImg);
|
||||
|
||||
// Обновляем превью текущего фото
|
||||
previewImg.src = photo.path;
|
||||
previewContainer.style.display = 'block';
|
||||
|
||||
// Добавляем информацию о ссылке в консоль для отладки
|
||||
console.log('📱 QR код обновлен для фото:', downloadUrl);
|
||||
}
|
||||
|
||||
// Показать уведомление о новом фото
|
||||
function showNotification(message) {
|
||||
// Удаляем старые уведомления
|
||||
const oldNotification = document.querySelector('.notification');
|
||||
if (oldNotification) {
|
||||
oldNotification.remove();
|
||||
}
|
||||
|
||||
const notification = document.createElement('div');
|
||||
notification.className = 'notification';
|
||||
notification.innerHTML = `✨ ${message}`;
|
||||
document.body.appendChild(notification);
|
||||
|
||||
setTimeout(() => {
|
||||
notification.remove();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Запускаем периодическое обновление
|
||||
loadPublishedPhotos();
|
||||
updateInterval = setInterval(loadPublishedPhotos, 3000);
|
||||
|
||||
// Обработка закрытия страницы
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (updateInterval) {
|
||||
clearInterval(updateInterval);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user