Files
html-tools/metar.html
T
tanner 64f4d96d9a style: Indent CSS properties in metar.html
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-02-14 14:38:48 -07:00

75 lines
2.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>METAR Practice</title>
<style>
body {
font-family: monospace;
padding: 2em;
}
#metar-display {
font-size: 1.2em;
margin-bottom: 1em;
min-height: 3em;
}
@media (max-width: 600px) {
#metar-display {
min-height: 6em;
}
}
button {
font-size: 1em;
padding: 0.5em 1em;
}
</style>
</head>
<body>
<div id="app">
<h1>METAR Practice</h1>
<div id="metar-display"></div>
<button id="new-metar-btn">New METAR</button>
</div>
<script>
const metarDisplay = document.getElementById('metar-display');
const newMetarBtn = document.getElementById('new-metar-btn');
const metars = [];
function displayNewMetar() {
if (metars.length === 0) {
metarDisplay.textContent = 'No METARs loaded.';
return;
}
const randomIndex = Math.floor(Math.random() * metars.length);
metarDisplay.textContent = metars[randomIndex];
}
fetch('metars.txt')
.then(response => response.text())
.then(data => {
const lines = data.split('\n');
lines.forEach(line => {
if (line.includes('METAR')) {
const metarString = line.substring(line.indexOf('METAR') + 6).replace('=', '').trim();
if (metarString) {
metars.push(metarString);
}
}
});
console.log(`Loaded ${metars.length} METARs.`);
displayNewMetar(); // Display initial METAR
})
.catch(error => {
console.error('Error fetching or parsing metars.txt:', error)
metarDisplay.textContent = 'Could not load METARs.';
});
newMetarBtn.addEventListener('click', displayNewMetar);
</script>
</body>
</html>