Clean up code

This commit is contained in:
Helen Chong 2023-11-09 20:17:29 +08:00
parent efaf42d064
commit 705735053a
1 changed files with 11 additions and 14 deletions

View File

@ -19,20 +19,18 @@ function loadHeader() {
}; };
} }
document.addEventListener('DOMContentLoaded', () => { const todayEvent = getTodayEvent();
const todayEvent = getTodayEvent(); const headerTopBarEl = document.querySelector(".main-header__top-bar");
const headerTopBarEl = document.querySelector(".main-header__top-bar"); const headerImgEl = document.querySelector(".main-header__img");
const headerImgEl = document.querySelector(".main-header__img");
if (todayEvent != "No event") { if (todayEvent != "No event") {
if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") { if (todayEvent == "Leilukin's Birthday" || todayEvent == "Leilukin's Hub Anniversary") {
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
} else { } else {
headerImgEl.classList.add(getBanner(todayEvent)); headerImgEl.classList.add(getBanner(todayEvent));
headerTopBarEl.innerHTML = getBlurbHtml(todayEvent); headerTopBarEl.innerHTML = getBlurbHtml(todayEvent);
} }
}; };
});
function getTodayEvent() { function getTodayEvent() {
const date = new Date(); const date = new Date();
@ -192,7 +190,6 @@ function getBlurbHtml(day) {
} }
/* ------ MAIN NAVIGATION BAR COMPONENT ------ */ /* ------ MAIN NAVIGATION BAR COMPONENT ------ */
document.querySelector(".navbar").innerHTML = ` document.querySelector(".navbar").innerHTML = `
<ul class="nav__menu"> <ul class="nav__menu">