forked from liduran/introduccionGit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.html
More file actions
292 lines (245 loc) · 7.77 KB
/
page.html
File metadata and controls
292 lines (245 loc) · 7.77 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
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>AutoMax Dealer</title>
<style>
body {
font-family: Arial;
margin: 0;
background: #f1f1f1;
}
header {
background: #000;
color: white;
padding: 15px;
text-align: center;
}
nav {
display: flex;
justify-content: center;
background: #222;
}
nav button {
color: white;
background: none;
border: none;
padding: 15px;
cursor: pointer;
}
nav button:hover {
background: #444;
}
section {
display: none;
padding: 20px;
}
.active {
display: block;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
}
.card {
background: white;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.card img {
width: 100%;
height: 160px;
object-fit: cover;
}
.card-content {
padding: 10px;
}
button {
padding: 10px;
margin-top: 10px;
cursor: pointer;
border: none;
background: #000;
color: white;
border-radius: 5px;
}
button:hover {
background: #333;
}
input {
padding: 10px;
margin-bottom: 15px;
width: 250px;
}
.login-box {
text-align: center;
margin-top: 60px;
}
.detail img {
width: 300px;
border-radius: 10px;
}
</style>
</head>
<body>
<header>
<h1>🚗 AutoMax Dealer</h1>
</header>
<nav>
<button onclick="showSection('home')">Inicio</button>
<button onclick="showSection('cars')">Vehículos</button>
<button onclick="showSection('about')">Sobre Nosotros</button>
<button onclick="logout()">Cerrar Sesión</button>
</nav>
<!-- LOGIN -->
<section id="login" class="active">
<div class="login-box">
<h2>Iniciar Sesión</h2>
<input type="text" id="user" placeholder="Usuario"><br>
<input type="password" id="pass" placeholder="Contraseña"><br>
<button onclick="login()">Entrar</button>
<p id="error" style="color:red;"></p>
</div>
</section>
<!-- HOME -->
<section id="home">
<h2>Bienvenido a AutoMax</h2>
<p>Los mejores vehículos al mejor precio.</p>
<h3>🔥 Vehículos Destacados</h3>
<div class="grid" id="featuredCars"></div>
<button onclick="showSection('cars')">Ver todos</button>
</section>
<!-- VEHICULOS -->
<section id="cars">
<h2>Vehículos</h2>
<input type="text" placeholder="Buscar vehículo..." onkeyup="searchCar(this.value)">
<div class="grid" id="carList"></div>
</section>
<!-- DETALLE -->
<section id="detail">
<div class="detail">
<h2 id="carTitle"></h2>
<img id="carImg">
<p><strong>Precio:</strong> <span id="carPrice"></span></p>
<p><strong>Año:</strong> <span id="carYear"></span></p>
<p><strong>Color:</strong> <span id="carColor"></span></p>
<p><strong>Transmisión:</strong> <span id="carTransmission"></span></p>
<p><strong>Descripción:</strong> <span id="carDesc"></span></p>
<button onclick="showSection('cars')">⬅ Volver</button>
</div>
</section>
<!-- ABOUT -->
<section id="about">
<h2>Sobre Nosotros</h2>
<p>Dealer confiable con más de 10 años en el mercado.</p>
</section>
<script>
let loggedIn = false;
const cars = [{
name: "Toyota Corolla 2022",
price: "$18,000",
year: 2022,
color: "Blanco",
transmission: "Automática",
desc: "Económico y confiable.",
img: "https://source.unsplash.com/400x300/?toyota"
},
{
name: "Honda Civic 2021",
price: "$17,500",
year: 2021,
color: "Negro",
transmission: "Manual",
desc: "Deportivo y eficiente.",
img: "https://source.unsplash.com/400x300/?honda"
},
{
name: "Ford Explorer 2020",
price: "$25,000",
year: 2020,
color: "Gris",
transmission: "Automática",
desc: "SUV familiar espaciosa.",
img: "https://source.unsplash.com/400x300/?ford,suv"
}
];
function loadCars(list = cars) {
const container = document.getElementById("carList");
container.innerHTML = "";
list.forEach((car, index) => {
container.innerHTML += `
<div class="card">
<img src="${car.img}">
<div class="card-content">
<h3>${car.name}</h3>
<p>${car.price}</p>
<button onclick="viewDetails(${index})">Ver detalles</button>
</div>
</div>
`;
});
}
function loadFeaturedCars() {
const container = document.getElementById("featuredCars");
container.innerHTML = "";
cars.slice(0, 2).forEach((car, index) => {
container.innerHTML += `
<div class="card">
<img src="${car.img}">
<div class="card-content">
<h3>${car.name}</h3>
<p>${car.price}</p>
<button onclick="viewDetails(${index})">Ver</button>
</div>
</div>
`;
});
}
function viewDetails(index) {
const car = cars[index];
document.getElementById("carTitle").innerText = car.name;
document.getElementById("carPrice").innerText = car.price;
document.getElementById("carYear").innerText = car.year;
document.getElementById("carColor").innerText = car.color;
document.getElementById("carTransmission").innerText = car.transmission;
document.getElementById("carDesc").innerText = car.desc;
document.getElementById("carImg").src = car.img;
showSection("detail");
}
function searchCar(text) {
const filtered = cars.filter(c =>
c.name.toLowerCase().includes(text.toLowerCase())
);
loadCars(filtered);
}
function login() {
const user = document.getElementById("user").value;
const pass = document.getElementById("pass").value;
if (user === "admin" && pass === "1234") {
loggedIn = true;
loadCars();
loadFeaturedCars();
showSection("home");
} else {
document.getElementById("error").innerText = "Credenciales incorrectas";
}
}
function logout() {
loggedIn = false;
showSection("login");
}
function showSection(id) {
if (!loggedIn && id !== "login") {
alert("Debes iniciar sesión");
return;
}
document.querySelectorAll("section").forEach(sec => {
sec.classList.remove("active");
});
document.getElementById(id).classList.add("active");
}
</script>
</body>
</html>