-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
46 lines (39 loc) · 1.17 KB
/
index.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
40
41
42
43
44
45
46
import
BookManagement
from './modules/bookmanagement.js';
import
addNew
from './modules/addNew.js';
import
removeBooks
from './modules/removeBooks.js';
import {
showListSection,
showAddNew,
showContact,
} from './modules/navigation.js';
import {
DateTime,
} from './modules/luxon.js';
const addForm = document.querySelector('form');
const navListBtn = document.querySelector('#nav-list');
const navAddNewBtn = document.querySelector('#nav-add-new');
const navContactBtn = document.querySelector('#nav-contact');
if (!JSON.parse(localStorage.getItem('books'))) {
localStorage.setItem('books', JSON.stringify([]));
}
// Show the books on localStorage
BookManagement.display();
// Add a book
addForm.addEventListener('submit', addNew);
// Dynamic remove buttons
const deleteButtons = document.querySelectorAll('.delete-button');
deleteButtons.forEach(removeBooks);
// Time
const time = document.querySelector('#time');
const dt = DateTime.now();
time.innerHTML = dt.toLocaleString(DateTime.DATETIME_MED);
// Navigation
navListBtn.addEventListener('click', showListSection);
navAddNewBtn.addEventListener('click', showAddNew);
navContactBtn.addEventListener('click', showContact);