Attempts: 0    Invalids: 0
function loadSelectedPuzzle() { const selector = document.getElementById("puzzleSelector"); const selected = selector.value; if (!selected) return; fetch(selected) .then(res => { if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`); return res.json(); }) .then(data => { loadFromConfig(data); if (typeof resetCounters === "function") resetCounters(); }) .catch(err => { alert("Failed to load puzzle: " + err.message); }); } function populatePuzzleDropdown() { fetch('/puzzles/index.json') .then(res => { if (!res.ok) throw new Error(`Unable to fetch puzzle index.`); return res.json(); }) .then(list => { const selector = document.getElementById("puzzleSelector"); list.forEach(entry => { const option = document.createElement("option"); option.value = entry.file; option.textContent = entry.name; selector.appendChild(option); }); }) .catch(err => { console.warn("Could not load puzzle list:", err); }); } document.addEventListener("DOMContentLoaded", populatePuzzleDropdown);