Skip to content

Commit

Permalink
feature: agrega boton quitar filtros
Browse files Browse the repository at this point in the history
  • Loading branch information
devchris03 committed Sep 8, 2024
1 parent 7b4b203 commit 0b67a45
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ document.addEventListener('DOMContentLoaded', function(){
const paginas = document.querySelector('#paginas');
const editorial = document.querySelector('#editorial');
const resultContent = document.querySelector('#resultContent');
const btnReset = document.querySelector('#btnReset');

// asigna valores seleccionados
let form = {
Expand All @@ -25,6 +26,7 @@ document.addEventListener('DOMContentLoaded', function(){
idioma.addEventListener('change', filter);
paginas.addEventListener('change', filter);
editorial.addEventListener('change', filter);
btnReset.addEventListener('click', resetSelects);

showResult(books)

Expand All @@ -39,8 +41,6 @@ document.addEventListener('DOMContentLoaded', function(){
bookItem.innerHTML = `
<span class="name">${nombre}</span> <span>${autor}</span> <span>${categoria}</span> <span>${año}</span> <span>${idioma}</span> <span>${npaginas} pag. </span> <span>${editorial}</span>
`
// bookItem.textContent = `${categoria} - ${autor} - ${año} - ${idioma} - ${paginas} - ${editorial}`;

resultContent.append(bookItem);
})
}
Expand All @@ -49,7 +49,6 @@ document.addEventListener('DOMContentLoaded', function(){
// filtra segun elección
function filter(event) {
form[event.target.name] = event.target.value;
console.log(form)

const newResult = books.filter(filterCategory).filter(filterAuthor).filter(filterYear).filter(filterLenguage).filter(filterPage).filter(filterEditorial);

Expand Down Expand Up @@ -126,4 +125,19 @@ document.addEventListener('DOMContentLoaded', function(){
resultContent.removeChild(resultContent.firstChild);
}
}


// resetea los campos select
function resetSelects() {
form = {
categoria: '',
autor: '',
año: '',
idioma: '',
paginas: '',
editorial: '',
};

showResult(books)
}
})

0 comments on commit 0b67a45

Please # to comment.