mirror of https://github.com/raftario/filite.git
Edit space detection method for random url gen (fixes #3)
This commit is contained in:
parent
4d835ed4c7
commit
aa8bd8b9f4
|
@ -76,6 +76,13 @@ for (const group in inputs) {
|
|||
|
||||
const urlInput = inputs[group][0];
|
||||
urlInput.addEventListener("input", () => {
|
||||
if (urlInput.value[urlInput.value.length - 1] === " ") {
|
||||
urlInput.value = randomUrl();
|
||||
checkValidity();
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
urlInput.value = urlInput.value
|
||||
.replace(/[^0-9A-Za-z]/g, "")
|
||||
.toLowerCase();
|
||||
|
@ -87,13 +94,6 @@ for (const group in inputs) {
|
|||
urlInput.setCustomValidity("");
|
||||
}
|
||||
});
|
||||
urlInput.addEventListener("keyup", (e) => {
|
||||
if (e.code === "Space") {
|
||||
urlInput.value = randomUrl();
|
||||
checkValidity();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
const checkValidity = () => {
|
||||
if (used[group].some((x) => x.id === parseInt(urlInput.value, 36))) {
|
||||
|
|
Loading…
Reference in New Issue