undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +471 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: depression-cycle-tracker-prototype
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: green
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,471 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>MindBloom | Depression Cycle Tracker</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
@keyframes fadeIn {
|
11 |
+
from { opacity: 0; }
|
12 |
+
to { opacity: 1; }
|
13 |
+
}
|
14 |
+
.fade-in {
|
15 |
+
animation: fadeIn 0.5s ease-in-out;
|
16 |
+
}
|
17 |
+
.mood-1 { background-color: #f87171; } /* Very low */
|
18 |
+
.mood-2 { background-color: #fb923c; } /* Low */
|
19 |
+
.mood-3 { background-color: #facc15; } /* Neutral */
|
20 |
+
.mood-4 { background-color: #a3e635; } /* Good */
|
21 |
+
.mood-5 { background-color: #4ade80; } /* Very good */
|
22 |
+
.chart-bar {
|
23 |
+
transition: height 0.5s ease-in-out;
|
24 |
+
}
|
25 |
+
.custom-scrollbar::-webkit-scrollbar {
|
26 |
+
width: 6px;
|
27 |
+
height: 6px;
|
28 |
+
}
|
29 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
30 |
+
background: #f1f1f1;
|
31 |
+
border-radius: 10px;
|
32 |
+
}
|
33 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
34 |
+
background: #cbd5e1;
|
35 |
+
border-radius: 10px;
|
36 |
+
}
|
37 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
38 |
+
background: #94a3b8;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
</head>
|
42 |
+
<body class="bg-gray-50 min-h-screen font-sans">
|
43 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
44 |
+
<!-- Header -->
|
45 |
+
<header class="flex justify-between items-center mb-8">
|
46 |
+
<div class="flex items-center">
|
47 |
+
<div class="w-10 h-10 rounded-full bg-indigo-600 flex items-center justify-center mr-3">
|
48 |
+
<i class="fas fa-brain text-white text-xl"></i>
|
49 |
+
</div>
|
50 |
+
<h1 class="text-2xl font-bold text-gray-800">MindBloom</h1>
|
51 |
+
</div>
|
52 |
+
<div class="flex items-center space-x-4">
|
53 |
+
<button id="theme-toggle" class="p-2 rounded-full hover:bg-gray-200 transition">
|
54 |
+
<i class="fas fa-moon text-gray-600"></i>
|
55 |
+
</button>
|
56 |
+
<div class="w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center">
|
57 |
+
<i class="fas fa-user text-indigo-600"></i>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
</header>
|
61 |
+
|
62 |
+
<!-- Main Content -->
|
63 |
+
<main class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
64 |
+
<!-- Left Column -->
|
65 |
+
<div class="lg:col-span-2 space-y-6">
|
66 |
+
<!-- Mood Tracker -->
|
67 |
+
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
|
68 |
+
<div class="flex justify-between items-center mb-4">
|
69 |
+
<h2 class="text-xl font-semibold text-gray-800">Today's Mood</h2>
|
70 |
+
<span class="text-sm text-gray-500" id="current-date"></span>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
<div class="mb-6">
|
74 |
+
<p class="text-gray-600 mb-4">How are you feeling today?</p>
|
75 |
+
<div class="flex justify-between space-x-2">
|
76 |
+
<button class="mood-btn flex-1 py-3 rounded-lg flex flex-col items-center transition hover:opacity-90" data-value="1">
|
77 |
+
<i class="fas fa-face-sad-tear text-2xl mb-1"></i>
|
78 |
+
<span class="text-xs">Very Low</span>
|
79 |
+
</button>
|
80 |
+
<button class="mood-btn flex-1 py-3 rounded-lg flex flex-col items-center transition hover:opacity-90" data-value="2">
|
81 |
+
<i class="fas fa-face-frown text-2xl mb-1"></i>
|
82 |
+
<span class="text-xs">Low</span>
|
83 |
+
</button>
|
84 |
+
<button class="mood-btn flex-1 py-3 rounded-lg flex flex-col items-center transition hover:opacity-90" data-value="3">
|
85 |
+
<i class="fas fa-face-meh text-2xl mb-1"></i>
|
86 |
+
<span class="text-xs">Neutral</span>
|
87 |
+
</button>
|
88 |
+
<button class="mood-btn flex-1 py-3 rounded-lg flex flex-col items-center transition hover:opacity-90" data-value="4">
|
89 |
+
<i class="fas fa-face-smile text-2xl mb-1"></i>
|
90 |
+
<span class="text-xs">Good</span>
|
91 |
+
</button>
|
92 |
+
<button class="mood-btn flex-1 py-3 rounded-lg flex flex-col items-center transition hover:opacity-90" data-value="5">
|
93 |
+
<i class="fas fa-face-laugh-beam text-2xl mb-1"></i>
|
94 |
+
<span class="text-xs">Very Good</span>
|
95 |
+
</button>
|
96 |
+
</div>
|
97 |
+
</div>
|
98 |
+
|
99 |
+
<div id="mood-description" class="hidden">
|
100 |
+
<textarea id="mood-notes" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" rows="3" placeholder="Add any notes about how you're feeling..."></textarea>
|
101 |
+
<div class="flex justify-end mt-3">
|
102 |
+
<button id="save-mood" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition">Save</button>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<!-- Mood History Chart -->
|
108 |
+
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
|
109 |
+
<div class="flex justify-between items-center mb-4">
|
110 |
+
<h2 class="text-xl font-semibold text-gray-800">Mood History</h2>
|
111 |
+
<div class="flex space-x-2">
|
112 |
+
<button class="time-btn px-3 py-1 text-sm rounded-md bg-indigo-100 text-indigo-700" data-range="7">Week</button>
|
113 |
+
<button class="time-btn px-3 py-1 text-sm rounded-md hover:bg-indigo-100 hover:text-indigo-700" data-range="30">Month</button>
|
114 |
+
<button class="time-btn px-3 py-1 text-sm rounded-md hover:bg-indigo-100 hover:text-indigo-700" data-range="90">3 Months</button>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
<div class="h-64">
|
118 |
+
<div id="mood-chart" class="h-full flex items-end justify-between pt-4"></div>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
|
123 |
+
<!-- Right Column -->
|
124 |
+
<div class="space-y-6">
|
125 |
+
<!-- Stats Card -->
|
126 |
+
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
|
127 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">Your Stats</h2>
|
128 |
+
<div class="space-y-4">
|
129 |
+
<div>
|
130 |
+
<p class="text-sm text-gray-500 mb-1">Current Mood Cycle</p>
|
131 |
+
<div class="flex items-center">
|
132 |
+
<div class="w-3 h-3 rounded-full bg-indigo-600 mr-2"></div>
|
133 |
+
<p class="font-medium" id="current-cycle">Neutral Phase</p>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
<div>
|
137 |
+
<p class="text-sm text-gray-500 mb-1">Average Mood</p>
|
138 |
+
<p class="font-medium text-2xl" id="avg-mood">3.4</p>
|
139 |
+
</div>
|
140 |
+
<div>
|
141 |
+
<p class="text-sm text-gray-500 mb-1">Low Days This Month</p>
|
142 |
+
<p class="font-medium" id="low-days">4</p>
|
143 |
+
</div>
|
144 |
+
<div>
|
145 |
+
<p class="text-sm text-gray-500 mb-1">Current Streak</p>
|
146 |
+
<p class="font-medium" id="current-streak">2 days</p>
|
147 |
+
</div>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
|
151 |
+
<!-- Journal Entries -->
|
152 |
+
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
|
153 |
+
<div class="flex justify-between items-center mb-4">
|
154 |
+
<h2 class="text-xl font-semibold text-gray-800">Recent Journal</h2>
|
155 |
+
<button class="text-indigo-600 hover:text-indigo-800">
|
156 |
+
<i class="fas fa-plus"></i>
|
157 |
+
</button>
|
158 |
+
</div>
|
159 |
+
<div class="space-y-4 max-h-64 overflow-y-auto custom-scrollbar">
|
160 |
+
<div class="p-3 bg-indigo-50 rounded-lg">
|
161 |
+
<div class="flex justify-between items-start mb-2">
|
162 |
+
<p class="font-medium">Feeling better today</p>
|
163 |
+
<span class="text-xs text-gray-500">Yesterday</span>
|
164 |
+
</div>
|
165 |
+
<p class="text-sm text-gray-700">Went for a walk in the park and it helped clear my mind. The sunshine felt nice.</p>
|
166 |
+
</div>
|
167 |
+
<div class="p-3 bg-amber-50 rounded-lg">
|
168 |
+
<div class="flex justify-between items-start mb-2">
|
169 |
+
<p class="font-medium">Struggling</p>
|
170 |
+
<span class="text-xs text-gray-500">2 days ago</span>
|
171 |
+
</div>
|
172 |
+
<p class="text-sm text-gray-700">Hard to get out of bed today. Everything feels heavy.</p>
|
173 |
+
</div>
|
174 |
+
<div class="p-3 bg-indigo-50 rounded-lg">
|
175 |
+
<div class="flex justify-between items-start mb-2">
|
176 |
+
<p class="font-medium">Productive day</p>
|
177 |
+
<span class="text-xs text-gray-500">4 days ago</span>
|
178 |
+
</div>
|
179 |
+
<p class="text-sm text-gray-700">Finished my project ahead of schedule. Feeling accomplished.</p>
|
180 |
+
</div>
|
181 |
+
</div>
|
182 |
+
</div>
|
183 |
+
|
184 |
+
<!-- Resources -->
|
185 |
+
<div class="bg-white rounded-xl shadow-md p-6 fade-in">
|
186 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">Resources</h2>
|
187 |
+
<div class="space-y-3">
|
188 |
+
<a href="#" class="flex items-center p-2 rounded-lg hover:bg-gray-50 transition">
|
189 |
+
<div class="w-8 h-8 rounded-full bg-green-100 flex items-center justify-center mr-3">
|
190 |
+
<i class="fas fa-head-side-virus text-green-600"></i>
|
191 |
+
</div>
|
192 |
+
<p class="text-sm">Coping Strategies</p>
|
193 |
+
</a>
|
194 |
+
<a href="#" class="flex items-center p-2 rounded-lg hover:bg-gray-50 transition">
|
195 |
+
<div class="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center mr-3">
|
196 |
+
<i class="fas fa-hands-holding-child text-blue-600"></i>
|
197 |
+
</div>
|
198 |
+
<p class="text-sm">Support Groups</p>
|
199 |
+
</a>
|
200 |
+
<a href="#" class="flex items-center p-2 rounded-lg hover:bg-gray-50 transition">
|
201 |
+
<div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center mr-3">
|
202 |
+
<i class="fas fa-book text-purple-600"></i>
|
203 |
+
</div>
|
204 |
+
<p class="text-sm">Depression Education</p>
|
205 |
+
</a>
|
206 |
+
</div>
|
207 |
+
</div>
|
208 |
+
</div>
|
209 |
+
</main>
|
210 |
+
</div>
|
211 |
+
|
212 |
+
<!-- Mood Saved Toast -->
|
213 |
+
<div id="toast" class="fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg hidden items-center">
|
214 |
+
<i class="fas fa-check-circle mr-2"></i>
|
215 |
+
<span>Mood saved successfully!</span>
|
216 |
+
</div>
|
217 |
+
|
218 |
+
<script>
|
219 |
+
// Set current date
|
220 |
+
const now = new Date();
|
221 |
+
document.getElementById('current-date').textContent = now.toLocaleDateString('en-US', {
|
222 |
+
weekday: 'long',
|
223 |
+
month: 'short',
|
224 |
+
day: 'numeric'
|
225 |
+
});
|
226 |
+
|
227 |
+
// Theme toggle
|
228 |
+
const themeToggle = document.getElementById('theme-toggle');
|
229 |
+
themeToggle.addEventListener('click', () => {
|
230 |
+
document.documentElement.classList.toggle('dark');
|
231 |
+
const icon = themeToggle.querySelector('i');
|
232 |
+
if (document.documentElement.classList.contains('dark')) {
|
233 |
+
icon.classList.replace('fa-moon', 'fa-sun');
|
234 |
+
document.body.classList.add('bg-gray-900');
|
235 |
+
document.body.classList.remove('bg-gray-50');
|
236 |
+
} else {
|
237 |
+
icon.classList.replace('fa-sun', 'fa-moon');
|
238 |
+
document.body.classList.remove('bg-gray-900');
|
239 |
+
document.body.classList.add('bg-gray-50');
|
240 |
+
}
|
241 |
+
});
|
242 |
+
|
243 |
+
// Mood selection
|
244 |
+
const moodBtns = document.querySelectorAll('.mood-btn');
|
245 |
+
const moodDescription = document.getElementById('mood-description');
|
246 |
+
let selectedMood = null;
|
247 |
+
|
248 |
+
moodBtns.forEach(btn => {
|
249 |
+
btn.addEventListener('click', () => {
|
250 |
+
// Remove active class from all buttons
|
251 |
+
moodBtns.forEach(b => {
|
252 |
+
b.classList.remove('mood-1', 'mood-2', 'mood-3', 'mood-4', 'mood-5');
|
253 |
+
b.classList.add('opacity-50');
|
254 |
+
});
|
255 |
+
|
256 |
+
// Add active class to clicked button
|
257 |
+
selectedMood = parseInt(btn.dataset.value);
|
258 |
+
btn.classList.add(`mood-${selectedMood}`);
|
259 |
+
btn.classList.remove('opacity-50');
|
260 |
+
|
261 |
+
// Show mood description
|
262 |
+
moodDescription.classList.remove('hidden');
|
263 |
+
});
|
264 |
+
});
|
265 |
+
|
266 |
+
// Save mood
|
267 |
+
const saveMoodBtn = document.getElementById('save-mood');
|
268 |
+
const moodNotes = document.getElementById('mood-notes');
|
269 |
+
const toast = document.getElementById('toast');
|
270 |
+
|
271 |
+
saveMoodBtn.addEventListener('click', () => {
|
272 |
+
if (!selectedMood) return;
|
273 |
+
|
274 |
+
// In a real app, you would save to a database here
|
275 |
+
const moodData = {
|
276 |
+
date: now,
|
277 |
+
mood: selectedMood,
|
278 |
+
notes: moodNotes.value
|
279 |
+
};
|
280 |
+
|
281 |
+
// Save to localStorage for demo purposes
|
282 |
+
let moods = JSON.parse(localStorage.getItem('moods') || '[]');
|
283 |
+
moods.push(moodData);
|
284 |
+
localStorage.setItem('moods', JSON.stringify(moods));
|
285 |
+
|
286 |
+
// Show toast
|
287 |
+
toast.classList.remove('hidden');
|
288 |
+
setTimeout(() => {
|
289 |
+
toast.classList.add('hidden');
|
290 |
+
}, 3000);
|
291 |
+
|
292 |
+
// Reset form
|
293 |
+
moodBtns.forEach(b => {
|
294 |
+
b.classList.remove('mood-1', 'mood-2', 'mood-3', 'mood-4', 'mood-5');
|
295 |
+
b.classList.remove('opacity-50');
|
296 |
+
});
|
297 |
+
moodNotes.value = '';
|
298 |
+
moodDescription.classList.add('hidden');
|
299 |
+
selectedMood = null;
|
300 |
+
|
301 |
+
// Update chart
|
302 |
+
updateChart(7);
|
303 |
+
updateStats();
|
304 |
+
});
|
305 |
+
|
306 |
+
// Time range buttons
|
307 |
+
const timeBtns = document.querySelectorAll('.time-btn');
|
308 |
+
timeBtns.forEach(btn => {
|
309 |
+
btn.addEventListener('click', () => {
|
310 |
+
timeBtns.forEach(b => {
|
311 |
+
b.classList.remove('bg-indigo-100', 'text-indigo-700');
|
312 |
+
b.classList.add('hover:bg-indigo-100', 'hover:text-indigo-700');
|
313 |
+
});
|
314 |
+
btn.classList.add('bg-indigo-100', 'text-indigo-700');
|
315 |
+
btn.classList.remove('hover:bg-indigo-100', 'hover:text-indigo-700');
|
316 |
+
|
317 |
+
const range = parseInt(btn.dataset.range);
|
318 |
+
updateChart(range);
|
319 |
+
});
|
320 |
+
});
|
321 |
+
|
322 |
+
// Generate mock data if none exists
|
323 |
+
function generateMockData() {
|
324 |
+
if (localStorage.getItem('moods')) return;
|
325 |
+
|
326 |
+
const moods = [];
|
327 |
+
const today = new Date();
|
328 |
+
|
329 |
+
for (let i = 0; i < 90; i++) {
|
330 |
+
const date = new Date();
|
331 |
+
date.setDate(today.getDate() - (90 - i));
|
332 |
+
|
333 |
+
// Simulate depression cycles (every 10-20 days)
|
334 |
+
const cyclePhase = Math.floor(i / 15) % 4; // 0-3
|
335 |
+
let mood;
|
336 |
+
|
337 |
+
if (cyclePhase === 0) {
|
338 |
+
mood = Math.floor(Math.random() * 2) + 4; // 4-5 (good phase)
|
339 |
+
} else if (cyclePhase === 1) {
|
340 |
+
mood = 3; // neutral phase
|
341 |
+
} else if (cyclePhase === 2) {
|
342 |
+
mood = Math.floor(Math.random() * 2) + 1; // 1-2 (low phase)
|
343 |
+
} else {
|
344 |
+
mood = 3; // neutral phase
|
345 |
+
}
|
346 |
+
|
347 |
+
moods.push({
|
348 |
+
date: date,
|
349 |
+
mood: mood,
|
350 |
+
notes: ''
|
351 |
+
});
|
352 |
+
}
|
353 |
+
|
354 |
+
localStorage.setItem('moods', JSON.stringify(moods));
|
355 |
+
}
|
356 |
+
|
357 |
+
// Update chart
|
358 |
+
function updateChart(days) {
|
359 |
+
generateMockData();
|
360 |
+
const moods = JSON.parse(localStorage.getItem('moods'));
|
361 |
+
const chart = document.getElementById('mood-chart');
|
362 |
+
chart.innerHTML = '';
|
363 |
+
|
364 |
+
const today = new Date();
|
365 |
+
const startDate = new Date();
|
366 |
+
startDate.setDate(today.getDate() - days);
|
367 |
+
|
368 |
+
const filteredMoods = moods.filter(mood => {
|
369 |
+
const moodDate = new Date(mood.date);
|
370 |
+
return moodDate >= startDate && moodDate <= today;
|
371 |
+
});
|
372 |
+
|
373 |
+
// Group by day (in a real app, you might want more sophisticated grouping)
|
374 |
+
const groupedMoods = {};
|
375 |
+
filteredMoods.forEach(mood => {
|
376 |
+
const dateStr = new Date(mood.date).toLocaleDateString();
|
377 |
+
if (!groupedMoods[dateStr]) {
|
378 |
+
groupedMoods[dateStr] = [];
|
379 |
+
}
|
380 |
+
groupedMoods[dateStr].push(mood.mood);
|
381 |
+
});
|
382 |
+
|
383 |
+
// Calculate average mood per day
|
384 |
+
const moodAverages = [];
|
385 |
+
Object.keys(groupedMoods).forEach(dateStr => {
|
386 |
+
const moods = groupedMoods[dateStr];
|
387 |
+
const avg = moods.reduce((a, b) => a + b, 0) / moods.length;
|
388 |
+
moodAverages.push({
|
389 |
+
date: dateStr,
|
390 |
+
avg: avg
|
391 |
+
});
|
392 |
+
});
|
393 |
+
|
394 |
+
// Sort by date
|
395 |
+
moodAverages.sort((a, b) => new Date(a.date) - new Date(b.date));
|
396 |
+
|
397 |
+
// Display chart
|
398 |
+
const maxHeight = 180; // max height in pixels
|
399 |
+
moodAverages.forEach((day, index) => {
|
400 |
+
const height = (day.avg / 5) * maxHeight;
|
401 |
+
const date = new Date(day.date);
|
402 |
+
const dayName = date.toLocaleDateString('en-US', { weekday: 'short' }).charAt(0);
|
403 |
+
|
404 |
+
const bar = document.createElement('div');
|
405 |
+
bar.className = `chart-bar flex flex-col items-center w-8 mx-1`;
|
406 |
+
|
407 |
+
const barFill = document.createElement('div');
|
408 |
+
barFill.className = `w-full rounded-t-md mood-${Math.round(day.avg)}`;
|
409 |
+
barFill.style.height = `${height}px`;
|
410 |
+
|
411 |
+
const dayLabel = document.createElement('span');
|
412 |
+
dayLabel.className = 'text-xs text-gray-500 mt-1';
|
413 |
+
dayLabel.textContent = dayName;
|
414 |
+
|
415 |
+
bar.appendChild(barFill);
|
416 |
+
bar.appendChild(dayLabel);
|
417 |
+
chart.appendChild(bar);
|
418 |
+
});
|
419 |
+
}
|
420 |
+
|
421 |
+
// Update stats
|
422 |
+
function updateStats() {
|
423 |
+
generateMockData();
|
424 |
+
const moods = JSON.parse(localStorage.getItem('moods'));
|
425 |
+
|
426 |
+
// Calculate average mood
|
427 |
+
const avgMood = moods.reduce((sum, mood) => sum + mood.mood, 0) / moods.length;
|
428 |
+
document.getElementById('avg-mood').textContent = avgMood.toFixed(1);
|
429 |
+
|
430 |
+
// Calculate low days this month
|
431 |
+
const thisMonth = new Date().getMonth();
|
432 |
+
const lowDays = moods.filter(mood => {
|
433 |
+
const moodDate = new Date(mood.date);
|
434 |
+
return moodDate.getMonth() === thisMonth && mood.mood <= 2;
|
435 |
+
}).length;
|
436 |
+
document.getElementById('low-days').textContent = lowDays;
|
437 |
+
|
438 |
+
// Determine current cycle
|
439 |
+
const last7Days = moods.slice(-7).map(m => m.mood);
|
440 |
+
const avgLast7 = last7Days.reduce((a, b) => a + b, 0) / last7Days.length;
|
441 |
+
|
442 |
+
let cycle;
|
443 |
+
if (avgLast7 <= 2) {
|
444 |
+
cycle = "Low Phase";
|
445 |
+
} else if (avgLast7 >= 4) {
|
446 |
+
cycle = "Good Phase";
|
447 |
+
} else {
|
448 |
+
cycle = "Neutral Phase";
|
449 |
+
}
|
450 |
+
document.getElementById('current-cycle').textContent = cycle;
|
451 |
+
|
452 |
+
// Calculate current streak
|
453 |
+
let streak = 0;
|
454 |
+
let prevMood = moods[moods.length - 1].mood;
|
455 |
+
for (let i = moods.length - 1; i >= 0; i--) {
|
456 |
+
if (moods[i].mood === prevMood) {
|
457 |
+
streak++;
|
458 |
+
} else {
|
459 |
+
break;
|
460 |
+
}
|
461 |
+
}
|
462 |
+
document.getElementById('current-streak').textContent = `${streak} day${streak !== 1 ? 's' : ''}`;
|
463 |
+
}
|
464 |
+
|
465 |
+
// Initialize
|
466 |
+
updateChart(7);
|
467 |
+
updateStats();
|
468 |
+
timeBtns[0].click();
|
469 |
+
</script>
|
470 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=twnatelo/depression-cycle-tracker-prototype" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
471 |
+
</html>
|