diff --git a/.gitignore b/.gitignore index 40b878d..3c3629e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -node_modules/ \ No newline at end of file +node_modules diff --git a/index.html b/index.html index f91132e..1f81734 100644 --- a/index.html +++ b/index.html @@ -190,7 +190,11 @@

I'm always interested in hearing about new projects, so if you'd like to chat please get in touch.

-
+
{ }; // eslint-disable-next-line no-plusplus -for (let i = 5; i >= 0; i--) { +for (let i = 5; i >= 0; i -= 1) { creatProject(); const projectHeading = document.querySelector('.project-heading'); const ProjectTechnologies1 = document.querySelector('.Project-technologies1'); @@ -444,3 +444,25 @@ formSubmit.addEventListener('click', (event) => { } formSubmit.submit(); }); + +/* Local Storage */ + +const fullName = document.getElementById('full-name'); +const message = document.getElementById('message'); + +function addFormData() { + const formDetails = document.getElementById('contact-Form'); + const contactFormData = new FormData(formDetails); + const contactFormObject = Object.fromEntries(contactFormData.entries()); + localStorage.setItem('form', JSON.stringify(contactFormObject)); +} + +email.addEventListener('keydown', addFormData); +fullName.addEventListener('keydown', addFormData); +message.addEventListener('keydown', addFormData); + +const storedData = JSON.parse(localStorage.getItem('form') ?? '{}'); + +fullName.value = storedData.name ?? ''; +email.value = storedData.email ?? ''; +message.value = storedData.message ?? '';