-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (43 loc) · 1.33 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
import Books from './modules/books.js';
import handleTiming from './modules/dateTime.js';
const booksContainer = document.querySelector('.book-container');
const form = document.querySelector('form');
const list = document.querySelector('#book-list');
const addNew = document.querySelector('#add-books');
const contact = document.querySelector('#contact');
const bookList = document.querySelector('#listbook');
const addBook = document.querySelector('#addbook');
const contacts = document.querySelector('#contacts');
bookList.addEventListener('click', (e) => {
e.preventDefault();
list.style.display = 'flex';
addNew.style.display = 'none';
contact.style.display = 'none';
});
addBook.addEventListener('click', () => {
list.style.display = 'none';
addNew.style.display = 'flex';
contact.style.display = 'none';
});
contacts.addEventListener('click', () => {
list.style.display = 'none';
addNew.style.display = 'none';
contact.style.display = 'flex';
});
// date
window.addEventListener('load', () => {
handleTiming();
});
// show books on the UI
const book = new Books();
book.showBooks();
// Add book ,update UI and localStorage
form.addEventListener('submit', (e) => {
e.preventDefault();
book.updateBooks();
form.reset();
});
// Remove the Book
booksContainer.addEventListener('click', (e) => {
book.removeBook(e);
});