Youssef117 commited on
Commit
ad8da2e
·
verified ·
1 Parent(s): 990df93

اريد لكل مستخدم ان يكون يكون له حساب خاص به و مكان يضع بيه رقم الواتساب الذي يريد عليه الاشعار بتاع التطبيق و ايضا مكان واتساب لارسال للشخص المتابع و مكان لمشاؤكة قائمة الادوية من خلال الواتساب - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +1004 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Dwaa2a
3
- emoji: 🚀
4
  colorFrom: yellow
5
- colorTo: blue
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: dwaa2a
3
+ emoji: 🐳
4
  colorFrom: yellow
5
+ colorTo: yellow
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,1004 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ar" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>منبه الدواء - تذكير بمواعيد الأدوية</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
+ @import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap');
11
+
12
+ body {
13
+ font-family: 'Tajawal', sans-serif;
14
+ }
15
+
16
+ .notification-badge {
17
+ position: absolute;
18
+ top: -5px;
19
+ right: -5px;
20
+ width: 20px;
21
+ height: 20px;
22
+ background-color: #EF4444;
23
+ color: white;
24
+ border-radius: 50%;
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ font-size: 12px;
29
+ }
30
+
31
+ .medication-card {
32
+ transition: all 0.3s ease;
33
+ }
34
+
35
+ .medication-card:hover {
36
+ transform: translateY(-5px);
37
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
38
+ }
39
+
40
+ .notification {
41
+ animation: slideIn 0.5s forwards;
42
+ }
43
+
44
+ @keyframes slideIn {
45
+ from {
46
+ transform: translateX(100%);
47
+ opacity: 0;
48
+ }
49
+ to {
50
+ transform: translateX(0);
51
+ opacity: 1;
52
+ }
53
+ }
54
+
55
+ .time-picker::-webkit-calendar-picker-indicator {
56
+ filter: invert(1);
57
+ }
58
+ </style>
59
+ </head>
60
+ <body class="bg-gray-100 text-gray-800">
61
+ <!-- Login/Signup Modal -->
62
+ <div id="authModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
63
+ <div class="bg-white rounded-lg w-full max-w-md">
64
+ <div class="bg-indigo-600 text-white px-6 py-4 rounded-t-lg">
65
+ <h3 class="text-lg font-bold">تسجيل الدخول / إنشاء حساب</h3>
66
+ </div>
67
+ <div class="p-6">
68
+ <form id="authForm">
69
+ <div class="mb-4">
70
+ <label for="username" class="block text-gray-700 mb-2">اسم المستخدم</label>
71
+ <input type="text" id="username" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
72
+ </div>
73
+ <div class="mb-4">
74
+ <label for="password" class="block text-gray-700 mb-2">كلمة المرور</label>
75
+ <input type="password" id="password" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
76
+ </div>
77
+ <div class="mb-6">
78
+ <label for="whatsappNumber" class="block text-gray-700 mb-2">رقم واتساب</label>
79
+ <input type="tel" id="whatsappNumber" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567" required>
80
+ </div>
81
+ <div class="mb-6">
82
+ <label for="caretakerNumber" class="block text-gray-700 mb-2">رقم المتابع (اختياري)</label>
83
+ <input type="tel" id="caretakerNumber" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567">
84
+ </div>
85
+ <div class="flex justify-between space-x-4 space-x-reverse">
86
+ <button type="button" id="loginBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">تسجيل الدخول</button>
87
+ <button type="button" id="signupBtn" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700">إنشاء حساب</button>
88
+ </div>
89
+ </form>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="container mx-auto px-4 py-8 max-w-6xl">
95
+ <!-- Header -->
96
+ <header class="flex justify-between items-center mb-8">
97
+ <div>
98
+ <h1 class="text-3xl font-bold text-indigo-700">منبه الدواء</h1>
99
+ <p class="text-gray-600">تذكير بمواعيد الأدوية</p>
100
+ </div>
101
+ <div class="flex items-center space-x-4 space-x-reverse">
102
+ <div class="relative">
103
+ <button id="profileBtn" class="p-2 rounded-full bg-indigo-100 text-indigo-700 hover:bg-indigo-200">
104
+ <i class="fas fa-user"></i>
105
+ </button>
106
+ </div>
107
+ <div class="relative">
108
+ <button id="notificationBtn" class="p-2 rounded-full bg-indigo-100 text-indigo-700 hover:bg-indigo-200">
109
+ <i class="fas fa-bell"></i>
110
+ </button>
111
+ <span id="notificationCount" class="notification-badge hidden">0</span>
112
+ </div>
113
+ <button id="addMedBtn" class="bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 flex items-center">
114
+ <i class="fas fa-plus ml-2"></i>
115
+ <span>إضافة دواء</span>
116
+ </button>
117
+ </div>
118
+ </header>
119
+
120
+ <!-- Notification Panel (Hidden by default) -->
121
+ <div id="notificationPanel" class="hidden fixed top-20 right-4 w-80 bg-white shadow-lg rounded-lg z-50 overflow-hidden">
122
+ <div class="bg-indigo-600 text-white px-4 py-3 flex justify-between items-center">
123
+ <h3 class="font-bold">الإشعارات</h3>
124
+ <button id="closeNotificationBtn" class="text-white hover:text-indigo-200">
125
+ <i class="fas fa-times"></i>
126
+ </button>
127
+ </div>
128
+ <div id="notificationList" class="max-h-96 overflow-y-auto">
129
+ <!-- Notifications will be added here dynamically -->
130
+ <div class="p-4 text-center text-gray-500">لا توجد إشعارات</div>
131
+ </div>
132
+ </div>
133
+
134
+ <!-- Stats Cards -->
135
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-8">
136
+ <div class="bg-white p-6 rounded-lg shadow">
137
+ <div class="flex items-center">
138
+ <div class="p-3 rounded-full bg-green-100 text-green-600 mr-4">
139
+ <i class="fas fa-check-circle text-xl"></i>
140
+ </div>
141
+ <div>
142
+ <p class="text-gray-500">الجرعات المأخوذة</p>
143
+ <h3 class="text-2xl font-bold" id="takenCount">0</h3>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ <div class="bg-white p-6 rounded-lg shadow">
148
+ <div class="flex items-center">
149
+ <div class="p-3 rounded-full bg-red-100 text-red-600 mr-4">
150
+ <i class="fas fa-times-circle text-xl"></i>
151
+ </div>
152
+ <div>
153
+ <p class="text-gray-500">الجرعات الفائتة</p>
154
+ <h3 class="text-2xl font-bold" id="missedCount">0</h3>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ <div class="bg-white p-6 rounded-lg shadow">
159
+ <div class="flex items-center">
160
+ <div class="p-3 rounded-full bg-blue-100 text-blue-600 mr-4">
161
+ <i class="fas fa-pills text-xl"></i>
162
+ </div>
163
+ <div>
164
+ <p class="text-gray-500">إجمالي الأدوية</p>
165
+ <h3 class="text-2xl font-bold" id="totalMedsCount">0</h3>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <!-- Upcoming Medications -->
172
+ <div class="mb-8">
173
+ <h2 class="text-xl font-bold mb-4 flex items-center">
174
+ <i class="fas fa-clock text-indigo-600 ml-2"></i>
175
+ <span>الجرعات القادمة</span>
176
+ </h2>
177
+ <div id="upcomingMeds" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
178
+ <!-- Upcoming meds will be added here dynamically -->
179
+ <div class="bg-white p-4 rounded-lg shadow text-center text-gray-500">
180
+ لا توجد جرعات قادمة
181
+ </div>
182
+ </div>
183
+ </div>
184
+
185
+ <!-- All Medications -->
186
+ <div>
187
+ <h2 class="text-xl font-bold mb-4 flex items-center">
188
+ <i class="fas fa-list-ul text-indigo-600 ml-2"></i>
189
+ <span>جميع الأدوية</span>
190
+ </h2>
191
+ <div id="allMedsList" class="space-y-4">
192
+ <!-- All meds will be added here dynamically -->
193
+ <div class="bg-white p-4 rounded-lg shadow text-center text-gray-500">
194
+ لا توجد أدوية مسجلة
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ <!-- Add Medication Modal -->
200
+ <div id="addMedModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
201
+ <div class="bg-white rounded-lg w-full max-w-md">
202
+ <div class="bg-indigo-600 text-white px-6 py-4 rounded-t-lg flex justify-between items-center">
203
+ <h3 class="text-lg font-bold">إضافة دواء جديد</h3>
204
+ <button id="closeModalBtn" class="text-white hover:text-indigo-200">
205
+ <i class="fas fa-times"></i>
206
+ </button>
207
+ </div>
208
+ <div class="p-6">
209
+ <form id="medicationForm">
210
+ <div class="mb-4">
211
+ <label for="medName" class="block text-gray-700 mb-2">اسم الدواء</label>
212
+ <input type="text" id="medName" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
213
+ </div>
214
+ <div class="mb-4">
215
+ <label for="medDosage" class="block text-gray-700 mb-2">الجرعة</label>
216
+ <input type="text" id="medDosage" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: حبة واحدة، ملعقة صغيرة" required>
217
+ </div>
218
+ <div class="mb-4">
219
+ <label for="medTime" class="block text-gray-700 mb-2">الوقت</label>
220
+ <input type="time" id="medTime" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 time-picker" required>
221
+ </div>
222
+ <div class="mb-4">
223
+ <label for="medFrequency" class="block text-gray-700 mb-2">التكرار</label>
224
+ <select id="medFrequency" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" required>
225
+ <option value="daily">يومي</option>
226
+ <option value="weekly">أسبوعي</option>
227
+ <option value="monthly">شهري</option>
228
+ <option value="custom">مخصص</option>
229
+ </select>
230
+ </div>
231
+ <div class="mb-4 hidden" id="customDaysContainer">
232
+ <label class="block text-gray-700 mb-2">أيام الأسبوع</label>
233
+ <div class="grid grid-cols-7 gap-2">
234
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
235
+ <input type="checkbox" name="customDays" value="0" class="hidden">
236
+ <span>الأحد</span>
237
+ </label>
238
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
239
+ <input type="checkbox" name="customDays" value="1" class="hidden">
240
+ <span>الاثنين</span>
241
+ </label>
242
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
243
+ <input type="checkbox" name="customDays" value="2" class="hidden">
244
+ <span>الثلاثاء</span>
245
+ </label>
246
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
247
+ <input type="checkbox" name="customDays" value="3" class="hidden">
248
+ <span>الأربعاء</span>
249
+ </label>
250
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
251
+ <input type="checkbox" name="customDays" value="4" class="hidden">
252
+ <span>الخميس</span>
253
+ </label>
254
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
255
+ <input type="checkbox" name="customDays" value="5" class="hidden">
256
+ <span>الجمعة</span>
257
+ </label>
258
+ <label class="flex items-center justify-center p-2 border rounded-lg cursor-pointer">
259
+ <input type="checkbox" name="customDays" value="6" class="hidden">
260
+ <span>السبت</span>
261
+ </label>
262
+ </div>
263
+ </div>
264
+ <div class="mb-4">
265
+ <label for="medNotes" class="block text-gray-700 mb-2">ملاحظات (اختياري)</label>
266
+ <textarea id="medNotes" rows="3" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
267
+ </div>
268
+ <div class="mb-6">
269
+ <label class="flex items-center">
270
+ <input type="checkbox" id="enableWhatsApp" class="form-checkbox h-5 w-5 text-indigo-600">
271
+ <span class="mr-2 text-gray-700">إرسال تذكير عبر واتساب</span>
272
+ </label>
273
+ </div>
274
+ <div id="whatsappSection" class="hidden mb-6">
275
+ <div class="mb-4">
276
+ <label for="whatsappNumber" class="block text-gray-700 mb-2">رقم واتساب المريض</label>
277
+ <input type="tel" id="whatsappNumber" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567">
278
+ </div>
279
+ <div class="mb-4">
280
+ <label for="secondaryContact" class="block text-gray-700 mb-2">رقم واتساب للشخص المساعد (اختياري)</label>
281
+ <input type="tel" id="secondaryContact" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567">
282
+ </div>
283
+ </div>
284
+ <div class="flex justify-end space-x-4 space-x-reverse">
285
+ <button type="button" id="cancelMedBtn" class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100">إلغاء</button>
286
+ <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">حفظ الدواء</button>
287
+ </div>
288
+ </form>
289
+ </div>
290
+ </div>
291
+ </div>
292
+
293
+ <!-- Confirmation Modal -->
294
+ <div id="confirmModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
295
+ <div class="bg-white rounded-lg w-full max-w-md">
296
+ <div class="bg-indigo-600 text-white px-6 py-4 rounded-t-lg">
297
+ <h3 class="text-lg font-bold">تأكيد أخذ الدواء</h3>
298
+ </div>
299
+ <div class="p-6">
300
+ <p id="confirmMessage" class="mb-6">هل أخذت دواء <span class="font-bold">[اسم الدواء]</span> في الوقت المحدد؟</p>
301
+ <div class="flex justify-end space-x-4 space-x-reverse">
302
+ <button id="missedBtn" class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600">فوتتني الجرعة</button>
303
+ <button id="takenBtn" class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600">نعم، أخذتها</button>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ </div>
308
+ </div>
309
+
310
+ <script>
311
+ // Sample data for medications
312
+ let medications = JSON.parse(localStorage.getItem('medications')) || [];
313
+ let notifications = JSON.parse(localStorage.getItem('notifications')) || [];
314
+ let stats = JSON.parse(localStorage.getItem('stats')) || { taken: 0, missed: 0 };
315
+
316
+ // DOM Elements
317
+ const addMedBtn = document.getElementById('addMedBtn');
318
+ const addMedModal = document.getElementById('addMedModal');
319
+ const closeModalBtn = document.getElementById('closeModalBtn');
320
+ const cancelMedBtn = document.getElementById('cancelMedBtn');
321
+ const medicationForm = document.getElementById('medicationForm');
322
+ const medFrequency = document.getElementById('medFrequency');
323
+ const customDaysContainer = document.getElementById('customDaysContainer');
324
+ const enableWhatsApp = document.getElementById('enableWhatsApp');
325
+ const whatsappSection = document.getElementById('whatsappSection');
326
+ const notificationBtn = document.getElementById('notificationBtn');
327
+ const notificationPanel = document.getElementById('notificationPanel');
328
+ const closeNotificationBtn = document.getElementById('closeNotificationBtn');
329
+ const notificationList = document.getElementById('notificationList');
330
+ const notificationCount = document.getElementById('notificationCount');
331
+ const confirmModal = document.getElementById('confirmModal');
332
+ const confirmMessage = document.getElementById('confirmMessage');
333
+ const takenBtn = document.getElementById('takenBtn');
334
+ const missedBtn = document.getElementById('missedBtn');
335
+ const takenCount = document.getElementById('takenCount');
336
+ const missedCount = document.getElementById('missedCount');
337
+ const totalMedsCount = document.getElementById('totalMedsCount');
338
+ const upcomingMeds = document.getElementById('upcomingMeds');
339
+ const allMedsList = document.getElementById('allMedsList');
340
+
341
+ // Current medication being confirmed
342
+ let currentMedication = null;
343
+
344
+ // Event Listeners
345
+ addMedBtn.addEventListener('click', () => addMedModal.classList.remove('hidden'));
346
+ closeModalBtn.addEventListener('click', () => addMedModal.classList.add('hidden'));
347
+ cancelMedBtn.addEventListener('click', () => addMedModal.classList.add('hidden'));
348
+
349
+ medFrequency.addEventListener('change', function() {
350
+ if (this.value === 'custom') {
351
+ customDaysContainer.classList.remove('hidden');
352
+ } else {
353
+ customDaysContainer.classList.add('hidden');
354
+ }
355
+ });
356
+
357
+ enableWhatsApp.addEventListener('change', function() {
358
+ if (this.checked) {
359
+ whatsappSection.classList.remove('hidden');
360
+ } else {
361
+ whatsappSection.classList.add('hidden');
362
+ }
363
+ });
364
+
365
+ medicationForm.addEventListener('submit', addMedication);
366
+
367
+ notificationBtn.addEventListener('click', toggleNotificationPanel);
368
+ closeNotificationBtn.addEventListener('click', () => notificationPanel.classList.add('hidden'));
369
+
370
+ takenBtn.addEventListener('click', confirmTaken);
371
+ missedBtn.addEventListener('click', confirmMissed);
372
+
373
+ // Custom day checkboxes styling
374
+ document.querySelectorAll('[name="customDays"]').forEach(checkbox => {
375
+ const label = checkbox.parentElement;
376
+ checkbox.addEventListener('change', function() {
377
+ if (this.checked) {
378
+ label.classList.add('bg-indigo-100', 'border-indigo-500');
379
+ } else {
380
+ label.classList.remove('bg-indigo-100', 'border-indigo-500');
381
+ }
382
+ });
383
+ });
384
+
385
+ // Initialize the app
386
+ function init() {
387
+ updateStats();
388
+ renderMedications();
389
+ renderNotifications();
390
+ checkForDueMedications();
391
+
392
+ // Check for due medications every minute
393
+ setInterval(checkForDueMedications, 60000);
394
+ }
395
+
396
+ // Add new medication
397
+ function addMedication(e) {
398
+ e.preventDefault();
399
+
400
+ const name = document.getElementById('medName').value;
401
+ const dosage = document.getElementById('medDosage').value;
402
+ const time = document.getElementById('medTime').value;
403
+ const frequency = document.getElementById('medFrequency').value;
404
+ const notes = document.getElementById('medNotes').value;
405
+ const whatsappEnabled = document.getElementById('enableWhatsApp').checked;
406
+ const whatsappNumber = document.getElementById('whatsappNumber').value;
407
+ const secondaryContact = document.getElementById('secondaryContact').value;
408
+
409
+ let days = [];
410
+ if (frequency === 'custom') {
411
+ document.querySelectorAll('[name="customDays"]:checked').forEach(checkbox => {
412
+ days.push(parseInt(checkbox.value));
413
+ });
414
+ } else if (frequency === 'weekly') {
415
+ days = [new Date().getDay()]; // Current day of week (0-6)
416
+ } else if (frequency === 'monthly') {
417
+ days = [new Date().getDate()]; // Current day of month (1-31)
418
+ }
419
+
420
+ const medication = {
421
+ id: Date.now(),
422
+ name,
423
+ dosage,
424
+ time,
425
+ frequency,
426
+ days,
427
+ notes,
428
+ whatsappEnabled,
429
+ whatsappNumber,
430
+ secondaryContact,
431
+ createdAt: new Date().toISOString(),
432
+ active: true
433
+ };
434
+
435
+ medications.push(medication);
436
+ saveMedications();
437
+
438
+ // Reset form
439
+ medicationForm.reset();
440
+ addMedModal.classList.add('hidden');
441
+
442
+ // Update UI
443
+ updateStats();
444
+ renderMedications();
445
+
446
+ // Schedule notifications for this medication
447
+ scheduleMedicationNotifications(medication);
448
+ }
449
+
450
+ // Save medications to localStorage
451
+ function saveMedications() {
452
+ localStorage.setItem('medications', JSON.stringify(medications));
453
+ }
454
+
455
+ // Save notifications to localStorage
456
+ function saveNotifications() {
457
+ localStorage.setItem('notifications', JSON.stringify(notifications));
458
+ }
459
+
460
+ // Save stats to localStorage
461
+ function saveStats() {
462
+ localStorage.setItem('stats', JSON.stringify(stats));
463
+ }
464
+
465
+ // Update statistics
466
+ function updateStats() {
467
+ takenCount.textContent = stats.taken;
468
+ missedCount.textContent = stats.missed;
469
+ totalMedsCount.textContent = medications.length;
470
+ }
471
+
472
+ // Render medications list
473
+ function renderMedications() {
474
+ // Clear existing
475
+ allMedsList.innerHTML = '';
476
+ upcomingMeds.innerHTML = '';
477
+
478
+ if (medications.length === 0) {
479
+ allMedsList.innerHTML = '<div class="bg-white p-4 rounded-lg shadow text-center text-gray-500">لا توجد أدوية مسجلة</div>';
480
+ upcomingMeds.innerHTML = '<div class="bg-white p-4 rounded-lg shadow text-center text-gray-500">لا توجد جرعات قادمة</div>';
481
+ return;
482
+ }
483
+
484
+ // Sort medications by time
485
+ const sortedMeds = [...medications].sort((a, b) => {
486
+ return a.time.localeCompare(b.time);
487
+ });
488
+
489
+ // Filter active medications
490
+ const activeMeds = sortedMeds.filter(med => med.active);
491
+
492
+ // Render all medications
493
+ activeMeds.forEach(med => {
494
+ const medCard = createMedicationCard(med);
495
+ allMedsList.appendChild(medCard);
496
+ });
497
+
498
+ // Render upcoming medications (next 3)
499
+ const now = new Date();
500
+ const currentTime = now.getHours() * 60 + now.getMinutes();
501
+
502
+ const upcoming = activeMeds
503
+ .filter(med => {
504
+ const [hours, minutes] = med.time.split(':').map(Number);
505
+ const medTime = hours * 60 + minutes;
506
+ return medTime >= currentTime;
507
+ })
508
+ .slice(0, 3);
509
+
510
+ if (upcoming.length === 0) {
511
+ upcomingMeds.innerHTML = '<div class="bg-white p-4 rounded-lg shadow text-center text-gray-500">لا توجد جرعات قادمة</div>';
512
+ } else {
513
+ upcoming.forEach(med => {
514
+ const upcomingCard = createUpcomingCard(med);
515
+ upcomingMeds.appendChild(upcomingCard);
516
+ });
517
+ }
518
+ }
519
+
520
+ // Create medication card for all medications list
521
+ function createMedicationCard(med) {
522
+ const card = document.createElement('div');
523
+ card.className = 'bg-white p-4 rounded-lg shadow medication-card';
524
+ card.dataset.id = med.id;
525
+
526
+ const frequencyText = {
527
+ daily: 'يومي',
528
+ weekly: 'أسبوعي',
529
+ monthly: 'شهري',
530
+ custom: 'مخصص'
531
+ }[med.frequency];
532
+
533
+ let daysText = '';
534
+ if (med.frequency === 'custom' && med.days.length > 0) {
535
+ const dayNames = ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'];
536
+ daysText = med.days.map(day => dayNames[day]).join('، ');
537
+ }
538
+
539
+ card.innerHTML = `
540
+ <div class="flex justify-between items-start mb-2">
541
+ <h3 class="font-bold text-lg">${med.name}</h3>
542
+ <div class="flex space-x-2 space-x-reverse">
543
+ <button class="edit-btn p-1 text-indigo-600 hover:text-indigo-800" data-id="${med.id}">
544
+ <i class="fas fa-edit"></i>
545
+ </button>
546
+ <button class="delete-btn p-1 text-red-600 hover:text-red-800" data-id="${med.id}">
547
+ <i class="fas fa-trash-alt"></i>
548
+ </button>
549
+ </div>
550
+ </div>
551
+ <div class="flex items-center mb-2">
552
+ <i class="fas fa-bolt text-yellow-500 ml-2"></i>
553
+ <span>${med.dosage}</span>
554
+ </div>
555
+ <div class="flex items-center mb-2">
556
+ <i class="fas fa-clock text-blue-500 ml-2"></i>
557
+ <span>${med.time} - ${frequencyText}${daysText ? ' (' + daysText + ')' : ''}</span>
558
+ </div>
559
+ ${med.notes ? `
560
+ <div class="flex items-start mb-2">
561
+ <i class="fas fa-sticky-note text-green-500 ml-2 mt-1"></i>
562
+ <span>${med.notes}</span>
563
+ </div>
564
+ ` : ''}
565
+ ${med.whatsappEnabled ? `
566
+ <div class="flex items-center">
567
+ <i class="fab fa-whatsapp text-green-600 ml-2"></i>
568
+ <span>يتم إرسال تذكير عبر واتساب</span>
569
+ </div>
570
+ ` : ''}
571
+ `;
572
+
573
+ // Add event listeners to buttons
574
+ card.querySelector('.edit-btn').addEventListener('click', () => editMedication(med.id));
575
+ card.querySelector('.delete-btn').addEventListener('click', () => deleteMedication(med.id));
576
+
577
+ return card;
578
+ }
579
+
580
+ // Create upcoming medication card
581
+ function createUpcomingCard(med) {
582
+ const card = document.createElement('div');
583
+ card.className = 'bg-white p-4 rounded-lg shadow medication-card';
584
+ card.dataset.id = med.id;
585
+
586
+ card.innerHTML = `
587
+ <div class="flex justify-between items-start mb-2">
588
+ <h3 class="font-bold text-lg">${med.name}</h3>
589
+ <span class="bg-indigo-100 text-indigo-800 px-2 py-1 rounded text-sm">${med.time}</span>
590
+ </div>
591
+ <div class="flex items-center mb-2">
592
+ <i class="fas fa-bolt text-yellow-500 ml-2"></i>
593
+ <span>${med.dosage}</span>
594
+ </div>
595
+ <div class="flex items-center">
596
+ <i class="fas fa-clock text-blue-500 ml-2"></i>
597
+ <span>${med.frequency === 'daily' ? 'يومي' : med.frequency === 'weekly' ? 'أسبوعي' : 'شهري'}</span>
598
+ </div>
599
+ `;
600
+
601
+ return card;
602
+ }
603
+
604
+ // Edit medication
605
+ function editMedication(id) {
606
+ const med = medications.find(m => m.id === id);
607
+ if (!med) return;
608
+
609
+ // Fill the form with medication data
610
+ document.getElementById('medName').value = med.name;
611
+ document.getElementById('medDosage').value = med.dosage;
612
+ document.getElementById('medTime').value = med.time;
613
+ document.getElementById('medFrequency').value = med.frequency;
614
+ document.getElementById('medNotes').value = med.notes || '';
615
+ document.getElementById('enableWhatsApp').checked = med.whatsappEnabled;
616
+
617
+ if (med.frequency === 'custom') {
618
+ customDaysContainer.classList.remove('hidden');
619
+ // Check the appropriate day checkboxes
620
+ med.days.forEach(day => {
621
+ const checkbox = document.querySelector(`[name="customDays"][value="${day}"]`);
622
+ if (checkbox) {
623
+ checkbox.checked = true;
624
+ checkbox.dispatchEvent(new Event('change'));
625
+ }
626
+ });
627
+ }
628
+
629
+ if (med.whatsappEnabled) {
630
+ whatsappSection.classList.remove('hidden');
631
+ document.getElementById('whatsappNumber').value = med.whatsappNumber || '';
632
+ document.getElementById('secondaryContact').value = med.secondaryContact || '';
633
+ }
634
+
635
+ // Show the modal
636
+ addMedModal.classList.remove('hidden');
637
+
638
+ // Remove the medication (will be re-added when form is submitted)
639
+ medications = medications.filter(m => m.id !== id);
640
+ }
641
+
642
+ // Delete medication
643
+ function deleteMedication(id) {
644
+ if (confirm('هل أنت متأكد من حذف هذا الدواء؟')) {
645
+ medications = medications.filter(m => m.id !== id);
646
+ saveMedications();
647
+ renderMedications();
648
+ updateStats();
649
+ }
650
+ }
651
+
652
+ // Schedule notifications for a medication
653
+ function scheduleMedicationNotifications(med) {
654
+ // In a real app, we would use the browser's Notification API and set alarms
655
+ // For this demo, we'll just simulate it
656
+ }
657
+
658
+ // Check for due medications
659
+ function checkForDueMedications() {
660
+ const now = new Date();
661
+ const currentTime = now.getHours() * 60 + now.getMinutes();
662
+
663
+ medications.forEach(med => {
664
+ if (!med.active) return;
665
+
666
+ const [hours, minutes] = med.time.split(':').map(Number);
667
+ const medTime = hours * 60 + minutes;
668
+
669
+ // Check if medication is due now (with 1 minute tolerance)
670
+ if (Math.abs(currentTime - medTime) <= 1) {
671
+ // Check if we already notified for this medication today
672
+ const today = now.toDateString();
673
+ const alreadyNotified = notifications.some(n =>
674
+ n.medId === med.id && new Date(n.date).toDateString() === today
675
+ );
676
+
677
+ if (!alreadyNotified) {
678
+ // Create notification
679
+ const notification = {
680
+ id: Date.now(),
681
+ medId: med.id,
682
+ title: 'حان وقت الدواء',
683
+ message: `حان وقت أخذ ${med.name} (${med.dosage})`,
684
+ date: new Date().toISOString(),
685
+ read: false
686
+ };
687
+
688
+ notifications.push(notification);
689
+ saveNotifications();
690
+
691
+ // Show notification
692
+ showNotification(notification);
693
+
694
+ // Update UI
695
+ renderNotifications();
696
+
697
+ // If WhatsApp is enabled, send message (simulated)
698
+ if (med.whatsappEnabled) {
699
+ sendWhatsAppReminder(med);
700
+ }
701
+
702
+ // Show confirmation modal
703
+ currentMedication = med;
704
+ confirmMessage.innerHTML = `هل أخذت دواء <span class="font-bold">${med.name}</span> (${med.dosage}) في الوقت المحدد؟`;
705
+ confirmModal.classList.remove('hidden');
706
+ }
707
+ }
708
+ });
709
+ }
710
+
711
+ // Show notification
712
+ function showNotification(notification) {
713
+ // In a real app, we would use the browser's Notification API
714
+ // For this demo, we'll just add it to our notification list
715
+
716
+ // Play sound
717
+ const audio = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-alarm-digital-clock-beep-989.mp3');
718
+ audio.play().catch(e => console.log('Audio play failed:', e));
719
+ }
720
+
721
+ // Send WhatsApp reminder using API
722
+ function sendWhatsAppReminder(med) {
723
+ const message = `تذكير: حان وقت أخذ ${med.name} (${med.dosage})`;
724
+
725
+ // Prepare API request data
726
+ const requestData = {
727
+ apiKey: 'EAAIoEPATD6QBPJc1eQOqVyrpmut0P2WUVUCfXNLlcSFl0KA5WuSeZCaV1SDaAuhZBGPZCz1B2Rc8szs3w0aqsVeMzZCrjBMHO67E2H2cPV6vxHlcI0gwdRuQOZCIKcGLYCWG9G0EAG8itMtpDzsDIiJFj6yHyZAtkKxL0KfJhyZBBDKNB1qhydFTZApZCchTAFHuovZAFCU0EQrBFKaLTib3GAZA9HzAEpz860PNsIYNjp7ZCUoX1u3S',
728
+ message: message
729
+ };
730
+
731
+ // Primary contact
732
+ if (med.whatsappNumber) {
733
+ requestData.phone = med.whatsappNumber;
734
+ fetch('https://api.whatsapp.com/send', {
735
+ method: 'POST',
736
+ headers: {
737
+ 'Content-Type': 'application/json',
738
+ },
739
+ body: JSON.stringify(requestData)
740
+ })
741
+ .catch(error => console.error('Error sending WhatsApp:', error));
742
+ }
743
+
744
+ // Secondary contact
745
+ if (med.secondaryContact) {
746
+ requestData.phone = med.secondaryContact;
747
+ fetch('https://api.whatsapp.com/send', {
748
+ method: 'POST',
749
+ headers: {
750
+ 'Content-Type': 'application/json',
751
+ },
752
+ body: JSON.stringify(requestData)
753
+ })
754
+ .catch(error => console.error('Error sending WhatsApp to secondary contact:', error));
755
+ }
756
+ }
757
+
758
+ // Toggle notification panel
759
+ function toggleNotificationPanel() {
760
+ notificationPanel.classList.toggle('hidden');
761
+
762
+ // Mark all notifications as read when panel is opened
763
+ if (!notificationPanel.classList.contains('hidden')) {
764
+ notifications.forEach(n => n.read = true);
765
+ saveNotifications();
766
+ renderNotifications();
767
+ }
768
+ }
769
+
770
+ // Render notifications
771
+ function renderNotifications() {
772
+ notificationList.innerHTML = '';
773
+
774
+ if (notifications.length === 0) {
775
+ notificationList.innerHTML = '<div class="p-4 text-center text-gray-500">لا توجد إشعارات</div>';
776
+ notificationCount.classList.add('hidden');
777
+ return;
778
+ }
779
+
780
+ // Sort by date (newest first)
781
+ const sortedNotifications = [...notifications].sort((a, b) => {
782
+ return new Date(b.date) - new Date(a.date);
783
+ });
784
+
785
+ // Show only the last 10 notifications
786
+ const recentNotifications = sortedNotifications.slice(0, 10);
787
+
788
+ recentNotifications.forEach(notif => {
789
+ const med = medications.find(m => m.id === notif.medId);
790
+ if (!med) return;
791
+
792
+ const notifElement = document.createElement('div');
793
+ notifElement.className = `p-4 border-b ${notif.read ? 'bg-white' : 'bg-blue-50'}`;
794
+
795
+ notifElement.innerHTML = `
796
+ <div class="flex justify-between items-start mb-1">
797
+ <h4 class="font-bold">${notif.title}</h4>
798
+ <span class="text-xs text-gray-500">${formatDate(notif.date)}</span>
799
+ </div>
800
+ <p class="text-gray-700">${notif.message}</p>
801
+ ${med.notes ? `<p class="text-sm text-gray-600 mt-1">ملاحظة: ${med.notes}</p>` : ''}
802
+ `;
803
+
804
+ notificationList.appendChild(notifElement);
805
+ });
806
+
807
+ // Update notification badge
808
+ const unreadCount = notifications.filter(n => !n.read).length;
809
+ if (unreadCount > 0) {
810
+ notificationCount.textContent = unreadCount;
811
+ notificationCount.classList.remove('hidden');
812
+ } else {
813
+ notificationCount.classList.add('hidden');
814
+ }
815
+ }
816
+
817
+ // Format date for display
818
+ function formatDate(dateString) {
819
+ const date = new Date(dateString);
820
+ return date.toLocaleTimeString('ar-EG', { hour: '2-digit', minute: '2-digit' });
821
+ }
822
+
823
+ // Confirm medication was taken
824
+ function confirmTaken() {
825
+ if (!currentMedication) return;
826
+
827
+ stats.taken++;
828
+ saveStats();
829
+ updateStats();
830
+
831
+ confirmModal.classList.add('hidden');
832
+ currentMedication = null;
833
+ }
834
+
835
+ // Confirm medication was missed
836
+ function confirmMissed() {
837
+ if (!currentMedication) return;
838
+
839
+ stats.missed++;
840
+ saveStats();
841
+ updateStats();
842
+
843
+ // Add missed notification
844
+ const notification = {
845
+ id: Date.now(),
846
+ medId: currentMedication.id,
847
+ title: 'جرعة فائتة',
848
+ message: `فوتت جرعة ${currentMedication.name} (${currentMedication.dosage})`,
849
+ date: new Date().toISOString(),
850
+ read: false
851
+ };
852
+
853
+ notifications.push(notification);
854
+ saveNotifications();
855
+ renderNotifications();
856
+
857
+ confirmModal.classList.add('hidden');
858
+ currentMedication = null;
859
+ }
860
+
861
+ <!-- Profile Settings Modal -->
862
+ <div id="profileModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
863
+ <div class="bg-white rounded-lg w-full max-w-md">
864
+ <div class="bg-indigo-600 text-white px-6 py-4 rounded-t-lg flex justify-between items-center">
865
+ <h3 class="text-lg font-bold">إعدادات الحساب</h3>
866
+ <button id="closeProfileBtn" class="text-white hover:text-indigo-200">
867
+ <i class="fas fa-times"></i>
868
+ </button>
869
+ </div>
870
+ <div class="p-6">
871
+ <div class="mb-4">
872
+ <label class="block text-gray-700 mb-2">اسم المستخدم</label>
873
+ <p id="profileUsername" class="font-bold"></p>
874
+ </div>
875
+ <div class="mb-4">
876
+ <label for="profileWhatsapp" class="block text-gray-700 mb-2">رقم واتساب</label>
877
+ <input type="tel" id="profileWhatsapp" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567">
878
+ </div>
879
+ <div class="mb-4">
880
+ <label for="profileCaretaker" class="block text-gray-700 mb-2">رقم المتابع</label>
881
+ <input type="tel" id="profileCaretaker" class="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="مثال: 966501234567">
882
+ </div>
883
+ <div class="mb-4">
884
+ <label class="flex items-center">
885
+ <input type="checkbox" id="shareList" class="form-checkbox h-5 w-5 text-indigo-600">
886
+ <span class="mr-2 text-gray-700">مشاركة قائمة الأدوية مع المتابع</span>
887
+ </label>
888
+ </div>
889
+ <div class="flex justify-end space-x-4 space-x-reverse">
890
+ <button id="logoutBtn" class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600">تسجيل الخروج</button>
891
+ <button id="saveProfileBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">حفظ التغييرات</button>
892
+ </div>
893
+ </div>
894
+ </div>
895
+ </div>
896
+
897
+ // Initialize the app
898
+ document.addEventListener('DOMContentLoaded', function() {
899
+ // Check if user is logged in
900
+ const currentUser = JSON.parse(localStorage.getItem('currentUser'));
901
+ if (!currentUser) {
902
+ document.getElementById('authModal').classList.remove('hidden');
903
+ } else {
904
+ init();
905
+ }
906
+ });
907
+
908
+ // User authentication functions
909
+ const users = JSON.parse(localStorage.getItem('users')) || [];
910
+
911
+ document.getElementById('signupBtn').addEventListener('click', function() {
912
+ const username = document.getElementById('username').value;
913
+ const password = document.getElementById('password').value;
914
+ const whatsapp = document.getElementById('whatsappNumber').value;
915
+ const caretaker = document.getElementById('caretakerNumber').value;
916
+
917
+ if (users.some(u => u.username === username)) {
918
+ alert('اسم المستخدم موجود بالفعل');
919
+ return;
920
+ }
921
+
922
+ const newUser = {
923
+ username,
924
+ password,
925
+ whatsapp,
926
+ caretaker,
927
+ shareList: false,
928
+ medications: []
929
+ };
930
+
931
+ users.push(newUser);
932
+ localStorage.setItem('users', JSON.stringify(users));
933
+ localStorage.setItem('currentUser', JSON.stringify(username));
934
+ document.getElementById('authModal').classList.add('hidden');
935
+ location.reload();
936
+ });
937
+
938
+ document.getElementById('loginBtn').addEventListener('click', function() {
939
+ const username = document.getElementById('username').value;
940
+ const password = document.getElementById('password').value;
941
+
942
+ const user = users.find(u => u.username === username && u.password === password);
943
+ if (!user) {
944
+ alert('اسم المستخدم أو كلمة المرور غير صحيحة');
945
+ return;
946
+ }
947
+
948
+ localStorage.setItem('currentUser', JSON.stringify(username));
949
+ document.getElementById('authModal').classList.add('hidden');
950
+ location.reload();
951
+ });
952
+
953
+ // Profile functions
954
+ document.getElementById('profileBtn').addEventListener('click', function() {
955
+ const currentUser = JSON.parse(localStorage.getItem('currentUser'));
956
+ const user = users.find(u => u.username === currentUser);
957
+
958
+ document.getElementById('profileUsername').textContent = user.username;
959
+ document.getElementById('profileWhatsapp').value = user.whatsapp;
960
+ document.getElementById('profileCaretaker').value = user.caretaker || '';
961
+ document.getElementById('shareList').checked = user.shareList || false;
962
+
963
+ document.getElementById('profileModal').classList.remove('hidden');
964
+ });
965
+
966
+ document.getElementById('closeProfileBtn').addEventListener('click', function() {
967
+ document.getElementById('profileModal').classList.add('hidden');
968
+ });
969
+
970
+ document.getElementById('saveProfileBtn').addEventListener('click', function() {
971
+ const currentUser = JSON.parse(localStorage.getItem('currentUser'));
972
+ const userIndex = users.findIndex(u => u.username === currentUser);
973
+
974
+ users[userIndex].whatsapp = document.getElementById('profileWhatsapp').value;
975
+ users[userIndex].caretaker = document.getElementById('profileCaretaker').value;
976
+ users[userIndex].shareList = document.getElementById('shareList').checked;
977
+
978
+ localStorage.setItem('users', JSON.stringify(users));
979
+ document.getElementById('profileModal').classList.add('hidden');
980
+ });
981
+
982
+ document.getElementById('logoutBtn').addEventListener('click', function() {
983
+ localStorage.removeItem('currentUser');
984
+ location.reload();
985
+ });
986
+
987
+ // Modify init function to load user-specific data
988
+ function init() {
989
+ const currentUser = JSON.parse(localStorage.getItem('currentUser'));
990
+ const user = users.find(u => u.username === currentUser);
991
+
992
+ // Load user's medications
993
+ medications = user.medications || [];
994
+
995
+ updateStats();
996
+ renderMedications();
997
+ renderNotifications();
998
+ checkForDueMedications();
999
+
1000
+ setInterval(checkForDueMedications, 60000);
1001
+ }
1002
+ </script>
1003
+ <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=Youssef117/dwaa2a" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
1004
+ </html>