seannyboy commited on
Commit
c2d8afa
·
verified ·
1 Parent(s): 31df713

create a calendar for the next many years and make a function to add reminders that will be sent as a notification and add events - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +822 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Calendar Pro
3
- emoji: 😻
4
- colorFrom: blue
5
- colorTo: red
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: calendar-pro
3
+ emoji: 🐳
4
+ colorFrom: purple
5
+ colorTo: purple
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,822 @@
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="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Advanced Calendar App</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
+ /* Custom scrollbar */
11
+ ::-webkit-scrollbar {
12
+ width: 8px;
13
+ }
14
+ ::-webkit-scrollbar-track {
15
+ background: #f1f1f1;
16
+ }
17
+ ::-webkit-scrollbar-thumb {
18
+ background: #888;
19
+ border-radius: 4px;
20
+ }
21
+ ::-webkit-scrollbar-thumb:hover {
22
+ background: #555;
23
+ }
24
+
25
+ /* Animation for notifications */
26
+ @keyframes slideIn {
27
+ from { transform: translateX(100%); }
28
+ to { transform: translateX(0); }
29
+ }
30
+
31
+ @keyframes fadeOut {
32
+ from { opacity: 1; }
33
+ to { opacity: 0; }
34
+ }
35
+
36
+ .notification {
37
+ animation: slideIn 0.3s ease-out, fadeOut 0.5s ease-out 4.5s forwards;
38
+ }
39
+
40
+ /* Custom checkbox */
41
+ .custom-checkbox {
42
+ appearance: none;
43
+ -webkit-appearance: none;
44
+ width: 20px;
45
+ height: 20px;
46
+ border: 2px solid #3b82f6;
47
+ border-radius: 4px;
48
+ outline: none;
49
+ cursor: pointer;
50
+ position: relative;
51
+ }
52
+
53
+ .custom-checkbox:checked {
54
+ background-color: #3b82f6;
55
+ }
56
+
57
+ .custom-checkbox:checked::after {
58
+ content: '\2713';
59
+ position: absolute;
60
+ color: white;
61
+ font-size: 14px;
62
+ top: 50%;
63
+ left: 50%;
64
+ transform: translate(-50%, -50%);
65
+ }
66
+
67
+ /* Event dot indicator */
68
+ .event-dot {
69
+ width: 8px;
70
+ height: 8px;
71
+ border-radius: 50%;
72
+ display: inline-block;
73
+ margin-right: 2px;
74
+ }
75
+ </style>
76
+ </head>
77
+ <body class="bg-gray-100 min-h-screen">
78
+ <div class="container mx-auto px-4 py-8">
79
+ <!-- Header -->
80
+ <header class="flex flex-col md:flex-row justify-between items-center mb-8">
81
+ <h1 class="text-3xl font-bold text-indigo-700 mb-4 md:mb-0">Calendar Pro</h1>
82
+ <div class="flex items-center space-x-4">
83
+ <button id="today-btn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition">
84
+ Today
85
+ </button>
86
+ <div class="flex items-center">
87
+ <button id="prev-month" class="p-2 rounded-full hover:bg-gray-200 transition">
88
+ <i class="fas fa-chevron-left text-gray-700"></i>
89
+ </button>
90
+ <h2 id="current-month-year" class="mx-4 text-xl font-semibold text-gray-800">June 2023</h2>
91
+ <button id="next-month" class="p-2 rounded-full hover:bg-gray-200 transition">
92
+ <i class="fas fa-chevron-right text-gray-700"></i>
93
+ </button>
94
+ </div>
95
+ <div class="relative">
96
+ <select id="year-select" class="appearance-none bg-white border border-gray-300 rounded-lg px-4 py-2 pr-8 focus:outline-none focus:ring-2 focus:ring-indigo-500">
97
+ <!-- Years will be populated by JavaScript -->
98
+ </select>
99
+ <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
100
+ <i class="fas fa-chevron-down"></i>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </header>
105
+
106
+ <!-- Main Content -->
107
+ <div class="flex flex-col lg:flex-row gap-6">
108
+ <!-- Calendar View -->
109
+ <div class="bg-white rounded-xl shadow-lg p-6 flex-1">
110
+ <!-- Weekday Headers -->
111
+ <div class="grid grid-cols-7 gap-1 mb-4">
112
+ <div class="text-center font-medium text-gray-500 py-2">Sun</div>
113
+ <div class="text-center font-medium text-gray-500 py-2">Mon</div>
114
+ <div class="text-center font-medium text-gray-500 py-2">Tue</div>
115
+ <div class="text-center font-medium text-gray-500 py-2">Wed</div>
116
+ <div class="text-center font-medium text-gray-500 py-2">Thu</div>
117
+ <div class="text-center font-medium text-gray-500 py-2">Fri</div>
118
+ <div class="text-center font-medium text-gray-500 py-2">Sat</div>
119
+ </div>
120
+
121
+ <!-- Calendar Grid -->
122
+ <div id="calendar-grid" class="grid grid-cols-7 gap-1">
123
+ <!-- Days will be populated by JavaScript -->
124
+ </div>
125
+ </div>
126
+
127
+ <!-- Sidebar - Events and Add Form -->
128
+ <div class="w-full lg:w-80 flex flex-col gap-6">
129
+ <!-- Upcoming Events -->
130
+ <div class="bg-white rounded-xl shadow-lg p-6">
131
+ <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
132
+ <i class="fas fa-calendar-day text-indigo-600 mr-2"></i>
133
+ Upcoming Events
134
+ </h3>
135
+ <div id="upcoming-events" class="space-y-3 max-h-64 overflow-y-auto">
136
+ <!-- Events will be populated by JavaScript -->
137
+ </div>
138
+ </div>
139
+
140
+ <!-- Add Event Form -->
141
+ <div class="bg-white rounded-xl shadow-lg p-6">
142
+ <h3 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
143
+ <i class="fas fa-plus-circle text-indigo-600 mr-2"></i>
144
+ Add Event/Reminder
145
+ </h3>
146
+ <form id="event-form" class="space-y-4">
147
+ <div>
148
+ <label for="event-title" class="block text-sm font-medium text-gray-700 mb-1">Title</label>
149
+ <input type="text" id="event-title" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" required>
150
+ </div>
151
+ <div>
152
+ <label for="event-date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
153
+ <input type="date" id="event-date" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" required>
154
+ </div>
155
+ <div class="flex gap-4">
156
+ <div class="flex-1">
157
+ <label for="event-start-time" class="block text-sm font-medium text-gray-700 mb-1">Start Time</label>
158
+ <input type="time" id="event-start-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
159
+ </div>
160
+ <div class="flex-1">
161
+ <label for="event-end-time" class="block text-sm font-medium text-gray-700 mb-1">End Time</label>
162
+ <input type="time" id="event-end-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
163
+ </div>
164
+ </div>
165
+ <div>
166
+ <label for="event-color" class="block text-sm font-medium text-gray-700 mb-1">Color</label>
167
+ <select id="event-color" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
168
+ <option value="bg-blue-500">Blue</option>
169
+ <option value="bg-red-500">Red</option>
170
+ <option value="bg-green-500">Green</option>
171
+ <option value="bg-yellow-500">Yellow</option>
172
+ <option value="bg-purple-500">Purple</option>
173
+ <option value="bg-pink-500">Pink</option>
174
+ </select>
175
+ </div>
176
+ <div class="flex items-center">
177
+ <input type="checkbox" id="event-reminder" class="custom-checkbox">
178
+ <label for="event-reminder" class="ml-2 text-sm font-medium text-gray-700">Set Reminder</label>
179
+ </div>
180
+ <div id="reminder-options" class="hidden pl-6 space-y-2">
181
+ <div>
182
+ <label for="reminder-time" class="block text-sm font-medium text-gray-700 mb-1">Remind Before</label>
183
+ <select id="reminder-time" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
184
+ <option value="5">5 minutes</option>
185
+ <option value="15">15 minutes</option>
186
+ <option value="30">30 minutes</option>
187
+ <option value="60">1 hour</option>
188
+ <option value="1440">1 day</option>
189
+ </select>
190
+ </div>
191
+ </div>
192
+ <button type="submit" class="w-full py-2 px-4 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 transition flex items-center justify-center">
193
+ <i class="fas fa-save mr-2"></i> Save Event
194
+ </button>
195
+ </form>
196
+ </div>
197
+ </div>
198
+ </div>
199
+ </div>
200
+
201
+ <!-- Notification Container -->
202
+ <div id="notification-container" class="fixed bottom-4 right-4 space-y-2 z-50"></div>
203
+
204
+ <script>
205
+ document.addEventListener('DOMContentLoaded', function() {
206
+ // Current date
207
+ let currentDate = new Date();
208
+ let currentMonth = currentDate.getMonth();
209
+ let currentYear = currentDate.getFullYear();
210
+
211
+ // DOM Elements
212
+ const calendarGrid = document.getElementById('calendar-grid');
213
+ const currentMonthYear = document.getElementById('current-month-year');
214
+ const prevMonthBtn = document.getElementById('prev-month');
215
+ const nextMonthBtn = document.getElementById('next-month');
216
+ const todayBtn = document.getElementById('today-btn');
217
+ const yearSelect = document.getElementById('year-select');
218
+ const upcomingEvents = document.getElementById('upcoming-events');
219
+ const eventForm = document.getElementById('event-form');
220
+ const eventDateInput = document.getElementById('event-date');
221
+ const reminderCheckbox = document.getElementById('event-reminder');
222
+ const reminderOptions = document.getElementById('reminder-options');
223
+ const notificationContainer = document.getElementById('notification-container');
224
+
225
+ // Events storage
226
+ let events = JSON.parse(localStorage.getItem('calendarEvents')) || [];
227
+
228
+ // Initialize calendar
229
+ function initCalendar() {
230
+ populateYearDropdown();
231
+ renderCalendar(currentMonth, currentYear);
232
+ renderUpcomingEvents();
233
+ setFormDate();
234
+
235
+ // Check for reminders every minute
236
+ setInterval(checkReminders, 60000);
237
+ }
238
+
239
+ // Populate year dropdown
240
+ function populateYearDropdown() {
241
+ yearSelect.innerHTML = '';
242
+ const startYear = currentYear - 10;
243
+ const endYear = currentYear + 20;
244
+
245
+ for (let year = startYear; year <= endYear; year++) {
246
+ const option = document.createElement('option');
247
+ option.value = year;
248
+ option.textContent = year;
249
+ if (year === currentYear) {
250
+ option.selected = true;
251
+ }
252
+ yearSelect.appendChild(option);
253
+ }
254
+ }
255
+
256
+ // Render calendar
257
+ function renderCalendar(month, year) {
258
+ // Update month/year display
259
+ const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
260
+ currentMonthYear.textContent = `${monthNames[month]} ${year}`;
261
+
262
+ // Clear previous calendar
263
+ calendarGrid.innerHTML = '';
264
+
265
+ // Get first day of month and total days in month
266
+ const firstDay = new Date(year, month, 1).getDay();
267
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
268
+
269
+ // Get days from previous month
270
+ const prevMonthDays = new Date(year, month, 0).getDate();
271
+
272
+ // Add days from previous month
273
+ for (let i = 0; i < firstDay; i++) {
274
+ const dayElement = createDayElement(prevMonthDays - firstDay + i + 1, true);
275
+ calendarGrid.appendChild(dayElement);
276
+ }
277
+
278
+ // Add days from current month
279
+ for (let i = 1; i <= daysInMonth; i++) {
280
+ const dayElement = createDayElement(i, false, month, year);
281
+ calendarGrid.appendChild(dayElement);
282
+ }
283
+
284
+ // Calculate remaining cells to fill the grid
285
+ const totalCells = firstDay + daysInMonth;
286
+ const remainingCells = totalCells % 7 === 0 ? 0 : 7 - (totalCells % 7);
287
+
288
+ // Add days from next month
289
+ for (let i = 1; i <= remainingCells; i++) {
290
+ const dayElement = createDayElement(i, true);
291
+ calendarGrid.appendChild(dayElement);
292
+ }
293
+ }
294
+
295
+ // Create day element
296
+ function createDayElement(day, isOtherMonth, month = currentMonth, year = currentYear) {
297
+ const dayElement = document.createElement('div');
298
+ dayElement.className = 'p-2 h-24 border border-gray-100 overflow-hidden';
299
+
300
+ if (isOtherMonth) {
301
+ dayElement.classList.add('bg-gray-50', 'text-gray-400');
302
+ } else {
303
+ dayElement.classList.add('hover:bg-gray-50');
304
+
305
+ // Check if it's today
306
+ const today = new Date();
307
+ if (day === today.getDate() && month === today.getMonth() && year === today.getFullYear()) {
308
+ dayElement.classList.add('bg-indigo-100', 'font-semibold');
309
+ }
310
+
311
+ // Check for events on this day
312
+ const dateStr = formatDate(new Date(year, month, day));
313
+ const dayEvents = events.filter(event => event.date === dateStr);
314
+
315
+ if (dayEvents.length > 0) {
316
+ const eventIndicator = document.createElement('div');
317
+ eventIndicator.className = 'flex flex-wrap mb-1';
318
+
319
+ dayEvents.forEach(event => {
320
+ const dot = document.createElement('span');
321
+ dot.className = `event-dot ${event.color}`;
322
+ eventIndicator.appendChild(dot);
323
+ });
324
+
325
+ dayElement.appendChild(eventIndicator);
326
+ }
327
+ }
328
+
329
+ const dayNumber = document.createElement('div');
330
+ dayNumber.className = 'text-right font-medium';
331
+ dayNumber.textContent = day;
332
+ dayElement.appendChild(dayNumber);
333
+
334
+ // Add click event to show events for this day
335
+ if (!isOtherMonth) {
336
+ dayElement.addEventListener('click', () => {
337
+ showDayEvents(day, month, year);
338
+ });
339
+ }
340
+
341
+ return dayElement;
342
+ }
343
+
344
+ // Show events for a specific day
345
+ function showDayEvents(day, month, year) {
346
+ const date = new Date(year, month, day);
347
+ const dateStr = formatDate(date);
348
+ const dayEvents = events.filter(event => event.date === dateStr);
349
+
350
+ if (dayEvents.length === 0) {
351
+ showNotification('No events for this day', 'bg-blue-500');
352
+ return;
353
+ }
354
+
355
+ let message = `Events for ${date.toDateString()}:\n\n`;
356
+ dayEvents.forEach(event => {
357
+ message += `• ${event.title}`;
358
+ if (event.startTime) {
359
+ message += ` at ${event.startTime}`;
360
+ if (event.endTime) {
361
+ message += ` - ${event.endTime}`;
362
+ }
363
+ }
364
+ message += '\n';
365
+ });
366
+
367
+ alert(message);
368
+ }
369
+
370
+ // Render upcoming events
371
+ function renderUpcomingEvents() {
372
+ upcomingEvents.innerHTML = '';
373
+
374
+ if (events.length === 0) {
375
+ upcomingEvents.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>';
376
+ return;
377
+ }
378
+
379
+ // Sort events by date
380
+ const sortedEvents = [...events].sort((a, b) => {
381
+ return new Date(a.date) - new Date(b.date);
382
+ });
383
+
384
+ // Filter events that are today or in the future
385
+ const today = new Date();
386
+ today.setHours(0, 0, 0, 0);
387
+
388
+ const upcoming = sortedEvents.filter(event => {
389
+ const eventDate = new Date(event.date);
390
+ return eventDate >= today;
391
+ });
392
+
393
+ if (upcoming.length === 0) {
394
+ upcomingEvents.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>';
395
+ return;
396
+ }
397
+
398
+ // Display next 5 events
399
+ const displayEvents = upcoming.slice(0, 5);
400
+
401
+ displayEvents.forEach(event => {
402
+ const eventElement = document.createElement('div');
403
+ eventElement.className = 'p-3 rounded-lg border border-gray-200 hover:bg-gray-50 transition cursor-pointer';
404
+
405
+ const eventDate = new Date(event.date);
406
+ const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
407
+
408
+ let timeStr = '';
409
+ if (event.startTime) {
410
+ timeStr = ` at ${event.startTime}`;
411
+ if (event.endTime) {
412
+ timeStr += ` - ${event.endTime}`;
413
+ }
414
+ }
415
+
416
+ eventElement.innerHTML = `
417
+ <div class="flex items-start">
418
+ <div class="w-2 h-10 rounded-full ${event.color} mr-3"></div>
419
+ <div class="flex-1">
420
+ <h4 class="font-medium text-gray-800">${event.title}</h4>
421
+ <p class="text-sm text-gray-600">${dateStr}${timeStr}</p>
422
+ ${event.reminder ? '<span class="inline-block mt-1 px-2 py-1 text-xs bg-yellow-100 text-yellow-800 rounded-full">Reminder Set</span>' : ''}
423
+ </div>
424
+ <button class="delete-event text-gray-400 hover:text-red-500" data-id="${event.id}">
425
+ <i class="fas fa-trash-alt"></i>
426
+ </button>
427
+ </div>
428
+ `;
429
+
430
+ eventElement.querySelector('.delete-event').addEventListener('click', (e) => {
431
+ e.stopPropagation();
432
+ deleteEvent(event.id);
433
+ });
434
+
435
+ eventElement.addEventListener('click', () => {
436
+ showEventDetails(event);
437
+ });
438
+
439
+ upcomingEvents.appendChild(eventElement);
440
+ });
441
+
442
+ if (upcoming.length > 5) {
443
+ const moreEvents = document.createElement('div');
444
+ moreEvents.className = 'text-center text-indigo-600 font-medium mt-2 cursor-pointer hover:underline';
445
+ moreEvents.textContent = `+ ${upcoming.length - 5} more events`;
446
+ moreEvents.addEventListener('click', () => {
447
+ showAllUpcomingEvents(upcoming);
448
+ });
449
+ upcomingEvents.appendChild(moreEvents);
450
+ }
451
+ }
452
+
453
+ // Show all upcoming events
454
+ function showAllUpcomingEvents(events) {
455
+ const modal = document.createElement('div');
456
+ modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4';
457
+
458
+ const modalContent = document.createElement('div');
459
+ modalContent.className = 'bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[80vh] overflow-y-auto';
460
+
461
+ const modalHeader = document.createElement('div');
462
+ modalHeader.className = 'border-b border-gray-200 p-4 flex justify-between items-center';
463
+ modalHeader.innerHTML = `
464
+ <h3 class="text-xl font-semibold text-gray-800">All Upcoming Events</h3>
465
+ <button class="text-gray-500 hover:text-gray-700">
466
+ <i class="fas fa-times"></i>
467
+ </button>
468
+ `;
469
+
470
+ const modalBody = document.createElement('div');
471
+ modalBody.className = 'p-4';
472
+
473
+ if (events.length === 0) {
474
+ modalBody.innerHTML = '<p class="text-gray-500 text-center py-4">No upcoming events</p>';
475
+ } else {
476
+ events.forEach(event => {
477
+ const eventElement = document.createElement('div');
478
+ eventElement.className = 'p-3 rounded-lg border border-gray-200 hover:bg-gray-50 transition cursor-pointer mb-2';
479
+
480
+ const eventDate = new Date(event.date);
481
+ const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
482
+
483
+ let timeStr = '';
484
+ if (event.startTime) {
485
+ timeStr = ` at ${event.startTime}`;
486
+ if (event.endTime) {
487
+ timeStr += ` - ${event.endTime}`;
488
+ }
489
+ }
490
+
491
+ eventElement.innerHTML = `
492
+ <div class="flex items-start">
493
+ <div class="w-2 h-10 rounded-full ${event.color} mr-3"></div>
494
+ <div class="flex-1">
495
+ <h4 class="font-medium text-gray-800">${event.title}</h4>
496
+ <p class="text-sm text-gray-600">${dateStr}${timeStr}</p>
497
+ ${event.reminder ? '<span class="inline-block mt-1 px-2 py-1 text-xs bg-yellow-100 text-yellow-800 rounded-full">Reminder Set</span>' : ''}
498
+ </div>
499
+ <button class="delete-event text-gray-400 hover:text-red-500" data-id="${event.id}">
500
+ <i class="fas fa-trash-alt"></i>
501
+ </button>
502
+ </div>
503
+ `;
504
+
505
+ eventElement.querySelector('.delete-event').addEventListener('click', (e) => {
506
+ e.stopPropagation();
507
+ deleteEvent(event.id);
508
+ modal.remove();
509
+ });
510
+
511
+ eventElement.addEventListener('click', () => {
512
+ showEventDetails(event);
513
+ modal.remove();
514
+ });
515
+
516
+ modalBody.appendChild(eventElement);
517
+ });
518
+ }
519
+
520
+ modalContent.appendChild(modalHeader);
521
+ modalContent.appendChild(modalBody);
522
+ modal.appendChild(modalContent);
523
+
524
+ document.body.appendChild(modal);
525
+
526
+ modal.querySelector('button').addEventListener('click', () => {
527
+ modal.remove();
528
+ });
529
+ }
530
+
531
+ // Show event details
532
+ function showEventDetails(event) {
533
+ const modal = document.createElement('div');
534
+ modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4';
535
+
536
+ const modalContent = document.createElement('div');
537
+ modalContent.className = 'bg-white rounded-xl shadow-xl w-full max-w-md';
538
+
539
+ const eventDate = new Date(event.date);
540
+ const dateStr = eventDate.toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' });
541
+
542
+ let timeStr = 'All day';
543
+ if (event.startTime) {
544
+ timeStr = event.startTime;
545
+ if (event.endTime) {
546
+ timeStr += ` - ${event.endTime}`;
547
+ }
548
+ }
549
+
550
+ modalContent.innerHTML = `
551
+ <div class="border-b border-gray-200 p-4 flex justify-between items-center">
552
+ <h3 class="text-xl font-semibold text-gray-800">Event Details</h3>
553
+ <button class="text-gray-500 hover:text-gray-700">
554
+ <i class="fas fa-times"></i>
555
+ </button>
556
+ </div>
557
+ <div class="p-6">
558
+ <div class="flex items-start mb-6">
559
+ <div class="w-3 h-12 rounded-full ${event.color} mr-4"></div>
560
+ <div>
561
+ <h4 class="text-2xl font-bold text-gray-800 mb-1">${event.title}</h4>
562
+ <p class="text-gray-600">${dateStr}</p>
563
+ <p class="text-gray-600">${timeStr}</p>
564
+ </div>
565
+ </div>
566
+ ${event.reminder ? `
567
+ <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6">
568
+ <div class="flex">
569
+ <div class="flex-shrink-0">
570
+ <i class="fas fa-bell text-yellow-400"></i>
571
+ </div>
572
+ <div class="ml-3">
573
+ <p class="text-sm text-yellow-700">
574
+ Reminder set for ${event.reminderTime} minutes before event
575
+ </p>
576
+ </div>
577
+ </div>
578
+ </div>
579
+ ` : ''}
580
+ <div class="flex justify-end space-x-3">
581
+ <button class="edit-event px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition" data-id="${event.id}">
582
+ <i class="fas fa-edit mr-2"></i> Edit
583
+ </button>
584
+ <button class="delete-event px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition" data-id="${event.id}">
585
+ <i class="fas fa-trash-alt mr-2"></i> Delete
586
+ </button>
587
+ </div>
588
+ </div>
589
+ `;
590
+
591
+ modal.appendChild(modalContent);
592
+ document.body.appendChild(modal);
593
+
594
+ modal.querySelector('button').addEventListener('click', () => {
595
+ modal.remove();
596
+ });
597
+
598
+ modal.querySelector('.delete-event').addEventListener('click', () => {
599
+ deleteEvent(event.id);
600
+ modal.remove();
601
+ });
602
+
603
+ modal.querySelector('.edit-event').addEventListener('click', () => {
604
+ editEvent(event);
605
+ modal.remove();
606
+ });
607
+ }
608
+
609
+ // Edit event
610
+ function editEvent(event) {
611
+ // Set form values
612
+ document.getElementById('event-title').value = event.title;
613
+ document.getElementById('event-date').value = event.date;
614
+ document.getElementById('event-start-time').value = event.startTime || '';
615
+ document.getElementById('event-end-time').value = event.endTime || '';
616
+ document.getElementById('event-color').value = event.color;
617
+
618
+ if (event.reminder) {
619
+ document.getElementById('event-reminder').checked = true;
620
+ reminderOptions.classList.remove('hidden');
621
+ document.getElementById('reminder-time').value = event.reminderTime;
622
+ } else {
623
+ document.getElementById('event-reminder').checked = false;
624
+ reminderOptions.classList.add('hidden');
625
+ }
626
+
627
+ // Change form to edit mode
628
+ eventForm.dataset.mode = 'edit';
629
+ eventForm.dataset.id = event.id;
630
+
631
+ // Change button text
632
+ eventForm.querySelector('button').innerHTML = '<i class="fas fa-save mr-2"></i> Update Event';
633
+
634
+ // Scroll to form
635
+ eventForm.scrollIntoView({ behavior: 'smooth' });
636
+ }
637
+
638
+ // Delete event
639
+ function deleteEvent(id) {
640
+ if (confirm('Are you sure you want to delete this event?')) {
641
+ events = events.filter(event => event.id !== id);
642
+ saveEvents();
643
+ renderCalendar(currentMonth, currentYear);
644
+ renderUpcomingEvents();
645
+ showNotification('Event deleted', 'bg-green-500');
646
+ }
647
+ }
648
+
649
+ // Save events to localStorage
650
+ function saveEvents() {
651
+ localStorage.setItem('calendarEvents', JSON.stringify(events));
652
+ }
653
+
654
+ // Format date as YYYY-MM-DD
655
+ function formatDate(date) {
656
+ const d = new Date(date);
657
+ let month = '' + (d.getMonth() + 1);
658
+ let day = '' + d.getDate();
659
+ const year = d.getFullYear();
660
+
661
+ if (month.length < 2) month = '0' + month;
662
+ if (day.length < 2) day = '0' + day;
663
+
664
+ return [year, month, day].join('-');
665
+ }
666
+
667
+ // Set form date to today
668
+ function setFormDate() {
669
+ eventDateInput.value = formatDate(currentDate);
670
+ }
671
+
672
+ // Show notification
673
+ function showNotification(message, bgColor = 'bg-indigo-600') {
674
+ const notification = document.createElement('div');
675
+ notification.className = `notification ${bgColor} text-white px-6 py-3 rounded-lg shadow-lg flex items-center`;
676
+ notification.innerHTML = `
677
+ <i class="fas fa-info-circle mr-2"></i>
678
+ <span>${message}</span>
679
+ `;
680
+
681
+ notificationContainer.appendChild(notification);
682
+
683
+ // Remove notification after 5 seconds
684
+ setTimeout(() => {
685
+ notification.remove();
686
+ }, 5000);
687
+ }
688
+
689
+ // Check for reminders
690
+ function checkReminders() {
691
+ const now = new Date();
692
+
693
+ events.forEach(event => {
694
+ if (event.reminder && !event.reminderShown) {
695
+ const eventDate = new Date(`${event.date}T${event.startTime || '00:00'}:00`);
696
+ const reminderTime = parseInt(event.reminderTime);
697
+
698
+ // Calculate reminder time (in minutes)
699
+ const reminderDate = new Date(eventDate.getTime() - reminderTime * 60000);
700
+
701
+ if (now >= reminderDate && now < eventDate) {
702
+ // Show notification
703
+ showNotification(`Reminder: ${event.title} is coming up soon!`, 'bg-yellow-500');
704
+
705
+ // Mark reminder as shown
706
+ event.reminderShown = true;
707
+ saveEvents();
708
+ }
709
+ }
710
+ });
711
+ }
712
+
713
+ // Event Listeners
714
+ prevMonthBtn.addEventListener('click', () => {
715
+ currentMonth--;
716
+ if (currentMonth < 0) {
717
+ currentMonth = 11;
718
+ currentYear--;
719
+ }
720
+ renderCalendar(currentMonth, currentYear);
721
+ });
722
+
723
+ nextMonthBtn.addEventListener('click', () => {
724
+ currentMonth++;
725
+ if (currentMonth > 11) {
726
+ currentMonth = 0;
727
+ currentYear++;
728
+ }
729
+ renderCalendar(currentMonth, currentYear);
730
+ });
731
+
732
+ todayBtn.addEventListener('click', () => {
733
+ currentDate = new Date();
734
+ currentMonth = currentDate.getMonth();
735
+ currentYear = currentDate.getFullYear();
736
+ yearSelect.value = currentYear;
737
+ renderCalendar(currentMonth, currentYear);
738
+ });
739
+
740
+ yearSelect.addEventListener('change', () => {
741
+ currentYear = parseInt(yearSelect.value);
742
+ renderCalendar(currentMonth, currentYear);
743
+ });
744
+
745
+ reminderCheckbox.addEventListener('change', () => {
746
+ if (reminderCheckbox.checked) {
747
+ reminderOptions.classList.remove('hidden');
748
+ } else {
749
+ reminderOptions.classList.add('hidden');
750
+ }
751
+ });
752
+
753
+ eventForm.addEventListener('submit', (e) => {
754
+ e.preventDefault();
755
+
756
+ const title = document.getElementById('event-title').value.trim();
757
+ const date = document.getElementById('event-date').value;
758
+ const startTime = document.getElementById('event-start-time').value;
759
+ const endTime = document.getElementById('event-end-time').value;
760
+ const color = document.getElementById('event-color').value;
761
+ const hasReminder = document.getElementById('event-reminder').checked;
762
+ const reminderTime = hasReminder ? document.getElementById('reminder-time').value : null;
763
+
764
+ if (eventForm.dataset.mode === 'edit') {
765
+ // Update existing event
766
+ const id = eventForm.dataset.id;
767
+ const eventIndex = events.findIndex(event => event.id === id);
768
+
769
+ if (eventIndex !== -1) {
770
+ events[eventIndex] = {
771
+ id,
772
+ title,
773
+ date,
774
+ startTime,
775
+ endTime,
776
+ color,
777
+ reminder: hasReminder,
778
+ reminderTime,
779
+ reminderShown: false
780
+ };
781
+
782
+ saveEvents();
783
+ renderCalendar(currentMonth, currentYear);
784
+ renderUpcomingEvents();
785
+ showNotification('Event updated', 'bg-green-500');
786
+ }
787
+ } else {
788
+ // Add new event
789
+ const newEvent = {
790
+ id: Date.now().toString(),
791
+ title,
792
+ date,
793
+ startTime,
794
+ endTime,
795
+ color,
796
+ reminder: hasReminder,
797
+ reminderTime,
798
+ reminderShown: false
799
+ };
800
+
801
+ events.push(newEvent);
802
+ saveEvents();
803
+ renderCalendar(currentMonth, currentYear);
804
+ renderUpcomingEvents();
805
+ showNotification('Event added', 'bg-green-500');
806
+ }
807
+
808
+ // Reset form
809
+ eventForm.reset();
810
+ setFormDate();
811
+ reminderOptions.classList.add('hidden');
812
+ delete eventForm.dataset.mode;
813
+ delete eventForm.dataset.id;
814
+ eventForm.querySelector('button').innerHTML = '<i class="fas fa-save mr-2"></i> Save Event';
815
+ });
816
+
817
+ // Initialize the calendar
818
+ initCalendar();
819
+ });
820
+ </script>
821
+ <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=seannyboy/calendar-pro" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
822
+ </html>