Skip to content

Commit 0743f39

Browse files
committed
Remove overlay
1 parent acaff37 commit 0743f39

2 files changed

Lines changed: 14 additions & 36 deletions

File tree

web/aladin.html

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
</head>
1111
<body>
1212
<div id="aladin-lite-div" aria-label="Interactive FITS viewer"></div>
13-
<div id="aladin-overlay" class="overlay" role="status" aria-live="polite">
14-
<span id="overlay-message">Loading the NASA sky map…</span>
15-
</div>
1613
<aside class="hud" aria-live="polite">
1714
<p class="title">NASA FITS Explorer</p>
1815
<p class="status" id="status-message">Select a FITS source to start exploring.</p>
@@ -63,8 +60,6 @@
6360
<script type="module">
6461
import { A } from 'https://aladin.cds.unistra.fr/AladinLite/api/v3/latest/aladin.min.js';
6562

66-
const overlay = document.getElementById('aladin-overlay');
67-
const overlayMessage = document.getElementById('overlay-message');
6863
const statusMessage = document.getElementById('status-message');
6964
const errorBox = document.getElementById('aladin-error');
7065
const fileInput = document.getElementById('fits-file');
@@ -83,16 +78,6 @@
8378
}
8479
: null;
8580

86-
function setOverlay(message) {
87-
overlayMessage.textContent = message;
88-
overlay.classList.remove('hidden');
89-
}
90-
91-
function clearOverlay() {
92-
overlay.classList.add('hidden');
93-
overlayMessage.textContent = 'Loading the NASA sky map…';
94-
}
95-
9681
function showError(message) {
9782
errorBox.textContent = message;
9883
errorBox.classList.remove('hidden');
@@ -160,31 +145,41 @@
160145
const label = options.label || deriveLabel(source);
161146

162147
clearError();
163-
setOverlay(`Loading ${label}…`);
148+
const loadTimeout = window.setTimeout(() => {
149+
if (requestId !== currentRequestId) {
150+
return;
151+
}
152+
console.warn(`FITS load timed out: ${label}`);
153+
showError('The FITS file is taking longer than expected to respond. Please try again or use a different source.');
154+
}, options.timeout ?? 20000);
155+
156+
const clearLoadState = () => {
157+
window.clearTimeout(loadTimeout);
158+
};
164159

165160
const handleSuccess = (ra, dec, fov, image) => {
166161
if (requestId !== currentRequestId) {
167162
return;
168163
}
164+
clearLoadState();
169165
configureImage(image, options.colormap);
170166
focusOnImage(ra, dec, fov);
171167
updateStatus(label, fov);
172-
clearOverlay();
173168
};
174169

175170
const handleError = (error) => {
176171
if (requestId !== currentRequestId) {
177172
return;
178173
}
174+
clearLoadState();
179175
console.error('Failed to load FITS data', error);
180-
clearOverlay();
181176
showError('Unable to load the FITS data. Please verify the file or URL and try again.');
182177
};
183178

184179
try {
185180
const result = aladinInstance.displayFITS(source, options.params || {}, handleSuccess, handleError);
186181
if (result && typeof result.then === 'function') {
187-
result.catch(handleError);
182+
result.catch(handleError).finally(clearLoadState);
188183
}
189184
} catch (error) {
190185
handleError(error);
@@ -240,13 +235,11 @@
240235
if (DEFAULT_SAMPLE) {
241236
loadFits(DEFAULT_SAMPLE.url, DEFAULT_SAMPLE);
242237
} else {
243-
clearOverlay();
244238
updateStatus(null);
245239
}
246240
} catch (error) {
247241
console.error('Aladin Lite failed to initialise', error);
248242
showError('The Aladin Lite viewer could not be initialised. Please refresh the page.');
249-
clearOverlay();
250243
}
251244
}
252245

web/styles.css

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,6 @@ button:disabled {
171171
color: rgba(226, 232, 240, 0.72);
172172
}
173173

174-
.overlay {
175-
position: fixed;
176-
inset: 0;
177-
display: flex;
178-
align-items: center;
179-
justify-content: center;
180-
text-align: center;
181-
color: #f8fafc;
182-
font-size: 1rem;
183-
background: radial-gradient(circle at center, rgba(15, 23, 42, 0.86) 0%, rgba(3, 7, 18, 0.78) 65%, rgba(2, 6, 23, 0.6) 100%);
184-
backdrop-filter: blur(6px);
185-
padding: 1rem;
186-
z-index: 20;
187-
}
188-
189174
@media (max-width: 720px) {
190175
.hud {
191176
position: static;

0 commit comments

Comments
 (0)