denisgay/public/index.html
2025-11-12 21:02:37 +07:00

243 lines
7.1 KiB
HTML

<!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: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 900px;
margin: 0 auto;
}
header {
text-align: center;
color: white;
margin-bottom: 40px;
padding: 30px 20px;
}
h1 {
font-size: 3rem;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.subtitle {
font-size: 1.2rem;
opacity: 0.9;
}
.rainbow-flag {
display: flex;
height: 8px;
margin: 20px 0;
border-radius: 4px;
overflow: hidden;
}
.rainbow-flag div {
flex: 1;
}
.controls {
display: flex;
justify-content: center;
gap: 15px;
margin-bottom: 30px;
}
button {
background: white;
border: none;
padding: 12px 30px;
border-radius: 25px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
button:active {
transform: translateY(0);
}
.quote-card {
background: white;
border-radius: 15px;
padding: 30px;
margin-bottom: 20px;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
transition: transform 0.3s;
animation: slideIn 0.5s ease-out;
}
@keyframes slideIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.quote-card:hover {
transform: translateY(-5px);
}
.quote-text {
font-size: 1.3rem;
line-height: 1.6;
color: #333;
margin-bottom: 15px;
font-style: italic;
}
.quote-timestamp {
color: #667eea;
font-size: 0.9rem;
font-weight: 600;
}
.loading {
text-align: center;
color: white;
font-size: 1.2rem;
padding: 40px;
}
.no-quotes {
text-align: center;
color: white;
font-size: 1.2rem;
padding: 40px;
background: rgba(255,255,255,0.1);
border-radius: 15px;
}
.spinner {
border: 3px solid rgba(255,255,255,0.3);
border-top: 3px solid white;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 20px auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>🏳️‍🌈 Цитатник Дениса Шулепова</h1>
<div class="rainbow-flag">
<div style="background: #e40303;"></div>
<div style="background: #ff8c00;"></div>
<div style="background: #ffed00;"></div>
<div style="background: #008026;"></div>
<div style="background: #24408e;"></div>
<div style="background: #732982;"></div>
</div>
</header>
<div class="controls">
<button onclick="loadQuotes()">🔄 Обновить</button>
</div>
<div id="quotes-container"></div>
</div>
<script>
async function loadQuotes() {
const container = document.getElementById('quotes-container');
container.innerHTML = '<div class="loading"><div class="spinner"></div>Загрузка цитат...</div>';
try {
const response = await fetch('/api/quotes');
const quotes = await response.json();
if (quotes.length === 0) {
container.innerHTML = '<div class="no-quotes">Пока нет цитат. Нажмите "Создать новую цитату"!</div>';
return;
}
container.innerHTML = quotes.map(q => {
const date = new Date(q.timestamp);
const formattedDate = date.toLocaleString('ru-RU', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
return `
<div class="quote-card">
<img src="photo_2023-10-27_20-55-45.jpg" alt="Денис Шулепов" style="width: 80px; height: 80px; border-radius: 50%; object-fit: cover; float: left; margin-right: 20px; border: 3px solid #667eea;">
<div class="quote-text">"${q.quote}"</div>
<div class="quote-timestamp">📅 ${formattedDate}</div>
</div>
`;
}).join('');
} catch (error) {
container.innerHTML = '<div class="no-quotes">❌ Ошибка загрузки цитат</div>';
console.error('Error loading quotes:', error);
}
}
async function generateQuote() {
const container = document.getElementById('quotes-container');
const originalContent = container.innerHTML;
container.innerHTML = '<div class="loading"><div class="spinner"></div>Генерируем новую цитату...</div>';
try {
const response = await fetch('/api/generate', {
method: 'POST'
});
if (response.ok) {
setTimeout(() => loadQuotes(), 1000);
} else {
throw new Error('Failed to generate quote');
}
} catch (error) {
container.innerHTML = originalContent;
alert('❌ Ошибка генерации цитаты. Проверьте настройки API.');
console.error('Error generating quote:', error);
}
}
loadQuotes();
setInterval(loadQuotes, 60000);
</script>
</body>
</html>