diff --git a/Practicas/Practicas JS/DOM 07/index.html b/Practicas/Practicas JS/DOM 07/index.html index 4352e0a..8ed63d9 100644 --- a/Practicas/Practicas JS/DOM 07/index.html +++ b/Practicas/Practicas JS/DOM 07/index.html @@ -4,7 +4,7 @@ - Document + DOM 07 + + + +
+ + +

Seleccione Destino + +

+ +
+

Fechas del viaje

+

Elige el día de salida

+

Elige el día de vuelta

+
+

Coste vuelo

+

Coste hotel

+

Tasas viaje

+

Coste alquiler coche

+

Coste total

+ + + +
+
+ + \ No newline at end of file diff --git a/Practicas/Practicas JS/DOM 6 Version 2/index.html b/Practicas/Practicas JS/DOM 6 Version 2/index.html new file mode 100644 index 0000000..3ce0ba5 --- /dev/null +++ b/Practicas/Practicas JS/DOM 6 Version 2/index.html @@ -0,0 +1,65 @@ + + + + + + + Document + + + +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ + \ No newline at end of file diff --git a/Practicas/Practicas JS/DOM 6 Version 2/js/main.js b/Practicas/Practicas JS/DOM 6 Version 2/js/main.js new file mode 100644 index 0000000..2e73346 --- /dev/null +++ b/Practicas/Practicas JS/DOM 6 Version 2/js/main.js @@ -0,0 +1,54 @@ +function calculaTotales() { + + let nDias = calculaNDias();//document.getElementById("nDias").value; + + let destino = document.getElementById("destino").value; + let costeVuelo = document.getElementById("costeVuelo"); + let costeHotel = document.getElementById("costeHotel"); + let tasasViaje = document.getElementById("tasasViaje"); + let costeAlquilerCoche = document.getElementById("costeAlquilerCoche"); + let costeTotal = document.getElementById("costeTotal"); + + let PVPHOTEL; + let PVPALQUILERCOCHE = + parseInt(nDias) >= 7 ? 40 : parseInt(nDias) <= 3 ? 80 : 60; + let IVA = 1.21; + + let tasas = 0; + switch (destino) { + case "500": + tasas = 50; + PVPHOTEL = 90; + break; + case "1000": + tasas = 100; + PVPHOTEL = 110; + break; + case "1200": + tasas = 120; + PVPHOTEL = 80; + break; + } + if (nDias >= 12) { + tasas = 0; + } + + let vuelo = parseInt(destino); + let hotel = nDias * PVPHOTEL; + let alquilerCoche = nDias * PVPALQUILERCOCHE; + let total = parseFloat((vuelo + hotel + tasas + alquilerCoche) * IVA).toFixed( + 2 + ); + + costeVuelo.value = vuelo; + costeHotel.value = hotel; + tasasViaje.value = tasas; + costeAlquilerCoche.value = alquilerCoche; + costeTotal.value = total; +} + +function calculaNDias(){ + let inicio=new Date(document.getElementById("fechaIda").value); + let fin=new Date(document.getElementById("fechaRegreso").value); + return Math.ceil((fin-inicio) / (1000 * 60 * 60 * 24)); +} \ No newline at end of file diff --git a/Practicas/Practicas JS/DOM Alquiler Coche/Ejercicio_práctica_alquila_coche1.txt b/Practicas/Practicas JS/DOM Alquiler Coche/Ejercicio_práctica_alquila_coche1.txt new file mode 100644 index 0000000..c5232fe --- /dev/null +++ b/Practicas/Practicas JS/DOM Alquiler Coche/Ejercicio_práctica_alquila_coche1.txt @@ -0,0 +1,28 @@ +Hacer una aplicación que calcule el coste de alquiler de un vehículo con las siguientes condiciones: + +- Input para indicar los días de alquiler. +- Selector de fecha de inicio del alquiler. + +- Tres tipos de vehículo + Básico (45 Euros por día de alquiler) + Gama media (65 Euros por día de alquiler) + Lujo (85 Euros por día de alquiler) + +- Elementos opcionales +Silla Infantil(15 Euros por día de alquiler) +Gps(5 Euros por día de alquiler) + +- Seguro a terceros (10 Euros día)(Obligatorio, se informa al cliente). + +- Seguro a todo riesgo (Opcional) + Para Básico (15 Euros por día de alquiler) + Para Gama media (25 Euros por día de alquiler) + Para Lujo (35 Euros por día de alquiler) + +- Conductor con menos de 30 años (recargo de 30% sobre el precio final con Iva) + + +Debemos dar el precio final con IVA +Y mediante alerta el siguiente mensaje: +Faltan 2 días para tu alquiler ! +Tu fecha de de entrega del vehículo es el 27/1/2024 ! \ No newline at end of file diff --git a/Practicas/Practicas JS/DOM Alquiler Coche/index.html b/Practicas/Practicas JS/DOM Alquiler Coche/index.html new file mode 100644 index 0000000..fd8d09a --- /dev/null +++ b/Practicas/Practicas JS/DOM Alquiler Coche/index.html @@ -0,0 +1,59 @@ + + + + + + + + Alquiler de coche + + + +
+
+ +
+
+ +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+ Seguro a terceros obligatorio si no se + contrata otro superior (10€ dia) +
+ Todo riesgo (15€ para basico 25€ para gamam media 35€ para lujo) + +
+ +
+ + +
+
+ +
+ + +
+ + + \ No newline at end of file diff --git a/Practicas/Practicas JS/DOM Alquiler Coche/js/main.js b/Practicas/Practicas JS/DOM Alquiler Coche/js/main.js new file mode 100644 index 0000000..9f39407 --- /dev/null +++ b/Practicas/Practicas JS/DOM Alquiler Coche/js/main.js @@ -0,0 +1,88 @@ +function calculaAlquiler() { + const IVA = 1.21; + const resultado = document.getElementById("resultado"); + const diasAlquiler = parseInt(document.getElementById("diasAlquiler").value); + const fechaInicio = new Date(document.getElementById("fechaInicio").value); + const diasHastaRecojer = diasDiferencia(fechaInicio); + + //prettier-ignore + const eurXVehiculo = parseInt(eurXTipo(document.getElementById("tipoVehiculo").value)); + //prettier-ignore + const sillaInfantil = document.getElementById("sillaInfantil").checked ? 15 : 0; + const gps = document.getElementById("gps").checked ? 5 : 0; + let seguro = parseInt( + document.querySelector('input[name="seguro"]:checked').value + ); + if (seguro === 0) { + seguro = parseInt( + eurXSeguro(document.getElementById("tipoVehiculo").value) + ); + } + + const menor30 = document.getElementById("menor30").checked; + + let pvpSinIva = + eurXVehiculo * diasAlquiler + + sillaInfantil * diasAlquiler + + gps * diasAlquiler + + seguro * diasAlquiler; + + let pvpConIva = 0; + if (menor30 === true) { + pvpConIva = pvpSinIva * IVA * 1.3; + } else { + pvpConIva = pvpSinIva * IVA; + } + + resultado.textContent = `El total final es: ${pvpConIva.toFixed(2)}€`; + + alert( + `Faltan ${diasHastaRecojer} dias para tu alquiler! \n Tu fecha de entrega del vehículo es el ${formatFecha( + fechaInicio + )} ` + ); +} + +function eurXTipo(tipoVehiculo) { + let valor = 0; + switch (tipoVehiculo) { + case "basico": + valor = 45; + break; + case "gama_media": + valor = 65; + break; + case "lujo": + valor = 85; + break; + } + return valor; +} + +function eurXSeguro(tipoVehiculo) { + let valor = 0; + switch (tipoVehiculo) { + case "basico": + valor = 15; + break; + case "gama_media": + valor = 25; + break; + case "lujo": + valor = 35; + break; + } + return valor; +} + +function diasDiferencia(fechaFinal) { + const fechaActual = new Date(); + return Math.ceil((fechaFinal - fechaActual) / (1000 * 60 * 60 * 24)); +} + +function formatFecha(fecha) { + var dia = fecha.getDate(); + var mes = fecha.getMonth() + 1; + var ano = fecha.getFullYear(); + return `${dia}/${mes}/${ano}`; +}