LauraMDB commited on
Commit
f08b1c1
·
verified ·
1 Parent(s): 83f2715

change the course calendar to include dates

Browse files
Files changed (3) hide show
  1. index.html +8 -0
  2. script.js +41 -1
  3. style.css +32 -0
index.html CHANGED
@@ -212,6 +212,14 @@
212
  </div>
213
  <div id="calendar-days" class="grid grid-cols-7 gap-px bg-gray-200"></div>
214
  </div>
 
 
 
 
 
 
 
 
215
  </section>
216
  <!-- Upcoming Courses Section -->
217
  <section id="upcoming-courses" class="mb-20">
 
212
  </div>
213
  <div id="calendar-days" class="grid grid-cols-7 gap-px bg-gray-200"></div>
214
  </div>
215
+
216
+ <!-- Upcoming Dates Section -->
217
+ <div class="mt-8 bg-white rounded-lg shadow p-6">
218
+ <h3 class="text-xl font-semibold text-gray-800 mb-4">Upcoming Course Dates</h3>
219
+ <div class="space-y-4" id="upcoming-dates-list">
220
+ <!-- Dates will be populated by JavaScript -->
221
+ </div>
222
+ </div>
223
  </section>
224
  <!-- Upcoming Courses Section -->
225
  <section id="upcoming-courses" class="mb-20">
script.js CHANGED
@@ -266,6 +266,7 @@ document.addEventListener('DOMContentLoaded', () => {
266
  currentYear = now.getFullYear();
267
 
268
  renderCalendar();
 
269
  // Month navigation
270
  document.getElementById('prev-month').addEventListener('click', () => {
271
  currentMonth--;
@@ -357,6 +358,46 @@ function renderCourses(courses, containerId) {
357
  container.appendChild(card);
358
  });
359
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  // Initialize the page
361
  function init() {
362
  const groupedCourses = groupCoursesByMonth(coursesData);
@@ -375,5 +416,4 @@ function init() {
375
  buttons[1].textContent = monthNames[(now.getMonth() + 1) % 12];
376
  buttons[2].textContent = monthNames[(now.getMonth() + 2) % 12];
377
  }
378
-
379
  init();
 
266
  currentYear = now.getFullYear();
267
 
268
  renderCalendar();
269
+ renderUpcomingDates();
270
  // Month navigation
271
  document.getElementById('prev-month').addEventListener('click', () => {
272
  currentMonth--;
 
358
  container.appendChild(card);
359
  });
360
  }
361
+ // Render upcoming dates list
362
+ function renderUpcomingDates() {
363
+ const upcomingDatesList = document.getElementById('upcoming-dates-list');
364
+ upcomingDatesList.innerHTML = '';
365
+
366
+ // Sort courses by date
367
+ const sortedCourses = [...coursesData].sort((a, b) => {
368
+ return new Date(a['Start Date']) - new Date(b['Start Date']);
369
+ });
370
+
371
+ // Get next 10 upcoming courses
372
+ const now = new Date();
373
+ const upcomingCourses = sortedCourses.filter(course => {
374
+ return new Date(course['Start Date']) >= now;
375
+ }).slice(0, 10);
376
+
377
+ if (upcomingCourses.length === 0) {
378
+ upcomingDatesList.innerHTML = '<p class="text-gray-600">No upcoming courses scheduled.</p>';
379
+ return;
380
+ }
381
+
382
+ upcomingCourses.forEach(course => {
383
+ const date = new Date(course['Start Date']);
384
+ const dateItem = document.createElement('div');
385
+ dateItem.className = 'flex items-start border-b border-gray-100 pb-4 last:border-0 last:pb-0';
386
+ dateItem.innerHTML = `
387
+ <div class="bg-green-100 rounded-lg p-2 mr-4 flex-shrink-0">
388
+ <div class="text-green-800 font-bold text-center text-sm">${date.toLocaleDateString('en-US', { month: 'short' })}</div>
389
+ <div class="text-green-800 font-bold text-center text-xl">${date.getDate()}</div>
390
+ </div>
391
+ <div>
392
+ <h4 class="font-medium text-gray-800">${course.Course}</h4>
393
+ <p class="text-sm text-gray-600">${course.Time} • ${course.Location}</p>
394
+ <p class="text-sm text-gray-500 mt-1">Instructor: ${course.Instructor}</p>
395
+ </div>
396
+ `;
397
+ upcomingDatesList.appendChild(dateItem);
398
+ });
399
+ }
400
+
401
  // Initialize the page
402
  function init() {
403
  const groupedCourses = groupCoursesByMonth(coursesData);
 
416
  buttons[1].textContent = monthNames[(now.getMonth() + 1) % 12];
417
  buttons[2].textContent = monthNames[(now.getMonth() + 2) % 12];
418
  }
 
419
  init();
style.css CHANGED
@@ -12,6 +12,7 @@ body {
12
  /* Calendar styling */
13
  #calendar-days > div {
14
  min-height: 6rem;
 
15
  }
16
 
17
  #calendar-days > div:hover {
@@ -21,11 +22,42 @@ body {
21
  .calendar-course {
22
  cursor: pointer;
23
  transition: all 0.2s;
 
 
 
 
 
 
 
24
  }
25
 
26
  .calendar-course:hover {
27
  background-color: #dbeafe;
28
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  /* Animation for course cards */
30
  @keyframes fadeIn {
31
  from { opacity: 0; transform: translateY(20px); }
 
12
  /* Calendar styling */
13
  #calendar-days > div {
14
  min-height: 6rem;
15
+ position: relative;
16
  }
17
 
18
  #calendar-days > div:hover {
 
22
  .calendar-course {
23
  cursor: pointer;
24
  transition: all 0.2s;
25
+ padding: 2px 4px;
26
+ margin-bottom: 2px;
27
+ border-radius: 3px;
28
+ font-size: 0.75rem;
29
+ white-space: nowrap;
30
+ overflow: hidden;
31
+ text-overflow: ellipsis;
32
  }
33
 
34
  .calendar-course:hover {
35
  background-color: #dbeafe;
36
  }
37
+
38
+ /* Upcoming dates styling */
39
+ #upcoming-dates-list {
40
+ max-height: 500px;
41
+ overflow-y: auto;
42
+ }
43
+
44
+ #upcoming-dates-list::-webkit-scrollbar {
45
+ width: 6px;
46
+ }
47
+
48
+ #upcoming-dates-list::-webkit-scrollbar-track {
49
+ background: #f1f1f1;
50
+ border-radius: 10px;
51
+ }
52
+
53
+ #upcoming-dates-list::-webkit-scrollbar-thumb {
54
+ background: #cbd5e0;
55
+ border-radius: 10px;
56
+ }
57
+
58
+ #upcoming-dates-list::-webkit-scrollbar-thumb:hover {
59
+ background: #a0aec0;
60
+ }
61
  /* Animation for course cards */
62
  @keyframes fadeIn {
63
  from { opacity: 0; transform: translateY(20px); }