020d0e7caf7d09cd63e7dc415d142e0c78e64c29
3 * A JavaScript file for the contact form.
10 const form
= document
.querySelector('.contact-form');
11 const button
= form
.querySelector('.form-submit');
12 const action
= form
.getAttribute('data-protect');
13 const body
= document
.querySelector('body');
15 function activateForm() {
16 form
.setAttribute('action', action
);
17 button
.removeAttribute('disabled');
20 // Display the hidden form.
21 form
.classList
.remove('hidden');
23 // Wait for a mouse to move, indicating they are human.
24 body
.addEventListener('mousemove', () => activateForm());
25 // Wait for a touch move event, indicating that they are human.
26 body
.addEventListener('touchmove', () => activateForm());
27 // A tab or enter key pressed can also indicate they are human.
28 body
.addEventListener('keydown', function (e
) {
29 if ((e
.key
=== 'Tab') || (e
.key
=== 'Enter')) {
34 // Mark the form as submitted.
35 button
.addEventListener('click', () => form
.classList
.add('js-submitted'));
38 if (location
.search
.substring(1) !== '') {
39 switch (location
.search
.substring(1)) {
41 document
.querySelector('.contact-submitted').classList
.remove('hidden');
45 document
.querySelector('.contact-error').classList
.remove('hidden');