This commit is contained in:
Mitch Ross
2026-02-21 15:50:58 -05:00
parent d67e89699b
commit ad69b1797f
+30 -13
View File
@@ -9,6 +9,7 @@ const WeatherSat = (function() {
let isRunning = false; let isRunning = false;
let eventSource = null; let eventSource = null;
let images = []; let images = [];
let allPasses = [];
let passes = []; let passes = [];
let selectedPassIndex = -1; let selectedPassIndex = -1;
let currentSatellite = null; let currentSatellite = null;
@@ -96,6 +97,8 @@ const WeatherSat = (function() {
if (!locationListenersAttached) { if (!locationListenersAttached) {
if (latInput) latInput.addEventListener('change', saveLocationFromInputs); if (latInput) latInput.addEventListener('change', saveLocationFromInputs);
if (lonInput) lonInput.addEventListener('change', saveLocationFromInputs); if (lonInput) lonInput.addEventListener('change', saveLocationFromInputs);
const satSelect = document.getElementById('weatherSatSelect');
if (satSelect) satSelect.addEventListener('change', applyPassFilter);
locationListenersAttached = true; locationListenersAttached = true;
} }
} }
@@ -536,6 +539,7 @@ const WeatherSat = (function() {
} }
if (!storedLat || !storedLon) { if (!storedLat || !storedLon) {
allPasses = [];
passes = []; passes = [];
selectedPassIndex = -1; selectedPassIndex = -1;
renderPasses([]); renderPasses([]);
@@ -551,24 +555,37 @@ const WeatherSat = (function() {
const data = await response.json(); const data = await response.json();
if (data.status === 'ok') { if (data.status === 'ok') {
passes = data.passes || []; allPasses = data.passes || [];
selectedPassIndex = -1; applyPassFilter();
renderPasses(passes);
renderTimeline(passes);
updateCountdownFromPasses();
// Always select the first upcoming pass so the polar plot
// and ground track reflect the current list after every refresh.
if (passes.length > 0) {
selectPass(0);
} else {
updateGroundTrack(null);
}
} }
} catch (err) { } catch (err) {
console.error('Failed to load passes:', err); console.error('Failed to load passes:', err);
} }
} }
/**
* Filter displayed passes by the currently selected satellite dropdown value.
* Updates the module-level `passes` from `allPasses` so selectPass/countdown work.
*/
function applyPassFilter() {
const satSelect = document.getElementById('weatherSatSelect');
const selected = satSelect?.value;
passes = selected
? allPasses.filter(p => p.satellite === selected)
: allPasses.slice();
selectedPassIndex = -1;
renderPasses(passes);
renderTimeline(passes);
updateCountdownFromPasses();
if (passes.length > 0) {
selectPass(0);
} else {
updateGroundTrack(null);
drawPolarPlot(null);
}
}
/** /**
* Select a pass to display in polar plot and map * Select a pass to display in polar plot and map
*/ */
@@ -731,7 +748,7 @@ const WeatherSat = (function() {
ctx.stroke(); ctx.stroke();
// Trajectory // Trajectory
const trajectory = pass.trajectory; const trajectory = pass?.trajectory;
if (!trajectory || trajectory.length === 0) return; if (!trajectory || trajectory.length === 0) return;
const color = pass.mode === 'LRPT' ? '#00ff88' : '#00d4ff'; const color = pass.mode === 'LRPT' ? '#00ff88' : '#00d4ff';