Random URL generation

This commit is contained in:
Raphaël Thériault 2019-10-25 13:49:33 -04:00
parent aa77707c21
commit f9fda22141
1 changed files with 11 additions and 0 deletions

View File

@ -31,6 +31,10 @@ const inputs = {
],
};
const randomUrl = () => {
return Math.floor(Math.random() * 2147483647).toString(36);
}
for (const group in tabs) {
tabs[group][0].onclick = () => {
const active = document.querySelectorAll(".active");
@ -65,6 +69,13 @@ for (const group in inputs) {
urlInput.setCustomValidity("");
}
});
urlInput.addEventListener("keyup", (e) => {
if (e.code === "Space") {
urlInput.value = randomUrl();
checkValidity();
e.preventDefault();
}
});
for (const input of inputs[group].filter(
(input) =>