Spaces:
Running
Running
Download index.html from Faist1/6v-website: direct link, hf CLI and curl.
- Browser
- Download file 27.6 kB
-
https://huggingface.co/spaces/Faist1/6v-website/resolve/main/index.html
- Command line
-
hf download hf://spaces/Faist1/6v-website/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Faist1/6v-website/resolve/main/index.html
27.6 kB
| <html lang="ru"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Photo Groups</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> | |
| .group-card:hover .group-actions { | |
| opacity: 1; | |
| } | |
| .fade-in { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .photo-container { | |
| columns: 3; | |
| column-gap: 1rem; | |
| } | |
| @media (max-width: 768px) { | |
| .photo-container { | |
| columns: 2; | |
| } | |
| } | |
| @media (max-width: 480px) { | |
| .photo-container { | |
| columns: 1; | |
| } | |
| } | |
| .drop-zone { | |
| border: 2px dashed #ccc; | |
| border-radius: 8px; | |
| padding: 2rem; | |
| text-align: center; | |
| transition: all 0.3s; | |
| } | |
| .drop-zone.active { | |
| border-color: #3b82f6; | |
| background-color: #f0f7ff; | |
| } | |
| .preview-image { | |
| max-width: 100%; | |
| max-height: 200px; | |
| margin-bottom: 1rem; | |
| } | |
| .notification { | |
| position: fixed; | |
| bottom: 20px; | |
| right: 20px; | |
| background: #4CAF50; | |
| color: white; | |
| padding: 15px; | |
| border-radius: 5px; | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | |
| z-index: 1000; | |
| display: none; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 min-h-screen"> | |
| <!-- Notification --> | |
| <div id="notification" class="notification"> | |
| Данные обновлены! | |
| </div> | |
| <!-- Admin Login Modal --> | |
| <div id="adminLoginModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50" style="display: none;"> | |
| <div class="bg-white rounded-lg p-6 w-full max-w-md fade-in"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-2xl font-bold">Вход администратора</h2> | |
| <button onclick="closeModal('adminLoginModal')" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-4"> | |
| <label class="block text-gray-700 mb-2">Пароль администратора</label> | |
| <input type="password" id="adminPassword" class="w-full px-3 py-2 border rounded-lg" placeholder="Введите пароль"> | |
| </div> | |
| <button onclick="adminLogin()" class="w-full bg-blue-500 text-white py-2 rounded-lg hover:bg-blue-600 transition">Войти</button> | |
| </div> | |
| </div> | |
| <!-- Create Group Modal --> | |
| <div id="createGroupModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50" style="display: none;"> | |
| <div class="bg-white rounded-lg p-6 w-full max-w-md fade-in"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-2xl font-bold">Создать группу</h2> | |
| <button onclick="closeModal('createGroupModal')" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="mb-4"> | |
| <label class="block text-gray-7 mb-2">Название группы</label> | |
| <input type="text" id="groupName" class="w-full px-3 py-2 border rounded-lg"> | |
| </div> | |
| <div class="mb-4"> | |
| <label class="block text-gray-7 mb-2">Описание</label> | |
| <textarea id="groupDescription" class="w-full px-3 py-2 border rounded-lg"></textarea> | |
| </div> | |
| <button onclick="createGroup()" class="w-full bg-green-500 text-white py-2 rounded-lg hover:bg-green-600 transition">Создать</button> | |
| </div> | |
| </div> | |
| <!-- Add Photo Modal --> | |
| <div id="addPhotoModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50" style="display: none;"> | |
| <div class="bg-white rounded-lg p-6 w-full max-w-md fade-in"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h2 class="text-2xl font-bold">Добавить фото</h2> | |
| <button onclick="closeModal('addPhotoModal')" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div id="dropZone" class="drop-zone mb-4"> | |
| <div id="dropContent"> | |
| <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-2"></i> | |
| <p class="text-gray-600">Перетащите фото сюда или</p> | |
| <label for="fileInput" class="cursor-pointer text-blue-500 hover:text-blue-700"> | |
| выберите файл | |
| </label> | |
| <input type="file" id="fileInput" accept="image/*" class="hidden" multiple> | |
| </div> | |
| <div id="previewContainer" class="hidden"> | |
| <img id="previewImage" class="preview-image"> | |
| <p id="fileName" class="text-sm text-gray-600"></p> | |
| </div> | |
| </div> | |
| <div class="mb-4"> | |
| <label class="block text-gray-7 mb-2">Описание</label> | |
| <input type="text" id="photoDescription" class="w-full px-3 py-2 border rounded-lg"> | |
| </div> | |
| <button onclick="addPhoto()" class="w-full bg-blue-500 text-white py-2 rounded-lg hover:bg-blue-600 transition">Добавить</button> | |
| </div> | |
| </div> | |
| <!-- Header --> | |
| <header class="bg-white shadow-sm" id="mainHeader"> | |
| <div class="container mx-auto px-4 py-4 flex justify-between items-center"> | |
| <h1 class="text-2xl font-bold text-blue-600">Photo Groups</h1> | |
| <div id="userMenu"> | |
| <div class="flex items-center space-x-4"> | |
| <span id="usernameDisplay" class="font-medium"></span> | |
| <button onclick="showLogoutMenu()" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-sign-out-alt"></i> | |
| </button> | |
| <div id="logoutMenu" class="hidden absolute bg-white shadow-lg rounded-md mt-2 py-1 right-4 z-50"> | |
| <button onclick="logout()" class="block w-full text-left px-4 py-2 hover:bg-gray-100">Выйти</button> | |
| <button onclick="showAdminLogin()" class="block w-full text-left px-4 py-2 hover:bg-gray-100">Войти как администратор</button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-8" id="mainContent"> | |
| <!-- Groups Section --> | |
| <section id="groupsSection"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h2 class="text-xl font-semibold">Группы</h2> | |
| <button id="createGroupBtn" onclick="openModal('createGroupModal')" class="bg-green-500 text-white px-4 py-2 rounded-lg hover:bg-green-600 transition" style="display: none;"> | |
| <i class="fas fa-plus mr-2"></i>Создать группу | |
| </button> | |
| </div> | |
| <div id="groupsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> | |
| <!-- Groups will be loaded here --> | |
| </div> | |
| </section> | |
| <!-- Group Photos Section --> | |
| <section id="groupPhotosSection" class="mt-12" style="display: none;"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h2 id="groupTitle" class="text-xl font-semibold"></h2> | |
| <button id="addPhotoBtn" onclick="openModal('addPhotoModal')" class="bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition" style="display: none;"> | |
| <i class="fas fa-plus mr-2"></i>Добавить фото | |
| </button> | |
| </div> | |
| <div id="photosContainer" class="photo-container"> | |
| <!-- Photos will be loaded here --> | |
| </div> | |
| </section> | |
| </main> | |
| <script> | |
| // State | |
| let currentUser = { | |
| username: 'user', | |
| isAdmin: false | |
| }; | |
| let groups = []; | |
| let currentGroupId = null; | |
| let selectedFile = null; | |
| let lastUpdateTime = 0; | |
| let checkInterval = null; | |
| // DOM Elements | |
| const userMenu = document.getElementById('userMenu'); | |
| const usernameDisplay = document.getElementById('usernameDisplay'); | |
| const createGroupBtn = document.getElementById('createGroupBtn'); | |
| const addPhotoBtn = document.getElementById('addPhotoBtn'); | |
| const groupsContainer = document.getElementById('groupsContainer'); | |
| const groupPhotosSection = document.getElementById('groupPhotosSection'); | |
| const groupTitle = document.getElementById('groupTitle'); | |
| const photosContainer = document.getElementById('photosContainer'); | |
| const mainHeader = document.getElementById('mainHeader'); | |
| const mainContent = document.getElementById('mainContent'); | |
| const adminLoginModal = document.getElementById('adminLoginModal'); | |
| const dropZone = document.getElementById('dropZone'); | |
| const dropContent = document.getElementById('dropContent'); | |
| const previewContainer = document.getElementById('previewContainer'); | |
| const previewImage = document.getElementById('previewImage'); | |
| const fileName = document.getElementById('fileName'); | |
| const fileInput = document.getElementById('fileInput'); | |
| const notification = document.getElementById('notification'); | |
| const logoutMenu = document.getElementById('logoutMenu'); | |
| // Initialize data from localStorage or use default | |
| function initializeData() { | |
| const savedData = localStorage.getItem('photoGroupsData'); | |
| const savedTimestamp = localStorage.getItem('photoGroupsTimestamp'); | |
| if (savedData) { | |
| groups = JSON.parse(savedData); | |
| lastUpdateTime = savedTimestamp ? parseInt(savedTimestamp) : 0; | |
| } else { | |
| // Default data | |
| groups = [ | |
| { | |
| id: 1, | |
| name: "Природа", | |
| description: "Красивые пейзажи со всего мира", | |
| owner: "admin", | |
| photos: [ | |
| { id: 1, url: "https://images.unsplash.com/photo-1506744038136-46273834b3fb", description: "Горы и озеро" }, | |
| { id: 2, url: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05", description: "Лесной туман" } | |
| ] | |
| }, | |
| { | |
| id: 2, | |
| name: "Города", | |
| description: "Фотографии городской архитектуры", | |
| owner: "admin", | |
| photos: [ | |
| { id: 3, url: "https://images.unsplash.com/photo-1496442226666-8d4d0e62e6e9", description: "Нью-Йорк" }, | |
| { id: 4, url: "https://images.unsplash.com/photo-1519501025264-65ba15a82390", description: "Токио ночью" } | |
| ] | |
| } | |
| ]; | |
| saveData(); | |
| } | |
| } | |
| // Save data to localStorage | |
| function saveData() { | |
| const timestamp = Date.now(); | |
| localStorage.setItem('photoGroupsData', JSON.stringify(groups)); | |
| localStorage.setItem('photoGroupsTimestamp', timestamp.toString()); | |
| lastUpdateTime = timestamp; | |
| } | |
| // Check for updates periodically | |
| function startUpdateChecker() { | |
| if (checkInterval) clearInterval(checkInterval); | |
| checkInterval = setInterval(() => { | |
| const savedTimestamp = localStorage.getItem('photoGroupsTimestamp'); | |
| if (savedTimestamp && parseInt(savedTimestamp) > lastUpdateTime) { | |
| // Data has been updated by someone else | |
| const savedData = localStorage.getItem('photoGroupsData'); | |
| if (savedData) { | |
| groups = JSON.parse(savedData); | |
| lastUpdateTime = parseInt(savedTimestamp); | |
| // Update UI | |
| renderGroups(); | |
| if (currentGroupId) { | |
| renderPhotos(); | |
| } | |
| // Show notification | |
| showNotification(); | |
| } | |
| } | |
| }, 3000); // Check every 3 seconds | |
| } | |
| // Show notification | |
| function showNotification() { | |
| notification.style.display = 'block'; | |
| setTimeout(() => { | |
| notification.style.display = 'none'; | |
| }, 3000); | |
| } | |
| // Modal functions | |
| function openModal(modalId) { | |
| document.getElementById(modalId).style.display = 'flex'; | |
| if (modalId === 'addPhotoModal') { | |
| resetFileInput(); | |
| } | |
| } | |
| function closeModal(modalId) { | |
| document.getElementById(modalId).style.display = 'none'; | |
| } | |
| // Auth functions | |
| function adminLogin() { | |
| const password = document.getElementById('adminPassword').value; | |
| if (password === '6v_2025') { | |
| currentUser = { | |
| username: 'admin', | |
| isAdmin: true | |
| }; | |
| // Update UI | |
| usernameDisplay.textContent = currentUser.username; | |
| createGroupBtn.style.display = 'block'; | |
| // Close admin login modal | |
| closeModal('adminLoginModal'); | |
| // Clear password field | |
| document.getElementById('adminPassword').value = ''; | |
| // Re-render groups to show admin controls | |
| renderGroups(); | |
| showNotification('Вы вошли как администратор'); | |
| } else { | |
| alert('Неверный пароль администратора'); | |
| } | |
| } | |
| function showAdminLogin() { | |
| logoutMenu.style.display = 'none'; | |
| openModal('adminLoginModal'); | |
| } | |
| function logout() { | |
| logoutMenu.style.display = 'none'; | |
| currentUser = { | |
| username: 'user', | |
| isAdmin: false | |
| }; | |
| // Update UI | |
| usernameDisplay.textContent = currentUser.username; | |
| createGroupBtn.style.display = 'none'; | |
| // Re-render groups to hide admin controls | |
| renderGroups(); | |
| showNotification('Вы вошли как пользователь'); | |
| } | |
| function showLogoutMenu() { | |
| logoutMenu.style.display = logoutMenu.style.display === 'block' ? 'none' : 'block'; | |
| } | |
| // Close logout menu when clicking outside | |
| document.addEventListener('click', function(event) { | |
| if (!userMenu.contains(event.target)) { | |
| logoutMenu.style.display = 'none'; | |
| } | |
| }); | |
| // Group functions | |
| function createGroup() { | |
| const name = document.getElementById('groupName').value; | |
| const description = document.getElementById('groupDescription').value; | |
| if (!name) { | |
| alert('Введите название группы'); | |
| return; | |
| } | |
| const newGroup = { | |
| id: Date.now(), // Use timestamp as ID to ensure uniqueness | |
| name, | |
| description, | |
| owner: currentUser.username, | |
| photos: [] | |
| }; | |
| groups.push(newGroup); | |
| saveData(); // Save to localStorage | |
| renderGroups(); | |
| closeModal('createGroupModal'); | |
| // Clear fields | |
| document.getElementById('groupName').value = ''; | |
| document.getElementById('groupDescription').value = ''; | |
| } | |
| function renderGroups() { | |
| if (!currentUser) return; | |
| groupsContainer.innerHTML = ''; | |
| groups.forEach(group => { | |
| const isOwner = group.owner === currentUser.username; | |
| const groupCard = document.createElement('div'); | |
| groupCard.className = 'bg-white rounded-lg shadow-md overflow-hidden group-card transition hover:shadow-lg'; | |
| groupCard.innerHTML = ` | |
| <div class="relative"> | |
| ${group.photos.length > 0 ? | |
| `<img src="${group.photos[0].url}" alt="${group.name}" class="w-full h-48 object-cover">` : | |
| `<div class="w-full h-48 bg-gray-200 flex items-center justify-center text-gray-500"> | |
| <i class="fas fa-image fa-2x"></i> | |
| </div>` | |
| } | |
| <div class="group-actions absolute top-2 right-2 opacity-0 transition"> | |
| ${isOwner ? ` | |
| <button onclick="deleteGroup(${group.id}, event)" class="bg-red-500 text-white p-2 rounded-full hover:bg-red-600 mr-1"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| ` : ''} | |
| </div> | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold text-lg mb-1">${group.name}</h3> | |
| <p class="text-gray-600 text-sm mb-2">${group.description || 'Нет описания'}</p> | |
| <div class="flex justify-between items-center text-sm text-gray-500"> | |
| <span>${group.photos.length} фото</span> | |
| <button onclick="viewGroup(${group.id})" class="text-blue-500 hover:text-blue-700"> | |
| Посмотреть <i class="fas fa-arrow-right ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| groupsContainer.appendChild(groupCard); | |
| }); | |
| } | |
| function deleteGroup(groupId, event) { | |
| event.stopPropagation(); | |
| if (confirm('Вы уверены, что хотите удалить эту группу?')) { | |
| groups = groups.filter(group => group.id !== groupId); | |
| saveData(); // Save to localStorage | |
| renderGroups(); | |
| if (currentGroupId === groupId) { | |
| groupPhotosSection.style.display = 'none'; | |
| } | |
| } | |
| } | |
| function viewGroup(groupId) { | |
| currentGroupId = groupId; | |
| const group = groups.find(g => g.id === groupId); | |
| groupTitle.textContent = group.name; | |
| groupPhotosSection.style.display = 'block'; | |
| // Показываем кнопку "Добавить фото" только для администратора | |
| if (currentUser.isAdmin) { | |
| addPhotoBtn.style.display = 'block'; | |
| } else { | |
| addPhotoBtn.style.display = 'none'; | |
| } | |
| renderPhotos(); | |
| // Scroll to photos section | |
| groupPhotosSection.scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| // Photo functions | |
| function addPhoto() { | |
| // Проверяем, является ли пользователь администратором | |
| if (!currentUser.isAdmin) { | |
| alert('Только администратор может добавлять фото'); | |
| return; | |
| } | |
| const description = document.getElementById('photoDescription').value; | |
| if (!selectedFile) { | |
| alert('Пожалуйста, выберите фото'); | |
| return; | |
| } | |
| const group = groups.find(g => g.id === currentGroupId); | |
| if (group) { | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| group.photos.push({ | |
| id: Date.now(), // Use timestamp as ID to ensure uniqueness | |
| url: e.target.result, | |
| description | |
| }); | |
| saveData(); // Save to localStorage | |
| renderPhotos(); | |
| closeModal('addPhotoModal'); | |
| // Clear fields | |
| document.getElementById('photoDescription').value = ''; | |
| resetFileInput(); | |
| }; | |
| reader.readAsDataURL(selectedFile); | |
| } | |
| } | |
| function renderPhotos() { | |
| const group = groups.find(g => g.id === currentGroupId); | |
| if (!group) return; | |
| photosContainer.innerHTML = ''; | |
| group.photos.forEach(photo => { | |
| const photoCard = document.createElement('div'); | |
| photoCard.className = 'mb-4 break-inside-avoid'; | |
| photoCard.innerHTML = ` | |
| <div class="bg-white rounded-lg shadow-md overflow-hidden"> | |
| <img src="${photo.url}" alt="${photo.description || 'Фото'}" class="w-full h-auto"> | |
| <div class="p-3"> | |
| <p class="text-gray-700">${photo.description || 'Нет описания'}</p> | |
| ${currentUser.isAdmin ? ` | |
| <div class="mt-2 flex justify-end"> | |
| <button onclick="deletePhoto(${group.id}, ${photo.id}, event)" class="text-red-500 hover:text-red-700"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| </div> | |
| ` : ''} | |
| </div> | |
| </div> | |
| `; | |
| photosContainer.appendChild(photoCard); | |
| }); | |
| } | |
| function deletePhoto(groupId, photoId, event) { | |
| event.stopPropagation(); | |
| if (!currentUser.isAdmin) { | |
| alert('Только администратор может удалять фото'); | |
| return; | |
| } | |
| if (confirm('Вы уверены, что хотите удалить это фото?')) { | |
| const group = groups.find(g => g.id === groupId); | |
| if (group) { | |
| group.photos = group.photos.filter(p => p.id !== photoId); | |
| saveData(); // Save to localStorage | |
| renderPhotos(); | |
| } | |
| } | |
| } | |
| // File upload functions | |
| function resetFileInput() { | |
| selectedFile = null; | |
| dropContent.style.display = 'block'; | |
| previewContainer.style.display = 'none'; | |
| fileInput.value = ''; | |
| } | |
| function handleFileSelect(file) { | |
| if (!file.type.match('image.*')) { | |
| alert('Пожалуйста, выберите файл изображения'); | |
| return; | |
| } | |
| selectedFile = file; | |
| const reader = new FileReader(); | |
| reader.onload = function(e) { | |
| previewImage.src = e.target.result; | |
| fileName.textContent = file.name; | |
| dropContent.style.display = 'none'; | |
| previewContainer.style.display = 'block'; | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| // Drag and drop events | |
| ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { | |
| dropZone.addEventListener(eventName, preventDefaults, false); | |
| }); | |
| function preventDefaults(e) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| } | |
| ['dragenter', 'dragover'].forEach(eventName => { | |
| dropZone.addEventListener(eventName, highlight, false); | |
| }); | |
| ['dragleave', 'drop'].forEach(eventName => { | |
| dropZone.addEventListener(eventName, unhighlight, false); | |
| }); | |
| function highlight() { | |
| dropZone.classList.add('active'); | |
| } | |
| function unhighlight() { | |
| dropZone.classList.remove('active'); | |
| } | |
| dropZone.addEventListener('drop', handleDrop, false); | |
| function handleDrop(e) { | |
| const dt = e.dataTransfer; | |
| const files = dt.files; | |
| if (files.length > 0) { | |
| handleFileSelect(files[0]); | |
| } | |
| } | |
| fileInput.addEventListener('change', function() { | |
| if (this.files.length > 0) { | |
| handleFileSelect(this.files[0]); | |
| } | |
| }); | |
| // Initialize | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Set initial user | |
| usernameDisplay.textContent = currentUser.username; | |
| // Initialize data and start update checker | |
| initializeData(); | |
| startUpdateChecker(); | |
| renderGroups(); | |
| }); | |
| </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=Faist1/6v-website" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body> | |
| </html> |