From 875d3d65184bceabc28ec17b68ea4538b346dd58 Mon Sep 17 00:00:00 2001 From: Madina Date: Mon, 10 Aug 2026 09:19:00 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=87=D0=B5=D0=BA-=D0=BB=D0=B8=D1=81=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=D0=B7=D0=BD=D1=8B=D1=85=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B2=D1=8B=D1=87=D0=B5=D0=BA=20(8=20=D0=BF=D1=80=D0=B8=D0=B2?= =?UTF-8?q?=D1=8B=D1=87=D0=B5=D0=BA,=20=D1=81=D0=B5=D1=80=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BD=D0=B5=D0=B9,=20=D1=81=D1=82=D0=B0=D1=82=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D0=BA=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 5d878a7..9a7f69a 100644 --- a/index.html +++ b/index.html @@ -411,6 +411,7 @@ + @@ -506,6 +507,29 @@
+ +
+

✨ Полезные привычки для похудения

+

Отмечай галочкой каждый день, когда выполнил привычку. Цель — 21 день подряд!

+ +
+ +
+
+
0
+
Дней подряд
+
+
+
0
+
Всего выполнено
+
+
+
0%
+
Успех сегодня
+
+
+
+

🥗 Питание для похудения

@@ -843,7 +867,19 @@ // === СОСТОЯНИЕ === let currentWeek = 0; - let progressData = JSON.parse(localStorage.getItem('madinaProgress') || '{"entries":[],"completedDays":[],"water":[],"waterToday":0}'); + let progressData = JSON.parse(localStorage.getItem('madinaProgress') || '{"entries":[],"completedDays":[],"water":[],"waterToday":0,"habits":{}}'); + + // === ПРИВЫЧКИ === + const habitsList = [ + { id: 'water', icon: '💧', name: 'Выпить 8 стаканов воды' }, + { id: 'workout', icon: '💪', name: 'Тренировка по плану' }, + { id: 'breakfast', icon: '🍳', name: 'Здоровый завтрак' }, + { id: 'no_sugar', icon: '🚫', name: 'Без сахара и сладкого' }, + { id: 'sleep', icon: '😴', name: 'Сон 7-8 часов' }, + { id: 'no_late', icon: '🕖', name: 'Ужин до 19:00' }, + { id: 'walk', icon: '🚶', name: 'Прогулка 30 мин' }, + { id: 'stretch', icon: '🧘', name: 'Растяжка утром' } + ]; // === ИНИЦИАЛИЗАЦИЯ === function init() { @@ -1190,6 +1226,66 @@ const avg = progressData.entries.reduce((sum, e) => sum + (parseFloat(e.weight) || 0), 0) / progressData.entries.length; document.getElementById('avg-weight').textContent = avg.toFixed(1); } + + renderHabits(); + } + + function renderHabits() { + const todayStr = new Date().toDateString(); + const container = document.getElementById('habits-list'); + + if (!container) return; + + // Инициализация сегодняшних привычек + if (!progressData.habits[todayStr]) { + progressData.habits[todayStr] = {}; + } + + // Чек-лист привычек + container.innerHTML = habitsList.map(h => { + const done = progressData.habits[todayStr][h.id] ? 'checked' : ''; + return '
' + + '' + + '' + h.icon + '' + + '' + h.name + '' + + (done ? '✓ Выполнено!' : '') + + '
'; + }).join(''); + + // Статистика + const todayHabits = progressData.habits[todayStr] || {}; + const doneCount = Object.values(todayHabits).filter(v => v).length; + const percent = Math.round((doneCount / habitsList.length) * 100); + + // Серия подряд + let streak = 0; + const dates = Object.keys(progressData.habits).sort((a, b) => new Date(b) - new Date(a)); + for (const date of dates) { + const dayHabits = progressData.habits[date]; + const allDone = habitsList.every(h => dayHabits[h.id]); + if (allDone) streak++; + else break; + } + + // Всего выполнено + let total = 0; + for (const date in progressData.habits) { + total += Object.values(progressData.habits[date]).filter(v => v).length; + } + + document.getElementById('habits-streak').textContent = streak; + document.getElementById('habits-total').textContent = total; + document.getElementById('habits-percent').textContent = percent + '%'; + } + + function toggleHabit(id) { + const todayStr = new Date().toDateString(); + if (!progressData.habits[todayStr]) { + progressData.habits[todayStr] = {}; + } + progressData.habits[todayStr][id] = !progressData.habits[todayStr][id]; + localStorage.setItem('madinaProgress', JSON.stringify(progressData)); + renderHabits(); } function addWater() {