From c3b0c197586ae6e8393352371aea94b2e30cb43c Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 11 Jul 2025 12:33:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=B0=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2=D1=8B=D1=85=20=D0=BF=D0=BE=D0=BB=D1=8F=20(Google?= =?UTF-8?q?=20=D0=B8=20=D0=AF=D0=BD=D0=B4=D0=B5=D0=BA=D1=81)=20=D1=81=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=BE=D1=82=D0=B8=D0=BF=D0=B0=D0=BC=D0=B8,?= =?UTF-8?q?=20=D0=B0=D0=B4=D0=B0=D0=BF=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D0=B5?= =?UTF-8?q?,=20=D0=BA=D1=80=D1=83=D0=BF=D0=BD=D1=8B=D0=B9=20=D1=88=D1=80?= =?UTF-8?q?=D0=B8=D1=84=D1=82,=20=D0=B7=D0=B0=D0=BD=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D1=8E=D1=82=20=D0=B2=D1=81=D1=8E=20=D1=88=D0=B8=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + templates/index.html | 65 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 190fd20..c301ce5 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ - Поддержка настройки времени кэширования погоды через weather.cache_ttl (минуты, по умолчанию 60) - В шапке вместо приветствия теперь крупно текущее время, дата на русском - Дата и время теперь на одной строке, одинакового размера и цвета, хорошо видны на тёмном фоне +- Два поисковых поля (Google и Яндекс) с логотипами, адаптивные, крупный шрифт, занимают всю ширину ## [init] Стартовая инициализация структуры Flask-приложения - Создана структура каталогов: templates/, static/ diff --git a/templates/index.html b/templates/index.html index 5b872dd..3698a7b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,15 +14,30 @@
-
+
+ + +
- {{ current_time }} - {{ now }} + {{ current_time }} + {{ now }}
-
-
+
+
+ {% if weather and weather.icon %} + icon + {% else %} + + {% endif %} +
{% if weather %} {{ weather.temp }}°C @@ -85,6 +100,13 @@
+
@@ -166,6 +188,39 @@ let resizeObserver = new ResizeObserver(() => { resizeMonaco(); }); resizeObserver.observe(document.getElementById('config-modal-content')); + +const weatherArea = document.getElementById('weather-area'); +const forecastModal = document.getElementById('forecast-modal'); +const forecastContent = document.getElementById('forecast-content'); +const closeForecastBtn = document.getElementById('close-forecast-btn'); +const forecastTitle = document.getElementById('forecast-title'); + +weatherArea.onclick = function() { + forecastContent.innerHTML = 'Загрузка...'; + forecastModal.style.display = 'flex'; + fetch('/api/weather-forecast').then(r => r.json()).then(data => { + if(data.error) { + forecastContent.innerHTML = ''+data.error+''; + forecastTitle.textContent = 'Прогноз'; + return; + } + let days = data.forecast.length; + forecastTitle.textContent = `Прогноз на ${days} ${days === 1 ? 'день' : (days < 5 ? 'дня' : 'дней')}`; + let html = ''; + html += ''; + for(const day of data.forecast) { + html += ``; + } + html += '
ДатаТемператураОблачностьСостояние
${day.date}${day.temp}°C${day.cloud}%${day.text||''}${day.icon ? `` : ''}
'; + forecastContent.innerHTML = html; + }).catch(() => { + forecastContent.innerHTML = 'Ошибка загрузки прогноза'; + forecastTitle.textContent = 'Прогноз'; + }); +}; +closeForecastBtn.onclick = function() { + forecastModal.style.display = 'none'; +}; \ No newline at end of file