From b21858860496fbe0229278ded54a840ad15fddb2 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Tue, 1 Sep 2026 12:14:24 -0500 Subject: all of the things --- app.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 app.js (limited to 'app.js') 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 = '
No assignments found.
'; + 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 = ` +Error loading entries: ${error.message}
`; + } +} + +loadAtomFeed(); -- cgit v1.3.1