/
Cooolprogrammers
/
web-nodejs-labs
Обзор
Документация
Войти
/
Cooolprogrammers
/
web-nodejs-labs
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
public/lab9/task1/index.html
275 строк
9 KB
darkvoid6@mail.ru
ЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫЫ
18 дек 2025, 07:59
18 дек 2025, 07:59
f2c4f06
Код
Авторство
О чём код?
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>ЛР9 - Задание 1 - Статистика и поиск</title> <style> body { font-family: 'Courier New', monospace; max-width: 1200px; margin: 2em auto; padding: 0 20px; background: #0a0a0a; color: #00ff41; } body::before { content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to bottom, transparent 90%, rgba(0, 255, 65, 0.03)); pointer-events: none; z-index: 1; } h1, h2, h3 { color: #00ff41; text-shadow: 0 0 10px #00ff41; letter-spacing: 1px; text-transform: uppercase; } h1 { border-bottom: 2px solid #00ff41; padding-bottom: 10px; } h2 { color: #00cc33; margin-bottom: 30px; } h3 { border-bottom: 1px solid #00ff41; padding-bottom: 8px; margin-bottom: 20px; } .stats-panel, .search-panel { background: linear-gradient(135deg, #001a00, #003300); padding: 20px; margin-bottom: 20px; border: 2px solid #00ff41; box-shadow: 0 0 20px rgba(0, 255, 65, 0.2); } .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 15px; } .stat-card { background: rgba(0, 20, 0, 0.9); padding: 20px; text-align: center; border: 1px solid #00ff41; transition: all 0.3s ease; } .stat-card:hover { border-color: #00ff88; box-shadow: 0 0 20px rgba(0, 255, 65, 0.3); transform: translateY(-2px); } .stat-value { font-size: 24px; font-weight: bold; color: #00ff41; text-shadow: 0 0 10px #00ff41; } .stat-label { color: #00cc33; margin-top: 5px; font-size: 0.9em; } .search-form { display: flex; gap: 10px; margin-bottom: 10px; } .search-input { flex: 1; padding: 10px; border: 2px solid #006600; font-size: 16px; background: #001a00; color: #00ff41; font-family: 'Courier New', monospace; } .search-input:focus { outline: none; border-color: #00ff41; box-shadow: 0 0 15px rgba(0, 255, 65, 0.3); } .search-btn, button[onclick="loadAllProducts()"] { padding: 10px 20px; background: #003300; color: #00ff41; border: 1px solid #00ff41; cursor: pointer; font-family: 'Courier New', monospace; text-transform: uppercase; letter-spacing: 1px; transition: all 0.3s ease; } .search-btn:hover, button[onclick="loadAllProducts()"]:hover { background: #00ff41; color: #000; transform: translateY(-2px); box-shadow: 0 0 15px rgba(0, 255, 65, 0.3); } .products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; } .product-card { background: rgba(0, 20, 0, 0.9); border: 1px solid #00cc33; padding: 15px; transition: all 0.2s; } .product-card:hover { border-color: #00ff41; box-shadow: 0 0 15px rgba(0, 255, 65, 0.2); } .product-title { font-weight: bold; font-size: 18px; margin-bottom: 10px; color: #00ff41; text-transform: uppercase; } .product-price { color: #00ff41; font-weight: bold; font-size: 16px; } .product-amount { color: #00cc33; margin-top: 5px; } .loading { text-align: center; padding: 40px; color: #00cc33; font-style: italic; border: 1px dashed #006600; background: rgba(0, 20, 0, 0.5); } .error { background: rgba(50, 0, 0, 0.8); color: #ff3333; padding: 15px; border: 1px solid #ff3333; margin: 10px 0; } @media (max-width: 768px) { .stats-grid { grid-template-columns: 1fr; } .search-form { flex-direction: column; } .products-grid { grid-template-columns: 1fr; } } </style> </head> <body> <h1>ЛР9 - ЗАДАНИЕ 1</h1> <h2>📊 СТАТИСТИКА СКЛАДА И ПОИСК</h2> <div class="stats-panel"> <h3>📈 СТАТИСТИКА СКЛАДА</h3> <div class="stats-grid" id="statsContainer"> <div class="loading">ЗАГРУЗКА...</div> </div> </div> <div class="search-panel"> <h3>🔍 ПОИСК ТОВАРОВ</h3> <form class="search-form" id="searchForm"> <input type="text" class="search-input" id="searchInput" placeholder="НАЗВАНИЕ ТОВАРА..."> <button type="submit" class="search-btn">НАЙТИ</button> </form> <button onclick="loadAllProducts()">ВСЕ ТОВАРЫ</button> </div> <div id="productsContainer"> <div class="loading">ВВЕДИТЕ ЗАПРОС ИЛИ НАЖМИТЕ "ВСЕ ТОВАРЫ"</div> </div> <script> const API_BASE = '/api/lab9/task1'; function formatPrice(cents) { return (cents / 100).toLocaleString('ru-RU', { style: 'currency', currency: 'RUB' }); } function formatTotalValue(cents) { const rubles = cents / 100; if (rubles >= 1000000) return (rubles / 1000000).toFixed(1) + ' МЛН ₽'; if (rubles >= 1000) return (rubles / 1000).toFixed(0) + ' ТЫС ₽'; return formatPrice(cents); } async function loadStats() { try { const response = await fetch(`${API_BASE}/stock`); const stats = await response.json(); document.getElementById('statsContainer').innerHTML = ` <div class="stat-card"> <div class="stat-value">${stats.total_products || 0}</div> <div class="stat-label">НАИМЕНОВАНИЙ</div> </div> <div class="stat-card"> <div class="stat-value">${stats.total_items || 0}</div> <div class="stat-label">ЕДИНИЦ</div> </div> <div class="stat-card"> <div class="stat-value">${formatTotalValue(stats.total_value || 0)}</div> <div class="stat-label">СТОИМОСТЬ</div> </div> `; } catch (error) { document.getElementById('statsContainer').innerHTML = `<div class="error">ОШИБКА: ${error.message}</div>`; } } async function searchProducts(query) { const container = document.getElementById('productsContainer'); container.innerHTML = '<div class="loading">ПОИСК...</div>'; try { const response = await fetch(`${API_BASE}/products?q=${encodeURIComponent(query)}`); const products = await response.json(); if (products.length === 0) { container.innerHTML = '<div class="loading">НЕ НАЙДЕНО</div>'; return; } container.innerHTML = ` <h3>НАЙДЕНО: ${products.length}</h3> <div class="products-grid"> ${products.map(p => ` <div class="product-card"> <div class="product-title">${p.title}</div> <div class="product-price">${formatPrice(p.price)}</div> <div class="product-amount">СКЛАД: ${p.amount} ШТ.</div> </div> `).join('')} </div> `; } catch (error) { container.innerHTML = `<div class="error">ОШИБКА: ${error.message}</div>`; } } async function loadAllProducts() { document.getElementById('searchInput').value = ''; await searchProducts(''); } document.getElementById('searchForm').addEventListener('submit', function(e) { e.preventDefault(); const query = document.getElementById('searchInput').value.trim(); if (query.length >= 1) searchProducts(query); else alert('ВВЕДИТЕ МИНИМУМ 1 СИМВОЛ'); }); window.addEventListener('load', loadStats); </script> </body> </html>