Created
December 29, 2021 20:13
-
-
Save gillkyle/e7fbc6103e38194b19172db13b2045f9 to your computer and use it in GitHub Desktop.
Helpers for entering stuff into voltorbflip.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy paste this into the console of Voltorbflip.com to make it easier to input numbers | |
function findAndFocus(id) { | |
document.getElementById(id).focus(); | |
} | |
function clearInputs() { | |
document.querySelectorAll("input").forEach(input => { | |
input.value = "" | |
}) | |
} | |
function handleChange(e) { | |
if (e.target.id === "r0p") { | |
findAndFocus("r0v"); | |
} else if (e.target.id === "r0v") { | |
findAndFocus("r1p"); | |
} else if (e.target.id === "r1p") { | |
findAndFocus("r1v"); | |
} else if (e.target.id === "r1v") { | |
findAndFocus("r2p"); | |
} else if (e.target.id === "r2p") { | |
findAndFocus("r2v"); | |
} else if (e.target.id === "r2v") { | |
findAndFocus("r3p"); | |
} else if (e.target.id === "r3p") { | |
findAndFocus("r3v"); | |
} else if (e.target.id === "r3v") { | |
findAndFocus("r4p"); | |
} else if (e.target.id === "r4p") { | |
findAndFocus("r4v"); | |
} else if (e.target.id === "r4v") { | |
findAndFocus("c0p"); | |
} else if (e.target.id === "c0p") { | |
findAndFocus("c0v"); | |
} else if (e.target.id === "c0v") { | |
findAndFocus("c1p"); | |
} else if (e.target.id === "c1p") { | |
findAndFocus("c1v"); | |
} else if (e.target.id === "c1v") { | |
findAndFocus("c2p"); | |
} else if (e.target.id === "c2p") { | |
findAndFocus("c2v"); | |
} else if (e.target.id === "c2v") { | |
findAndFocus("c3p"); | |
} else if (e.target.id === "c3p") { | |
findAndFocus("c3v"); | |
} else if (e.target.id === "c3v") { | |
findAndFocus("c4p"); | |
} else if (e.target.id === "c4p") { | |
findAndFocus("c4v"); | |
} else if (e.target.id === "c4v") { | |
console.log("done!") | |
} | |
} | |
document.querySelectorAll("input").forEach((input) => { | |
input.oninput = handleChange; | |
input.type = "number"; | |
input.max = 9; | |
input.maxlength = 1; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment