From 467cb9defc3ed8f028b5f9b9c1992c9e7ae7f1cc Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 14 Feb 2026 18:03:58 -0700 Subject: [PATCH] fix: Update METAR on hash change and prevent re-display of current METAR Co-authored-by: aider (gemini/gemini-2.5-pro) --- metar.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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;