-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
43 lines (37 loc) · 1.18 KB
/
Copy pathmain.js
File metadata and controls
43 lines (37 loc) · 1.18 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
// Declaración de variables
let continuarComprando = true
let continuarAgregando = true
let total = 0
let carrito = []
let busqueda = []
// Lista de productos
let lista = []
const Producto = function (nombre, precio, imagen, stock){
this.nombre=nombre
this.precio=precio
this.imagen=imagen
this.stock=stock
}
const ProductoCarrito = function (nombre, precio, imagen){
this.nombre=nombre
this.precio=precio
this.imagen=imagen
}
// Cargo los productos a la lista
cargarLista()
// Eventos
let boton1 = document.getElementById("verTodo")
boton1.addEventListener("click",function() {mostrarProductos(lista)})
let boton2 = document.getElementById("verCarrito")
boton2.addEventListener("click", mostrarCarrito)
let boton3 = document.getElementById("addProducto")
boton3.addEventListener("click", agregarProducto)
let boton4 = document.getElementById("delProducto")
boton4.addEventListener("click", delProducto)
let searchForm = document.getElementById('searchForm')
searchForm.addEventListener('submit', function(event) {
event.preventDefault()
let palabraBuscada = document.getElementById('searchInput').value.trim().toLowerCase()
filtrarProductos(palabraBuscada)
}
)