feat: Add "Decode all" checkbox for full METAR decoding

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-14 15:02:35 -07:00
parent e93187742d
commit cc2452c641
+23 -14
View File
@@ -42,6 +42,7 @@
<div id="metar-display"></div>
<button id="new-metar-btn">New METAR</button>
<button id="test-all-btn">Test All METARs</button>
<label style="margin-left: 1em;"><input type="checkbox" id="decode-all-checkbox"> Decode all</label>
<div id="decoding-display"></div>
<button id="next-btn" style="margin-top: 1em;">Next</button>
</div>
@@ -51,6 +52,7 @@
const newMetarBtn = document.getElementById('new-metar-btn');
const testAllBtn = document.getElementById('test-all-btn');
const nextBtn = document.getElementById('next-btn');
const decodeAllCheckbox = document.getElementById('decode-all-checkbox');
const metars = [];
let currentMetarSections = [];
@@ -229,26 +231,33 @@
});
newMetarBtn.addEventListener('click', displayNewMetar);
decodeAllCheckbox.addEventListener('change', updateDisplay);
function updateDisplay() {
if (currentMetarSections.length === 0) return;
// Build highlighted string
const parts = [];
currentMetarSections.forEach((section, index) => {
if (index === currentSectionIndex) {
parts.push(`<span class="highlight">${section.raw}</span>`);
} else {
parts.push(section.raw);
}
});
metarDisplay.innerHTML = parts.join(' ');
if (decodeAllCheckbox.checked) {
metarDisplay.innerHTML = currentMetarSections.map(s => s.raw).join(' ');
decodingDisplay.textContent = currentMetarSections.map(s => s.decoded).join('\n\n');
nextBtn.style.display = 'none';
} else {
// Build highlighted string
const parts = [];
currentMetarSections.forEach((section, index) => {
if (index === currentSectionIndex) {
parts.push(`<span class="highlight">${section.raw}</span>`);
} else {
parts.push(section.raw);
}
});
metarDisplay.innerHTML = parts.join(' ');
// Show decoding
decodingDisplay.textContent = currentMetarSections[currentSectionIndex].decoded;
// Show decoding
decodingDisplay.textContent = currentMetarSections[currentSectionIndex].decoded;
// Show/hide next button
nextBtn.style.display = (currentSectionIndex < currentMetarSections.length - 1) ? 'inline-block' : 'none';
// Show/hide next button
nextBtn.style.display = (currentSectionIndex < currentMetarSections.length - 1) ? 'inline-block' : 'none';
}
}
nextBtn.addEventListener('click', () => {