Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# DAVID IL BOIT DU SPRITE SA MERE!!


# js-basic-list


Expand Down
58 changes: 58 additions & 0 deletions main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
*{
margin: 0;
padding: 0;

}

body{
font-family: futura;
}

.container{
width: 100vw;
/*height: 100vh;*/
display: flex;
align-items: center;
justify-content: space-around;
flex-direction: column;
}
.booksList{
list-style: none;
font-family: futura;
}
ul {
list-style: none;
}
.checkbox{
display: flex;
flex-direction: column;
margin-bottom: 30px;
}
.main{
border: 1px solid black;
padding: 10px 5px;
width: 417px;
}
.title{
font-size: 20px;
font-weight: bold;
}
.author{
font-size: 14px;
font-weight: 100;
}
.type{
font-size: 15px;
font-style: italic;
}
.nothing{
display: none;
}
button{
border: none;
border-radius: 5px;
background-color: rgb(224, 130, 140);
color: white;
width: 100px;
height: 30px;
}
27 changes: 27 additions & 0 deletions main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="master.css">
</head>
<body>

<div class="container">
<div class="checkbox">
<div class="">
<label for="JS">Javascript</label><input class="js" type="checkbox" checked name="JS" value="JS">
</div>
<div class="">
<label for="CSS">CSS</label><input class="css" type="checkbox" checked name="CSS" value="CSS">
</div>
<button type="button" name="button" class="filterbtn">Filtrer</button>
</div>
<ul class="booksList">
<ul class="main nothing"><li>Désolé mais votre recherche n'a rien donné...</li></ul>
</ul>
</div>

<script src="main.js"></script>
</body>
</html>
73 changes: 73 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
var books = [
{
title: 'CSS: The Definitive Guide',
author: 'Eric Meyer',
link: 'http://shop.oreilly.com/product/0636920012726.do',
type: 'css'
},
{
title: 'CSS Development with CSS3',
author: 'Zachary Kingston',
link: 'http://shop.oreilly.com/product/0636920057970.do',
type: 'css'
},
{
title: 'You Don\'t Know JS: Up & Going',
author: 'Kyle Simpson',
link: 'http://shop.oreilly.com/product/0636920039303.do',
type: 'js'
},
{
title: 'Programming JavaScript Applications',
author: 'Eric Elliott',
link: 'http://shop.oreilly.com/product/0636920033141.do',
type: 'js'
},
{
title: 'Modern JavaScript',
author: 'unknown',
link: 'http://www.oreilly.com/web-platform/free/modern-javascript.csp',
type: 'js'
}
];

var booksList = document.querySelector('.booksList');
for (var i = 0; i < books.length; i++) {
booksList.innerHTML = booksList.innerHTML + '<ul class="main '+ books[i].type +'-type"><li class="title">'+ books[i].title +'</li><li class="author">'+ books[i].author +'</li><li class="type">'+books[i].type+'</li><a href="'+books[i].link+'"><button>En savoir plus</button></a></ul>';
}
var js = document.querySelector('.js'), css = document.querySelector('.css');
var filterbtn = document.querySelector('.filterbtn'),

cssType = document.querySelectorAll('.css-type'),
jsType = document.querySelectorAll('.js-type');
console.log(jsType);

filterbtn.onclick = function(){
if (js.checked && !css.checked) {
for (var i = 0; i < cssType.length; i++) {
cssType[i].style.display = 'none';
}for (var i = 0; i < jsType.length; i++) {
jsType[i].style.display = 'block';
}document.querySelector('.nothing').style.display = 'none';
}else if (!js.checked && css.checked) {
for (var i = 0; i < jsType.length; i++) {
jsType[i].style.display = 'none';
}for (var i = 0; i < cssType.length; i++) {
cssType[i].style.display = 'block';
}document.querySelector('.nothing').style.display = 'none';
}else if (!js.checked && !css.checked){
document.querySelector('.nothing').style.display = 'block';
for (var i = 0; i < jsType.length; i++) {
jsType[i].style.display = 'none';
}for (var i = 0; i < cssType.length; i++) {
cssType[i].style.display = 'none';
}
}else if (js.checked && css.checked) {
for (var i = 0; i < jsType.length; i++) {
jsType[i].style.display = 'block';
}for (var i = 0; i < cssType.length; i++) {
cssType[i].style.display = 'block';
}
document.querySelector('.nothing').style.display = 'none';
}
}