From 0490135d9eb5b9907271a3d19cf84f76b3ab4ab9 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Thu, 25 Dec 2025 20:42:03 +0300 Subject: [PATCH] =?UTF-8?q?[=D0=92=D0=9E=D0=9B=D0=9A]=20=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8=20=D0=B2=20=D0=B4=D0=B5?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BB=D0=BE=D1=89=D0=B0=D0=B4=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_edit.py | 3 ++- templates/index.html | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/db_edit.py b/db_edit.py index 1ea710e..ba23d6c 100644 --- a/db_edit.py +++ b/db_edit.py @@ -1129,7 +1129,7 @@ def api_category_details(category_id): try: with db.conn.cursor() as cursor: cursor.execute(""" - SELECT AUTO_ID, ID, TITLE, description + SELECT AUTO_ID, ID, TITLE, description, image_url FROM categories WHERE ID = %s """, (category_id,)) @@ -1152,6 +1152,7 @@ def api_category_details(category_id): 'id': category['ID'], 'title': category['TITLE'] or '', 'description': category['description'] or '', + 'image_url': category['image_url'] or '', 'event_count': event_count }) except Exception as e: diff --git a/templates/index.html b/templates/index.html index 0b4e1e2..809f87e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1924,8 +1924,15 @@ const category = await response.json(); // Создаем HTML для деталей let detailsHtml = ` -
-
+
+ ${category.image_url ? ` + + ` : ''} +
ID: ${category.id || 'Не указано'}
@@ -1945,6 +1952,28 @@ } detailsHtml += `
`; detailsPanel.innerHTML = detailsHtml; + + // Проверяем, загрузилось ли изображение + if (category.image_url) { + const img = document.getElementById('category-image'); + const imgContainer = document.getElementById('category-image-container'); + const contentDiv = document.getElementById('category-content'); + + if (img && imgContainer) { + img.onload = function() { + // Изображение успешно загрузилось - показываем его + imgContainer.style.display = 'block'; + }; + img.onerror = function() { + // Изображение не загрузилось, скрываем контейнер + imgContainer.style.display = 'none'; + // Убираем отступ справа, если изображение не загрузилось + if (contentDiv) { + contentDiv.style.paddingRight = ''; + } + }; + } + } // Обновляем заголовок панели const header = document.getElementById('category-details-header'); if (header) {