-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (25 loc) · 892 Bytes
/
app.js
File metadata and controls
31 lines (25 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
async function loadPuzzle() {
try {
const response = await fetch("puzzles/today.json");
const puzzle = await response.json();
// Header
document.getElementById("puzzle-date").textContent = puzzle.date;
document.getElementById("puzzle-author").textContent = `By ${puzzle.author}`;
// Clue
document.getElementById("clue-text").textContent = puzzle.clue;
document.getElementById("answer-length").textContent = `(${puzzle.length})`;
// Answer cells
const answerBox = document.getElementById("answer-box");
answerBox.innerHTML = "";
for (let i = 0; i < puzzle.length; i++) {
const cell = document.createElement("div");
cell.className = "cell";
cell.dataset.index = i;
answerBox.appendChild(cell);
}
} catch (error) {
console.error("Failed to load puzzle:", error);
}
}
// Load on page start
loadPuzzle();