-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfav.html
More file actions
81 lines (74 loc) · 3.03 KB
/
Copy pathfav.html
File metadata and controls
81 lines (74 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://bootswatch.com/5/darkly/bootstrap.min.css">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<header id="header" class="container-fluid py-4">
<div class="row">
<div class="col"><h1>R<span>A</span>PPI</h1></div>
<nav class="col-auto ms-auto">
<a href="./index.html">Inicio</a>
<a href="./fav.html">Favoritos</a>
</nav>
</div>
</header>
<div class="container my-5" id="recetas">
<div class="row"></div>
</div>
<div class="modal fade" id="emergente" tabindex="-1" aria-labelledby="emergenteLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="emergenteLabel"></h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="text-center"><img src="" alt="" class="img-fluid"></div>
<h2>Instrucciones</h2><p></p>
<h2>Ingredientes</h2><ul></ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary favoritos" >Guardar Favorito</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
<script src="./funciones.js"></script>
<script>
const containerRecetas=document.querySelector("#recetas .row");
const btnFav=document.querySelector(".favoritos");
//Lo que haya en el local storage se mete en un array
let idFavoritos;
if(localStorage.length!=0){
//Actualizar el array donde guardo el array de ids del local storage
idFavoritos=localStorage.getItem("favoritos");
idFavoritos=JSON.parse(idFavoritos);
//Crear tarjeta
idFavoritos.forEach(id => {
let url=`https://www.themealdb.com/api/json/v1/1/lookup.php?i=${id}`;
fetch(url).
then(res => res.json())
.then(datosReceta=>{
datosReceta.meals.forEach(dato=>{
containerRecetas.append(crearTarjetaReceta(dato));
})
})
});
}else{
const col = document.createElement("div");
col.classList.add("col-md-4");
col.innerHTML=`
<p class='noRecetasMsj'>No hay recetas añadidas</p>
`;
containerRecetas.append(col);
}
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>