diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 1710768..9f77e2c 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,4 +1,4 @@ -import { Throttler } from "./utils"; +import { Throttler } from "./Throttler"; type Position = { x: number; @@ -105,7 +105,7 @@ function setupSearchBar(zipCodeElement: HTMLParagraphElement) { searchBar.onkeypress = (event: KeyboardEvent) => {console.log(event); event.key !== "Enter" || !isNaN(parseInt(event.key));} - searchBar.addEventListener("submit", async (event: MouseEvent) => { + searchBar.addEventListener("submit", async (event: SubmitEvent) => { event.preventDefault(); const inputValue = searchInput.value; diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts deleted file mode 100644 index c55e284..0000000 --- a/frontend/src/utils.ts +++ /dev/null @@ -1,17 +0,0 @@ -export class Throttler { - private hasBeenCalledWithinTime = false; - private lastCallFunc: (() => any) | null = null; - - public constructor(private minimumTimeBetweenCall: number) {} - - public call(func: () => any) { - this.lastCallFunc = func; - if (this.hasBeenCalledWithinTime) return; - this.hasBeenCalledWithinTime = true; - func(); - setTimeout(() => { - this.hasBeenCalledWithinTime = false; - if (this.lastCallFunc) this.lastCallFunc(); - }, this.minimumTimeBetweenCall); - } -}