fix: Update METAR on hash change and prevent re-display of current METAR
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
+13
@@ -76,6 +76,7 @@
|
||||
|
||||
let currentMetarSections = [];
|
||||
let currentSectionIndex = 0;
|
||||
let currentMetarIndex = -1;
|
||||
|
||||
// --- METAR Ranking ---
|
||||
|
||||
@@ -832,6 +833,11 @@
|
||||
metarIndex = Math.floor(Math.random() * Math.random() * metars.length);
|
||||
}
|
||||
|
||||
if (metarIndex === currentMetarIndex) {
|
||||
return; // Already displaying this METAR
|
||||
}
|
||||
currentMetarIndex = metarIndex;
|
||||
|
||||
const metarString = metars[metarIndex].metar;
|
||||
history.replaceState(null, '', '#' + metarIndex);
|
||||
|
||||
@@ -896,6 +902,13 @@
|
||||
|
||||
newMetarBtn.addEventListener('click', () => displayMetar());
|
||||
decodeAllCheckbox.addEventListener('change', updateDisplay);
|
||||
window.addEventListener('hashchange', () => {
|
||||
const hash = window.location.hash.substring(1);
|
||||
const index = parseInt(hash, 10);
|
||||
if (!isNaN(index) && index >= 0 && index < metars.length) {
|
||||
displayMetar(index);
|
||||
}
|
||||
});
|
||||
|
||||
function updateDisplay() {
|
||||
if (currentMetarSections.length === 0) return;
|
||||
|
||||
Reference in New Issue
Block a user