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 --- assignment.js | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 assignment.js (limited to 'assignment.js') diff --git a/assignment.js b/assignment.js new file mode 100644 index 0000000..7d8a7a5 --- /dev/null +++ b/assignment.js @@ -0,0 +1,82 @@ +function addMetadata() { + // Favicon + const favicon = document.createElement("link"); + favicon.rel = "icon"; + favicon.href = "../Logo.svg"; + favicon.type = "image/svg+xml"; + document.head.appendChild(favicon); + + // UTF-8 charset + const charset = document.createElement("meta"); + charset.setAttribute("charset", "UTF-8"); + document.head.appendChild(charset); + + // Viewport for mobile + const viewport = document.createElement("meta"); + viewport.setAttribute("name", "viewport"); + viewport.setAttribute("content", "width=device-width, initial-scale=1.0"); + document.head.appendChild(viewport); + + // Primary stylesheet + const css = document.createElement("link"); + css.rel = "stylesheet"; + css.href = "../style.css"; + document.head.appendChild(css); +} + +function addHeader() { + const header = document.querySelector("header"); + if (!header) return; + + // Back Link + const backLink = document.createElement("a"); + backLink.href = "../index.html"; + backLink.classList.add("header-logo-link"); + backLink.textContent = "<- Back to Index"; + header.appendChild(backLink); + + // Right-side info container + const info = document.createElement("div"); + info.classList.add("header-info"); + + // Title from document.title + const h1 = document.createElement("h1"); + h1.textContent = document.title; + info.appendChild(h1); + + // Read date from + const metaDate = document.querySelector('meta[property="article:published_time"]'); + if (metaDate) { + const dateString = metaDate.getAttribute("content"); + const displayDate = (new Date(dateString)).toLocaleDateString("en-US", { + month: "short", + day: "numeric", + year: "numeric", + timeZone: "UTC" + }); + + const time = document.createElement("time"); + time.setAttribute("datetime", dateString); + time.textContent = `Updated ${displayDate}`; + info.appendChild(time); + } + + // Read class tag from + const metaClass = document.querySelector('meta[name="class"]'); + if (metaClass) { + const classTag = document.createElement("span"); + classTag.classList.add("class-tag"); + classTag.textContent = `Class: ${metaClass.getAttribute("content")}`; + info.appendChild(classTag); + } + + header.appendChild(info); + + const hr = document.createElement("hr"); + header.appendChild(hr); +} + +document.addEventListener("DOMContentLoaded", () => { + addMetadata(); + addHeader(); +}); -- cgit v1.3.1