Skip to content

Commit 6a9c9d2

Browse files
committed
16 video
1 parent 66713de commit 6a9c9d2

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

app.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,29 @@ li.appendChild(bookName);
3232
li.appendChild(deleteBtn)
3333
list.appendChild(li);
3434

35-
3635
});
36+
37+
//hide books
38+
const hideBox = document.querySelector('#hide');
39+
hideBox.addEventListener('change', function(e){
40+
if(hideBox.checked){
41+
list.style.display = 'none';
42+
} else {
43+
list.style.display = 'initial';
44+
}
45+
})
46+
47+
//filter books
48+
const searchBar = document.forms['search-books'].querySelector('input');
49+
searchBar.addEventListener('keyup', function(e){
50+
const term = e.target.value.toLowerCase();
51+
const books = list.getElementsByTagName('li');
52+
Array.from(books).forEach(function(book){
53+
const title = book.firstElementChild.textContent;
54+
if(title.toLowerCase().indexOf(term) != -1){
55+
book.style.display = 'block';
56+
} else {
57+
book.style.display = 'none';
58+
}
59+
});
60+
});

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<div id="page-banner">
1212
<h1 class="title">Bookorama</h1>
1313
<p>Books for Ninjas</p>
14-
<a href='http://www.thenetninja.co.uk'>the net ninja</a>
1514
<form id="search-books">
1615
<input type="text" placeholder="Search books..." />
1716
</form>
@@ -39,6 +38,8 @@ <h2 class="title">Books to Read</h2>
3938
</ul>
4039
</div>
4140
<form id="add-book">
41+
<input type='checkbox' id='hide'/>
42+
<label for='hide'>Hide all books</label>
4243
<input type="text" placeholder="Add a book..." />
4344
<button>Add</button>
4445
</form>

styles.css

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,15 @@ h1, h2{
115115
clear: both;
116116
}
117117

118-
/*
119-
#tabbed-content li{
120-
display: inline-block;
121-
padding: 10px 14px;
122-
background: #ddd;
123-
border-radius: 4px;
124-
cursor: pointer;
125-
margin-right: 10px;
118+
#add-book #hide{
119+
width: 30px;
126120
}
127121

122+
#add-book label{
123+
line-height: 52px;
124+
}
125+
126+
/*
128127
#tabbed-content .tab{
129128
display: none;
130129
border: 1px solid #ddd;

0 commit comments

Comments
 (0)