summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-09-01 12:14:24 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2026-09-01 12:14:24 -0500
commitb21858860496fbe0229278ded54a840ad15fddb2 (patch)
treefbab086d6a1b8fea5f745b3990f9e1f31d6f6472 /app.js
all of the things
Diffstat (limited to 'app.js')
-rw-r--r--app.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/app.js b/app.js
new file mode 100644
index 0000000..9349824
--- /dev/null
+++ b/app.js
@@ -0,0 +1,78 @@
+async function loadAtomFeed() {
+ const container = document.getElementById('feed-container');
+
+ try {
+ const response = await fetch('feed.xml');
+ if (!response.ok) throw new Error('Failed to load feed');
+
+ const xmlText = await response.text();
+ const parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(xmlText, 'text/xml');
+
+ const entries = Array.from(xmlDoc.querySelectorAll('entry'));
+ container.innerHTML = '';
+
+ if (entries.length === 0) {
+ container.innerHTML = '<p>No assignments found.</p>';
+ return;
+ }
+
+ // Group entries by class category
+ const groupedByClass = {};
+
+ entries.forEach(entry => {
+ const title = entry.querySelector('title')?.textContent || 'Untitled';
+ const updated = entry.querySelector('updated')?.textContent || '';
+
+ const linkEl = entry.querySelector('link');
+ const link = linkEl ? linkEl.getAttribute('href') : '#';
+
+ // Grab category term or fallback to "General"
+ const categoryEl = entry.querySelector('category');
+ const className = categoryEl ? categoryEl.getAttribute('term') : 'General';
+
+ const itemData = {
+ title,
+ link,
+ updated: updated ? new Date(updated).toLocaleDateString() : ''
+ };
+
+ if (!groupedByClass[className]) {
+ groupedByClass[className] = [];
+ }
+ groupedByClass[className].push(itemData);
+ });
+
+ // Render grouped entries
+ Object.keys(groupedByClass).sort().forEach(className => {
+ const groupSection = document.createElement('section');
+ groupSection.className = 'class-group';
+
+ const classHeader = document.createElement('h2');
+ classHeader.className = 'class-title';
+ classHeader.textContent = className;
+ groupSection.appendChild(classHeader);
+
+ const ul = document.createElement('ul');
+ ul.className = 'feed-list';
+
+ groupedByClass[className].forEach(item => {
+ const li = document.createElement('li');
+ li.className = 'feed-item';
+ li.innerHTML = `
+ <h3><a href="${item.link}">${item.title}</a></h3>
+ ${item.updated ? `<div class="meta">Updated: ${item.updated}</div>` : ''}
+ `;
+ ul.appendChild(li);
+ });
+
+ groupSection.appendChild(ul);
+ container.appendChild(groupSection);
+ });
+
+ } catch (error) {
+ container.innerHTML = `<p>Error loading entries: ${error.message}</p>`;
+ }
+}
+
+loadAtomFeed();