-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 1.26 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
/* eslint-disable max-classes-per-file */
/* eslint-disable import/no-unresolved */
import { Book } from './modules/book.js';
import { Store } from './modules/store.js';
import { showBooks } from './modules/showBook.js';
import {
showAdd, showAddBook, showBookList, showList, showContact, showContactPage,
} from './modules/onClick.js';
import { current } from './modules/date.js';
document.addEventListener('DOMContentLoaded', showBooks.displayBooks);
document.getElementById('date').innerHTML = current;
window.addEventListener('load', () => {
showList();
});
showBookList.addEventListener('click', () => {
showList();
});
showAddBook.addEventListener('click', () => {
showAdd();
});
showContact.addEventListener('click', () => {
showContactPage();
});
document.querySelector('#form').addEventListener('submit', (e) => {
e.preventDefault();
const title = document.querySelector('#title').value;
const author = document.querySelector('#author').value;
const book = new Book(title, author);
showBooks.addBookToList(book);
Store.addBook(book);
showBooks.clearFields();
});
document.querySelector('#list').addEventListener('click', (e) => {
showBooks.deleteBook(e.target);
Store.removeBook(e.target.parentElement.previousElementSibling.textContent);
});