Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Mar 25, 2024
1 parent 5e793aa commit ba56af9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 24 additions & 0 deletions Source/Script/Index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function debounce(_Function, Delay) {
let Timer;

return function (...Argumnents) {
if (Timer) {
clearTimeout(Timer);
}
Timer = setTimeout(() => {
_Function.apply(this, Argumnents);
Timer = null;
}, Delay);
};
}

document
.querySelector<HTMLInputElement>("#mce-EMAIL")
?.addEventListener(
"input",
debounce((Event) => {
/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Event.target.value)
? document.querySelector<HTMLFormElement>('[name="mc-embedded-subscribe-form"]')?.submit()
: null;
}, 7000)
);
6 changes: 3 additions & 3 deletions Source/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ import "@Stylesheet/Page/Index.css";
value=""
aria-label="E-mail subscribe"
/>
<script>
import "@Script/Index.ts";
</script>
</div>
<button type="submit" name="subscribe">
Subscribe
</button>
</div>
</div>
<div
Expand Down

0 comments on commit ba56af9

Please sign in to comment.