// nav bar scroll effect const scrollLimit = 150; window.onscroll = () => { // check if scrolled past limit if so add scrolled class to change background of nav if (document.body.scrollTop >= scrollLimit || document.documentElement.scrollTop >= scrollLimit) { document.querySelector("nav").classList.add("scrolled"); } else { document.querySelector("nav").classList.remove("scrolled"); } }; document.querySelector("#goBackToTop").addEventListener("click", () => { window.scrollTo(0, 0); }); /** * getProjectData function * Gets the project data from the backend route and appends the data on to the timeline. */ function getProjectData() { fetch("/api/projectData").then(res => { res.json().then(json => { if (res.ok) { json.forEach(item => { if (item["isMainProject"] === 1) { document.querySelector("#mainProj").innerHTML = `

${item["title"]}

${item["information"]}

`; return null; } document.querySelector("#otherProj").innerHTML += `

${item["title"]}

${item["information"]}

View Project ${(item["githubLink"] === "N/A") ? "disabled=\"disabled\"" : ""}Git
`; }) } }) }) } document.addEventListener('DOMContentLoaded', () => { // get projectData getProjectData(); // update the year in the footer document.getElementById("year").innerHTML = new Date().getFullYear().toString(); });