-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
376 lines (346 loc) · 14.5 KB
/
index.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ViajesLoLO</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: url('https://turismodeislascanarias.com/sites/default/files/plane.jpg') no-repeat center center fixed;
background-size: cover;
color: #fff;
}
header {
background-color: #003366;
color: white;
padding: 1rem 0;
text-align: center;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
background-color: #004080;
}
nav ul li {
margin: 0 1rem;
}
nav ul li a {
color: white;
text-decoration: none;
}
main {
padding: 2rem;
text-align: center;
background-color: rgba(0, 0, 51, 0.7);
margin: 1rem;
border-radius: 8px;
}
footer {
background-color: #003366;
color: white;
text-align: center;
padding: 0.5rem 0;
position: fixed;
width: 100%;
bottom: 0;
}
form {
display: flex;
flex-direction: column;
align-items: center;
max-width: 400px;
margin: 0 auto;
}
form label,
form input,
form button,
form select,
form textarea {
margin: 0.5rem 0;
width: 100%;
padding: 0.5rem;
}
button {
background-color: #004080;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0059b3;
}
#resultados,
#resultadoCheckin,
#resultadoContacto,
#confirmacionReserva,
#resultadoCancelarReserva,
#resultadoLogin,
#resultadoRegistro {
margin-top: 1rem;
color: #ffcc00;
}
.hidden {
display: none;
}
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background-color: rgba(255, 255, 255, 0.9);
color: #000;
}
table th,
table td {
border: 1px solid #003366;
padding: 0.5rem;
text-align: left;
}
table th {
background-color: #004080;
color: #fff;
}
.center {
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>ViajesLoLO</h1>
<nav>
<ul>
<li><a href="#inicio" onclick="mostrarSeccion('inicio')">Inicio</a></li>
<li><a href="#vuelos" onclick="mostrarSeccion('vuelos')">Vuelos Disponibles</a></li>
<li class="restricted"><a href="#reservas" onclick="mostrarSeccion('reservas')">Reservas</a></li>
<li class="restricted"><a href="#checkin" onclick="mostrarSeccion('checkin')">Check-in</a></li>
<li><a href="#contacto" onclick="mostrarSeccion('contacto')">Contacto</a></li>
<li><a href="#login" onclick="mostrarSeccion('login')">Login</a></li>
<li><a href="#registro" onclick="mostrarSeccion('registro')">Registro</a></li>
</ul>
</nav>
</header>
<main id="inicio">
<h2>Bienvenidos a ViajesLoLO</h2>
<p>Tu viaje, nuestro compromiso. Descubre el mundo con nosotros.</p>
</main>
<main id="vuelos" class="hidden">
<h2>Vuelos Disponibles</h2>
<div id="listaVuelos"></div>
</main>
<main id="reservas" class="hidden">
<h2>Reservas</h2>
<form id="reservaForm">
<label for="origen">Origen:</label>
<input type="text" id="origen" name="origen" required>
<label for="destino">Destino:</label>
<input type="text" id="destino" name="destino" required>
<label for="fecha">Fecha:</label>
<input type="date" id="fecha" name="fecha" required>
<button type="submit">Buscar Vuelos</button>
</form>
<div id="resultados"></div>
<form id="reservaVueloForm" class="hidden">
<label for="vueloID">ID del Vuelo:</label>
<input type="text" id="vueloID" name="vueloID" required>
<label for="asientoID">ID del Asiento:</label>
<input type="text" id="asientoID" name="asientoID" required>
<button type="submit">Reservar Vuelo</button>
</form>
<div id="confirmacionReserva"></div>
<form id="cancelarReservaForm">
<label for="codigoReservaCancelar">Código de Reserva:</label>
<input type="text" id="codigoReservaCancelar" name="codigoReservaCancelar" required>
<button type="submit">Cancelar Reserva</button>
</form>
<div id="resultadoCancelarReserva"></div>
</main>
<main id="checkin" class="hidden">
<h2>Check-in</h2>
<form id="checkinForm">
<label for="codigoReserva">Código de Reserva:</label>
<input type="text" id="codigoReserva" name="codigoReserva" required>
<label for="apellido">Apellido:</label>
<input type="text" id="apellido" name="apellido" required>
<button type="submit">Check-in</button>
</form>
<div id="resultadoCheckin"></div>
</main>
<main id="contacto" class="hidden">
<h2>Contacto</h2>
<form id="contactoForm">
<label for="nombre">Nombre:</label>
<input type="text" id="nombre" name="nombre" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="mensaje">Mensaje:</label>
<textarea id="mensaje" name="mensaje" required></textarea>
<button type="submit">Enviar</button>
</form>
<div id="resultadoContacto"></div>
</main>
<main id="login" class="hidden">
<h2>Login</h2>
<form id="loginForm">
<label for="clienteID">ID de Cliente:</label>
<input type="text" id="clienteID" name="clienteID" required>
<label for="clave">Clave:</label>
<input type="password" id="clave" name="clave" required>
<button type="submit">Login</button>
</form>
<div id="resultadoLogin"></div>
</main>
<main id="registro" class="hidden">
<h2>Registro</h2>
<form id="registroForm">
<label for="nombreRegistro">Nombre:</label>
<input type="text" id="nombreRegistro" name="nombre" required>
<label for="direccion">Dirección:</label>
<input type="text" id="direccion" name="direccion" required>
<label for="nombreCompania">Nombre de la Compañía:</label>
<input type="text" id="nombreCompania" name="nombreCompania" required>
<label for="telefono">Número de Teléfono:</label>
<input type="text" id="telefono" name="telefono" required>
<label for="emailRegistro">Email:</label>
<input type="email" id="emailRegistro" name="email" required>
<label for="tipoCliente">Tipo de Cliente:</label>
<select id="tipoCliente" name="tipoCliente" required>
<option value="corporativo">Corporativo</option>
<option value="minorista">Minorista</option>
</select>
<label for="claveRegistro">Clave:</label>
<input type="password" id="claveRegistro" name="clave" required>
<label for="confirmarClave">Confirmar Clave:</label>
<input type="password" id="confirmarClave" name="confirmarClave" required>
<button type="submit">Registrar</button>
</form>
<div id="resultadoRegistro"></div>
</main>
<footer>
<p>© 2024 ViajesLoLO. Todos los derechos reservados.</p>
</footer>
<script>
// Usuario admin oculto
const usuarios = [
{ id: 'admin', clave: 'admin' }
];
function mostrarSeccion(id) {
const secciones = document.querySelectorAll('main');
secciones.forEach(seccion => {
if (seccion.id === id) {
seccion.classList.remove('hidden');
} else {
seccion.classList.add('hidden');
}
});
}
class Vuelo {
constructor(vueloID, origen, destino, fechaHoraSalida, fechaHoraLlegada, estado, capacidad, asientosDisponibles, precio) {
this.vueloID = vueloID;
this.origen = origen;
this.destino = destino;
this.fechaHoraSalida = fechaHoraSalida;
this.fechaHoraLlegada = fechaHoraLlegada;
this.estado = estado;
this.capacidad = capacidad;
this.asientosDisponibles = asientosDisponibles;
this.precio = precio;
}
}
const vuelos = [
new Vuelo('V001', 'Madrid', 'Barcelona', '2024-06-01T08:00', '2024-06-01T09:30', 'En horario', 180, 20, 120),
new Vuelo('V002', 'Madrid', 'París', '2024-06-02T10:00', '2024-06-02T12:30', 'En horario', 180, 15, 150),
new Vuelo('V003', 'Madrid', 'Londres', '2024-06-03T14:00', '2024-06-03T15:45', 'Retrasado', 180, 10, 200),
new Vuelo('V004', 'Barcelona', 'Roma', '2024-06-04T09:00', '2024-06-04T11:00', 'En horario', 180, 5, 130),
new Vuelo('V005', 'París', 'Nueva York', '2024-06-05T16:00', '2024-06-05T20:00', 'En horario', 180, 25, 500),
new Vuelo('V006', 'Londres', 'Tokio', '2024-06-06T18:00', '2024-06-07T10:00', 'Retrasado', 180, 30, 700),
new Vuelo('V007', 'Roma', 'Berlín', '2024-06-07T07:00', '2024-06-07T09:00', 'En horario', 180, 8, 100),
new Vuelo('V008', 'Berlín', 'Moscú', '2024-06-08T12:00', '2024-06-08T16:00', 'En horario', 180, 12, 300),
new Vuelo('V009', 'Madrid', 'Lisboa', '2024-06-09T11:00', '2024-06-09T12:30', 'En horario', 180, 18, 80),
new Vuelo('V010', 'Lisboa', 'Madrid', '2024-06-10T13:00', '2024-06-10T14:30', 'En horario', 180, 22, 90)
];
const listaVuelosDiv = document.getElementById('listaVuelos');
const tablaVuelos = document.createElement('table');
tablaVuelos.innerHTML = `
<thead>
<tr>
<th>ID del Vuelo</th>
<th>Origen</th>
<th>Destino</th>
<th>Fecha y Hora de Salida</th>
<th>Fecha y Hora de Llegada</th>
<th>Estado</th>
<th>Capacidad</th>
<th>Asientos Disponibles</th>
<th>Precio</th>
<th>Reservar</th>
</tr>
</thead>
<tbody id="tbodyVuelos">
</tbody>
`;
listaVuelosDiv.appendChild(tablaVuelos);
const tbodyVuelos = document.getElementById('tbodyVuelos');
vuelos.forEach(vuelo => {
const fila = document.createElement('tr');
fila.innerHTML = `
<td>${vuelo.vueloID}</td>
<td>${vuelo.origen}</td>
<td>${vuelo.destino}</td>
<td>${vuelo.fechaHoraSalida}</td>
<td>${vuelo.fechaHoraLlegada}</td>
<td>${vuelo.estado}</td>
<td>${vuelo.capacidad}</td>
<td>${vuelo.asientosDisponibles}</td>
<td>${vuelo.precio} EUR</td>
<td class="center"><button onclick="reservarVuelo('${vuelo.vueloID}')">Reservar</button></td>
`;
tbodyVuelos.appendChild(fila);
});
let usuarioLogueado = false;
document.getElementById('loginForm').addEventListener('submit', function (event) {
event.preventDefault();
const id = document.getElementById('clienteID').value;
const clave = document.getElementById('clave').value;
const usuario = usuarios.find(user => user.id === id && user.clave === clave);
if (usuario) {
usuarioLogueado = true;
document.querySelectorAll('.restricted').forEach(item => item.classList.remove('hidden'));
document.getElementById('resultadoLogin').innerText = 'Login exitoso. Ahora puede realizar reservas.';
} else {
document.getElementById('resultadoLogin').innerText = 'ID de cliente o clave incorrectos.';
}
});
function reservarVuelo(vueloID) {
if (usuarioLogueado) {
document.getElementById('reservaVueloForm').classList.remove('hidden');
document.getElementById('vueloID').value = vueloID;
} else {
alert('Debe iniciar sesión para reservar un vuelo.');
}
}
document.getElementById('registroForm').addEventListener('submit', function (event) {
event.preventDefault();
const clave = document.getElementById('claveRegistro').value;
const confirmarClave = document.getElementById('confirmarClave').value;
if (clave === confirmarClave) {
const nuevoUsuario = {
id: document.getElementById('emailRegistro').value,
clave: clave
};
usuarios.push(nuevoUsuario);
document.getElementById('resultadoRegistro').innerText = 'Registro exitoso. Ahora puede iniciar sesión.';
} else {
document.getElementById('resultadoRegistro').innerText = 'Las claves no coinciden.';
}
});
// Al iniciar la página, ocultar los elementos restringidos
document.querySelectorAll('.restricted').forEach(item => item.classList.add('hidden'));
</script>
</body>
</html>