Skip to content

Commit

Permalink
fix: ultra-clear main content
Browse files Browse the repository at this point in the history
  • Loading branch information
zyriab committed Dec 23, 2023
1 parent 9eb5116 commit 452301f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions js/tui.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,15 @@ function closeHamburgerMenu() {
LEFT_SECTION.classList.remove('menu-open');
}

async function displayContent() {
function clearMainContent() {
MAIN_CONTENT_SECTION.innerHTML = '';
MAIN_CONTENT_SECTION.scrollTo({ top: 0 });
}

const sectionName = left_sections[currentPosition.sectionIndex].name;
async function displayContent() {
clearMainContent();

const sectionName = left_sections[currentPosition.sectionIndex].name;

const response = await fetch(`data/${sectionName}.json`)
const { data } = await response.json();
Expand Down Expand Up @@ -324,6 +327,8 @@ async function displayContent() {

innerContainerElement.prepend(topElement);
outerContainerElement.appendChild(innerContainerElement);

clearMainContent()
MAIN_CONTENT_SECTION.appendChild(outerContainerElement);

colorizeCode();
Expand All @@ -339,6 +344,8 @@ async function displayContent() {
logoElement.alt = 'Wallenart'

logoContainer.appendChild(logoElement);

clearMainContent()
MAIN_CONTENT_SECTION.appendChild(logoContainer);

data.forEach((d) => {
Expand All @@ -354,6 +361,8 @@ async function displayContent() {
})

outerContainerElement.appendChild(innerContainerElement);

clearMainContent()
MAIN_CONTENT_SECTION.appendChild(outerContainerElement);

await displayRandomBibleVerse(innerContainerElement);
Expand Down

0 comments on commit 452301f

Please sign in to comment.