generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (44 loc) · 1.75 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
47
48
49
50
51
52
53
54
55
import navigateAddNew from './modules/navigateAddNew.js';
import navigateList from './modules/navigateList.js';
import navigateContact from './modules/navigateContact.js';
import addBook from './modules/addBook.js';
import removeBook from './modules/removeBook.js';
import loadFromStorage from './modules/loadFromStorage.js';
import updateStorage from './modules/updateStorage.js';
const list = document.getElementById('list-link');
const addNew = document.getElementById('add-new-link');
const contact = document.getElementById('contact-link');
const sectionList = document.getElementsByClassName('list')[0];
const sectionAddBook = document.getElementsByClassName('add-book')[0];
const sectionContact = document.getElementsByClassName('contact')[0];
// Navigation links on-click event listeners
list.onclick = () => {
navigateList(list, sectionList, addNew, sectionAddBook, contact, sectionContact);
};
addNew.onclick = () => {
navigateAddNew(list, sectionList, addNew, sectionAddBook, contact, sectionContact);
};
contact.onclick = () => {
navigateContact(list, sectionList, addNew, sectionAddBook, contact, sectionContact);
};
// Functions area
window.onclick = (event) => {
if (event.target.className === 'add-button') {
addBook();
} else if (event.target.className === 'remove-button') {
removeBook(event);
}
};
window.onload = () => {
let bookList = window.localStorage.getItem('bookList');
if ((bookList === null) || (bookList === undefined)) {
bookList = [];
updateStorage(bookList);
} else {
loadFromStorage();
}
};
// export default date;
const datePlaceholder = document.getElementById('date');
// eslint-disable-next-line no-undef
datePlaceholder.innerHTML = luxon.DateTime.local().toLocaleString(luxon.DateTime.DATETIME_FULL);