From 705735053a3d91ef28084d63e7549659ac5521d7 Mon Sep 17 00:00:00 2001 From: Helen Chong <119173961+helenclx@users.noreply.github.com> Date: Thu, 9 Nov 2023 20:17:29 +0800 Subject: [PATCH] Clean up code --- js/main-components.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/js/main-components.js b/js/main-components.js index 3833b11b..5d6a107a 100644 --- a/js/main-components.js +++ b/js/main-components.js @@ -19,20 +19,18 @@ function loadHeader() { }; } -document.addEventListener('DOMContentLoaded', () => { - const todayEvent = getTodayEvent(); - const headerTopBarEl = document.querySelector(".main-header__top-bar"); - const headerImgEl = document.querySelector(".main-header__img"); +const todayEvent = getTodayEvent(); +const headerTopBarEl = document.querySelector(".main-header__top-bar"); +const headerImgEl = document.querySelector(".main-header__img"); - if (todayEvent != "No event") { - if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") { - headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); - } else { - headerImgEl.classList.add(getBanner(todayEvent)); - headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); - } - }; -}); +if (todayEvent != "No event") { + if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") { + headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); + } else { + headerImgEl.classList.add(getBanner(todayEvent)); + headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); + } +}; function getTodayEvent() { const date = new Date(); @@ -192,7 +190,6 @@ function getBlurbHtml(day) { } - /* ------ MAIN NAVIGATION BAR COMPONENT ------ */ document.querySelector(".navbar").innerHTML = `