diff --git a/metar.html b/metar.html
index 14d10e7..fce7da5 100644
--- a/metar.html
+++ b/metar.html
@@ -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;