From 94c9989bf589fcf6de44763e1f40d509fff152b6 Mon Sep 17 00:00:00 2001 From: btwatts0 Date: Mon, 23 Mar 2026 08:29:35 -0700 Subject: [PATCH] improves readability of html, resolves #54 --- campusResource.html | 378 +++++++++++++++++++++++--------------------- 1 file changed, 195 insertions(+), 183 deletions(-) diff --git a/campusResource.html b/campusResource.html index b2efdf8..33d21d7 100644 --- a/campusResource.html +++ b/campusResource.html @@ -1,192 +1,204 @@ - - - Resource Form - - - - - + + + Resource Form + + + + + + + +
-
- - - - - + + // Closes form upon clicking outside of box + window.onclick = function(event) { + const modal = document.getElementById("formModal"); + if (event.target === modal) { + modal.style.display = "none"; + } + } + + // When form is submitted, stores the results to HTML text in a ResourceDiv, which is then added to the resource list + document.getElementById("resourceForm").addEventListener("submit", function(e) { + e.preventDefault(); // Stop page refresh + + const name = this.resourceName.value; + const location = this.location.value; + const description = this.description.value; + const availability = this.availability.value; + + const resourceList = document.getElementById("resourceList"); + const resourceDiv = document.createElement("div"); + resourceDiv.className = "resourceItem"; + + resourceDiv.innerHTML = ` + ${name}
+ ${location}
+ ${description}
+ Status: ${availability} +
+ `; + + resourceList.appendChild(resourceDiv); + + this.reset(); + closeForm(); + }); + + + + \ No newline at end of file