Some improvements

This commit is contained in:
Henry Hiles 2022-06-03 13:46:55 -04:00
parent 82dd6fd398
commit 46e69ad87b
6 changed files with 134 additions and 69 deletions

View file

@ -1,6 +1,15 @@
import { v4 as uuidv4 } from "https://jspm.dev/uuid"
import { type } from "./utils.js"
const input = document.querySelector("#go-input")
input.addEventListener("keydown", (event) => {
if (event.code == "Space") {
event.preventDefault()
type("-")
} else if (!/^[-a-z0-9]+$/i.test(event.key)) event.preventDefault()
})
const setHref = () =>
(document.querySelector("#go").href = input.value || uuidv4())