Skip to content

Commit

Permalink
cambios de json
Browse files Browse the repository at this point in the history
  • Loading branch information
JMVallejo12 committed Dec 19, 2023
1 parent cb99bf2 commit f7c4eea
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,6 @@ <h4 class="h4-flyer">VISITA NUESTRO CANAL DE YOUTUBE</h4>
</footer>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script src="main.js"></script>
<script src="./script/main.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion pages/carrito.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ <h1 class="h1-cart">TU CARRITO</h1>

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script src="../script/carrito.js"></script>
<script src="../main.js"></script>
<script src="../script/main.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion pages/miperfil.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ <h2 class="item-title">TUS ARTICULOS FAVORITOS</h2>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script src="../script/perfil.js"></script>
<script src="../main.js"></script>
<script src="../script/main.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion pages/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script src="../main.js"></script>
<script src="../script/result.js"></script>
<script src="../script/main.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion pages/tienda.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ <h1 class="h1-shop">TIENDA</h1>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
<script src="../script/tienda.js"></script>
<script src="../main.js"></script>
<script src="../script/main.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions script/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

// accediendo a el local storage

window.onload = function(){
// verificando que tema tiene en el local storage
tema = localStorage.getItem("tema")
console.log(tema)
header.style.backgroundColor = tema
}

// trayendo la barra de busqueda con el id
const search_bar = document.getElementById("busqueda")
const products_url_main = "../products.json"
let show_product

fetch(products_url_main)
.then(response => response.json())
.then(data=>{
search_bar.addEventListener("keydown",(event)=>{
if (event.key === "Enter"){
console.log("entro")
const result = search_bar.value.toLowerCase()
console.log(result)
let show_product = data.filter(product=>product.name.toLowerCase().includes(result.toLowerCase()))
show_product.forEach((product=>{
console.log(product)

}))
show_product_str = JSON.stringify(show_product)
localStorage.setItem('search', show_product_str)
window.location.href = "../pages/result.html"
}
})
})
.catch(error => console.log("Error con la carga de data en filtro de busqueda"))


0 comments on commit f7c4eea

Please sign in to comment.