Skip to content

Commit 473662b

Browse files
committed
spacing
1 parent 8a0da74 commit 473662b

File tree

2 files changed

+60
-60
lines changed

2 files changed

+60
-60
lines changed

.DS_Store

0 Bytes
Binary file not shown.

app.js

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,87 +6,87 @@ const searchBooks = document.forms['search-books'].querySelector('input');
66

77
//delete Function
88
bookList.addEventListener('click', function (e) {
9-
if (e.target.matches('.delete')) {
10-
deleteBooks(e.target);
11-
} else if (e.target.matches('.book-complete')) {
12-
completeRead(e.target);
13-
}
9+
if (e.target.matches('.delete')) {
10+
deleteBooks(e.target);
11+
} else if (e.target.matches('.book-complete')) {
12+
completeRead(e.target);
13+
}
1414
});
1515

1616
searchBooks.addEventListener('keyup', (e) => {
17-
const searchTerm = e.target.value.toLowerCase();
18-
const books = bookList.querySelectorAll('li');
19-
books.forEach((book) => {
20-
const title = book.querySelector('.name').textContent;
21-
if (title.toLowerCase().includes(searchTerm)) {
22-
book.style.display = 'block';
23-
} else {
24-
book.style.display = 'none';
25-
}
26-
});
17+
const searchTerm = e.target.value.toLowerCase();
18+
const books = bookList.querySelectorAll('li');
19+
books.forEach((book) => {
20+
const title = book.querySelector('.name').textContent;
21+
if (title.toLowerCase().includes(searchTerm)) {
22+
book.style.display = 'block';
23+
} else {
24+
book.style.display = 'none';
25+
}
26+
});
2727
});
2828

2929
//hide All books
3030
hideBooks.addEventListener('change', (ev) => {
31-
if (hideBooks.checked) {
32-
bookList.style.display = 'none';
33-
} else {
34-
bookList.style.display = 'initial';
35-
}
31+
if (hideBooks.checked) {
32+
bookList.style.display = 'none';
33+
} else {
34+
bookList.style.display = 'initial';
35+
}
3636
});
3737

3838
//delete books
3939
function deleteBooks(ev) {
40-
const li = ev.parentElement;
41-
bookList.removeChild(li);
40+
const li = ev.parentElement;
41+
bookList.removeChild(li);
4242
}
4343

4444
//complete read books
4545
function completeRead(ev) {
46-
ev.addEventListener('change', () => {
47-
let title = ev.parentElement.querySelector('.name');
48-
if (ev.checked) {
49-
title.style.textDecoration = 'line-through';
50-
title.style.color = 'red';
51-
} else {
52-
title.style.textDecoration = 'initial';
53-
title.style.color = 'initial';
54-
}
55-
});
46+
ev.addEventListener('change', () => {
47+
let title = ev.parentElement.querySelector('.name');
48+
if (ev.checked) {
49+
title.style.textDecoration = 'line-through';
50+
title.style.color = 'red';
51+
} else {
52+
title.style.textDecoration = 'initial';
53+
title.style.color = 'initial';
54+
}
55+
});
5656
}
5757

5858
// add Book Function
5959
bookForm.addEventListener('submit', (e) => {
60-
e.preventDefault();
61-
let text = e.target.title.value;
62-
let newLI = createAndAppendElement('li', bookList, null, null, undefined);
63-
let checkBox = createAndAppendElement('input', newLI, null, 'book-complete', (e) => {
64-
e.setAttribute('type', 'checkbox');
65-
});
66-
createAndAppendElement('label', newLI, null, null, (e) => {
67-
e.htmlFor = checkBox.className;
68-
});
69-
createAndAppendElement('span', newLI, null, 'name', (e) => {
70-
e.textContent = text;
71-
});
72-
createAndAppendElement('span', newLI, null, 'delete', (e) => {
73-
e.textContent = 'delete';
74-
});
75-
e.target.title.value = '';
60+
e.preventDefault();
61+
let text = e.target.title.value;
62+
let newLI = createAndAppendElement('li', bookList, null, null, undefined);
63+
let checkBox = createAndAppendElement('input', newLI, null, 'book-complete', (e) => {
64+
e.setAttribute('type', 'checkbox');
65+
});
66+
createAndAppendElement('label', newLI, null, null, (e) => {
67+
e.htmlFor = checkBox.className;
68+
});
69+
createAndAppendElement('span', newLI, null, 'name', (e) => {
70+
e.textContent = text;
71+
});
72+
createAndAppendElement('span', newLI, null, 'delete', (e) => {
73+
e.textContent = 'delete';
74+
});
75+
e.target.title.value = '';
7676
});
7777

7878
//helper append function to doc
7979
function createAndAppendElement(tag, parent, id, className, callback) {
80-
const element = document.createElement(tag);
81-
parent.append(element);
82-
if (id !== null) {
83-
element.id = id;
84-
}
85-
if (className !== null) {
86-
element.className = className;
87-
}
88-
if (callback !== undefined) {
89-
callback(element);
90-
}
91-
return element;
80+
const element = document.createElement(tag);
81+
parent.append(element);
82+
if (id !== null) {
83+
element.id = id;
84+
}
85+
if (className !== null) {
86+
element.className = className;
87+
}
88+
if (callback !== undefined) {
89+
callback(element);
90+
}
91+
return element;
9292
}

0 commit comments

Comments
 (0)