-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetails.html
More file actions
65 lines (60 loc) · 2.47 KB
/
details.html
File metadata and controls
65 lines (60 loc) · 2.47 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crane Details</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Crane Details</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="compare.html">Compare</a></li>
</ul>
</nav>
</header>
<section class="container">
<h2>Crane Details</h2>
<div id="crane-details" class="details-card"></div>
<a href="compare.html" class="btn">Back to Comparison</a>
</section>
<footer>
<div class="footer-content">
<p>© 2025 Crane Compare. All rights reserved.</p>
</div>
</footer>
<script>
document.addEventListener("DOMContentLoaded", function() {
const params = new URLSearchParams(window.location.search);
const craneId = params.get("crane");
if (!craneId) {
document.getElementById("crane-details").innerHTML = "<p>No crane selected.</p>";
return;
}
fetch('assets/cranes.json')
.then(response => response.json())
.then(data => {
const crane = data.cranes.find(c => c.id === craneId);
if (crane) {
document.getElementById("crane-details").innerHTML = `
<div class="crane-card">
<img src="${crane.image}" alt="${crane.name}" class="crane-image">
<h3>${crane.name}</h3>
<p><strong>Manufacturer:</strong> ${crane.manufacturer}</p>
<p><strong>Capacity:</strong> ${crane.capacity} tons</p>
<p><strong>Height:</strong> ${crane.height} meters</p>
<p><strong>Description:</strong> ${crane.description}</p>
</div>
`;
} else {
document.getElementById("crane-details").innerHTML = "<p>Crane not found.</p>";
}
})
.catch(error => console.error("Error fetching crane data:", error));
});
</script>
</body>
</html>