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:
@@ -42,6 +42,7 @@
|
|||||||
<div id="metar-display"></div>
|
<div id="metar-display"></div>
|
||||||
<button id="new-metar-btn">New METAR</button>
|
<button id="new-metar-btn">New METAR</button>
|
||||||
<button id="test-all-btn">Test All METARs</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>
|
<div id="decoding-display"></div>
|
||||||
<button id="next-btn" style="margin-top: 1em;">Next</button>
|
<button id="next-btn" style="margin-top: 1em;">Next</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
const newMetarBtn = document.getElementById('new-metar-btn');
|
const newMetarBtn = document.getElementById('new-metar-btn');
|
||||||
const testAllBtn = document.getElementById('test-all-btn');
|
const testAllBtn = document.getElementById('test-all-btn');
|
||||||
const nextBtn = document.getElementById('next-btn');
|
const nextBtn = document.getElementById('next-btn');
|
||||||
|
const decodeAllCheckbox = document.getElementById('decode-all-checkbox');
|
||||||
const metars = [];
|
const metars = [];
|
||||||
|
|
||||||
let currentMetarSections = [];
|
let currentMetarSections = [];
|
||||||
@@ -229,10 +231,16 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
newMetarBtn.addEventListener('click', displayNewMetar);
|
newMetarBtn.addEventListener('click', displayNewMetar);
|
||||||
|
decodeAllCheckbox.addEventListener('change', updateDisplay);
|
||||||
|
|
||||||
function updateDisplay() {
|
function updateDisplay() {
|
||||||
if (currentMetarSections.length === 0) return;
|
if (currentMetarSections.length === 0) return;
|
||||||
|
|
||||||
|
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
|
// Build highlighted string
|
||||||
const parts = [];
|
const parts = [];
|
||||||
currentMetarSections.forEach((section, index) => {
|
currentMetarSections.forEach((section, index) => {
|
||||||
@@ -250,6 +258,7 @@
|
|||||||
// Show/hide next button
|
// Show/hide next button
|
||||||
nextBtn.style.display = (currentSectionIndex < currentMetarSections.length - 1) ? 'inline-block' : 'none';
|
nextBtn.style.display = (currentSectionIndex < currentMetarSections.length - 1) ? 'inline-block' : 'none';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nextBtn.addEventListener('click', () => {
|
nextBtn.addEventListener('click', () => {
|
||||||
if (currentSectionIndex < currentMetarSections.length - 1) {
|
if (currentSectionIndex < currentMetarSections.length - 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user