generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (47 loc) · 1.59 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 Display from './modules/functions.js';
import { DateTime } from './modules/luxon.js';
const booksList = document.querySelector('.books-list');
const addBooks = document.querySelector('.add-book');
const contactInfo = document.querySelector('.contact-info');
const books = document.querySelector('.books');
const forms = document.querySelector('.form');
const contact = document.querySelector('.contact');
const tag = document.querySelector('h1');
const showCurrentTime = document.querySelector('.current-time');
books.style.display = 'none';
forms.style.display = 'block';
contact.style.display = 'none';
tag.style.display = 'none';
booksList.addEventListener('click', () => {
forms.style.display = 'none';
contact.style.display = 'none';
books.style.display = 'block';
tag.style.display = 'block';
});
addBooks.addEventListener('click', () => {
forms.style.display = 'block';
books.style.display = 'none';
contact.style.display = 'none';
tag.style.display = 'none';
});
contactInfo.addEventListener('click', () => {
forms.style.display = 'none';
books.style.display = 'none';
tag.style.display = 'none';
contact.style.display = 'block';
});
window.addEventListener('DOMContentLoaded', () => {
Display.displayBooks();
});
const form = document.querySelector('.form');
form.addEventListener('submit', (evt) => {
evt.preventDefault();
Display.addBook();
form.reset();
});
const showDateTime = () => {
const time = DateTime.now();
const curTime = time.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS);
showCurrentTime.textContent = curTime;
};
setInterval(showDateTime, 1000);