-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCAPTCHA.js
More file actions
33 lines (25 loc) · 745 Bytes
/
CAPTCHA.js
File metadata and controls
33 lines (25 loc) · 745 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
// set #image=https://whatever;content=whatever
const hash = window.location.hash;
const dict = hash
.substr(1)
.split(";")
.reduce((mem, cur) => {
const [key, val] = cur.split("=");
mem[key] = val;
return mem;
}, {});
const updateImage = (image, content = "Waldo") => {
const contentElem = document.getElementById("content");
const grid = document.querySelector(".waldogrid");
contentElem.textContent = content;
grid.style.backgroundImage = `url(${image})`;
};
if (dict.image && dict.content) {
updateImage(dict.image, dict.content);
}
document.addEventListener("click", (e) => {
const target = e.target;
if (target.classList.contains("waldosquare")) {
target.classList.toggle("selected");
}
});