-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
39 lines (34 loc) · 1.06 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import Book from './modules/book.js';
import { DateTime } from './modules/luxon.js';
const displayDate = () => {
const date = document.getElementById('date');
date.innerHTML = DateTime.now();
};
displayDate();
window.onload = () => {
Book.updateDisplay();
Book.addBook();
const links = document.querySelectorAll('.nav-link');
links.forEach((link) => {
link.addEventListener('click', (e) => {
const sectionId = link.getAttribute('href');
const section = document.querySelector(sectionId);
document.querySelectorAll('section').forEach((s) => {
if (s !== section) {
s.style.display = 'none';
}
});
section.style.display = 'block';
e.preventDefault();
});
});
const activeNavItem = document.querySelector('.nav-link.active');
const sectionId = activeNavItem.getAttribute('href');
const section = document.querySelector(sectionId);
document.querySelectorAll('section').forEach((s) => {
if (s !== section) {
s.style.display = 'none';
}
});
section.style.display = 'block';
};