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 @@
🥗 Питание для похудения
@@ -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() {