-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c16565f
commit 5bb5794
Showing
7 changed files
with
88 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
--- | ||
title: Week 16 Announcements | ||
week: 16 | ||
date: 202-12-09 | ||
date: 2024-12-09 | ||
--- | ||
|
||
1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ | |
</div> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
<div class="announcement"> | ||
<h2>{{ page.title }}</h2> | ||
<h2>{{ include.announcement.title }}</h2> | ||
<span class="announcement-meta"> | ||
{% if page.date %} | ||
{{ page.date | date: '%b %e' }} | ||
· | ||
{% endif %} | ||
{% assign minutes = content | strip_html | number_of_words | divided_by: 180.0 | round %} | ||
{{ minutes }} min read | ||
{{ include.announcement.date | date: '%b %e' }} | ||
<!-- · --> | ||
<!-- {{ include.announcement.content | strip_html | number_of_words | divided_by: 180.0 | round }} min read --> | ||
</span> | ||
<div> | ||
{{ content }} | ||
{{ include.announcement.content }} | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const prevButton = document.getElementById('prev-week'); | ||
const nextButton = document.getElementById('next-week'); | ||
const announcements = document.querySelectorAll('.announcement[data-week]'); | ||
|
||
function getValidWeeks() { | ||
const validAnnouncements = Array.from(announcements).filter(a => { | ||
const announcementDate = new Date(a.dataset.date); | ||
return announcementDate <= new Date(); // Only past or present announcements | ||
}); | ||
|
||
return validAnnouncements.map(a => parseInt(a.dataset.week)).sort((a, b) => a - b); | ||
} | ||
|
||
function showAnnouncement(week) { | ||
announcements.forEach(announcement => { | ||
const announcementWeek = parseInt(announcement.dataset.week); | ||
if (announcementWeek === week) { | ||
announcement.style.display = 'block'; | ||
} else { | ||
announcement.style.display = 'none'; | ||
} | ||
}); | ||
|
||
const validWeeks = getValidWeeks(); | ||
const maxWeek = Math.max(...validWeeks); | ||
const minWeek = Math.min(...validWeeks); | ||
|
||
prevButton.dataset.week = week - 1; | ||
nextButton.dataset.week = week + 1; | ||
|
||
prevButton.style.visibility = week > minWeek ? 'visible' : 'hidden'; | ||
nextButton.style.visibility = week < maxWeek ? 'visible' : 'hidden'; | ||
} | ||
|
||
// Initial load | ||
const validWeeks = getValidWeeks(); | ||
const initialWeek = validWeeks[validWeeks.length - 1]; // Most recent valid week | ||
showAnnouncement(initialWeek); | ||
|
||
prevButton.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
const week = parseInt(prevButton.dataset.week); | ||
if (week >= Math.min(...getValidWeeks())) { | ||
showAnnouncement(week); | ||
} | ||
}); | ||
|
||
nextButton.addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
const week = parseInt(nextButton.dataset.week); | ||
if (week <= Math.max(...getValidWeeks())) { | ||
showAnnouncement(week); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters