-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (25 loc) · 879 Bytes
/
Copy pathscript.js
File metadata and controls
27 lines (25 loc) · 879 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
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("./sw.js");
}
import words from "./words.js";
const output = document.getElementById("output");
document.getElementById("numBox").addEventListener("input", (e) => {
const number = e.target.value;
const word = words[number];
if (word) {
output.textContent = word;
const el = document.createElement("li");
const span = document.createElement("span");
el.textContent = word;
span.textContent = number;
el.appendChild(span);
document.getElementById("list").append(el);
const history = document.getElementById("history");
history.scrollTop = list.scrollHeight;
history.style.display = "block";
} else if (number.length === 4) {
output.textContent = "I couldn't find that word.";
} else if (number.length > 4) {
e.target.value = number.slice(4);
}
});