Skip to content

Commit

Permalink
add js functionality to show/hide text blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwittler committed Jul 7, 2023
1 parent faac4db commit 3eba2f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions public/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,26 @@ document.addEventListener('DOMContentLoaded', () => {
'minutes': minutesRounded
};
}

function showAndHideWords() {
const now = getCurrentTime();

document.querySelectorAll('li[data-hours], li[data-minutes]').forEach((element) => {
element.classList.remove('active');
});

const hoursToActivate = document.querySelectorAll(`li[data-hours~='${now.hours}']`);
const minutesToActivate = document.querySelectorAll(`li[data-minutes~='${now.minutes}']`);

hoursToActivate.forEach((element) => {
element.classList.add('active');
});

minutesToActivate.forEach((element) => {
element.classList.add('active');
});
}

showAndHideWords();
setInterval(showAndHideWords, 1000);
});

0 comments on commit 3eba2f6

Please sign in to comment.