-
Notifications
You must be signed in to change notification settings - Fork 0
/
card-details.html
113 lines (104 loc) · 3.67 KB
/
card-details.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GeneTerrain Card Details</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
background-color: #f9f9f9;
}
#map {
width: 70%;
height: 70vh;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
margin-top: 20px;
}
.details-container {
width: 70%;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-top: 20px;
padding: 20px;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
.detail-item {
font-size: 1rem;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", async () => {
// Retrieve the item object from sessionStorage
const item = JSON.parse(sessionStorage.getItem("selectedItem"));
if (!item) {
document.body.innerHTML = `<p style="text-align:center;">No data available to display!</p>`;
return;
}
// Extract Base64 content from item object
const lowQualityImage = item.low;
const mediumQualityImage = item.med;
const highQualityImage = item.high;
// Initialize the map
const map = L.map("map", {
crs: L.CRS.Simple,
minZoom: -5,
maxZoom: 2,
zoomSnap: 1,
});
// Adjust the image bounds
const imageWidth = 800; // Replace with your image's actual width
const imageHeight = 600; // Replace with your image's actual height
const imageBounds = [[0, 0], [imageHeight, imageWidth]];
// Add the low-quality image initially
let currentOverlay = L.imageOverlay(`${lowQualityImage}`, imageBounds).addTo(map);
map.setView([imageHeight/2, imageWidth/2], 1);
// Switch images based on zoom level
map.on("zoomend", () => {
const zoomLevel = map.getZoom();
// Remove the current overlay
if (currentOverlay) {
map.removeLayer(currentOverlay);
}
// Add the appropriate quality image based on zoom level
if (zoomLevel <= -2) {
currentOverlay = L.imageOverlay(`${lowQualityImage}`, imageBounds).addTo(map);
} else if (zoomLevel <= -1) {
currentOverlay = L.imageOverlay(`${mediumQualityImage}`, imageBounds).addTo(map);
} else {
currentOverlay = L.imageOverlay(`${highQualityImage}`, imageBounds).addTo(map);
}
});
// Render details
const detailsContainer = document.getElementById("details-container");
detailsContainer.innerHTML = `
<div class="detail-item"><strong>Sample ID:</strong> ${item.sampleID}</div>
<div class="detail-item"><strong>Resolution:</strong> ${item.resolution}</div>
<div class="detail-item"><strong>Scale Min:</strong> ${item.scaleMin}</div>
<div class="detail-item"><strong>Scale Max:</strong> ${item.scaleMax}</div>
<div class="detail-item"><strong>Sigma:</strong> ${item.sigma}</div>
<div class="detail-item"><strong>Cancer Type:</strong> ${item.cancerType}</div>
`;
});
</script>
</head>
<body>
<!-- Map container -->
<div id="map"></div>
<!-- Details container -->
<div id="details-container" class="details-container"></div>
</body>
</html>