From 2d33b7428bb4881aa6d38b4358f5bbdb96f15523 Mon Sep 17 00:00:00 2001 From: floydferrer <146372883+floydferrer@users.noreply.github.com> Date: Sun, 17 Nov 2024 09:21:43 -0800 Subject: [PATCH] removed api-actionnetwork script and js file (#7719) --- _layouts/default-markdown.html | 1 - assets/js/api-actionnetwork.js | 116 --------------------------------- 2 files changed, 117 deletions(-) delete mode 100644 assets/js/api-actionnetwork.js diff --git a/_layouts/default-markdown.html b/_layouts/default-markdown.html index 56f11ce4fb..db2d682d36 100644 --- a/_layouts/default-markdown.html +++ b/_layouts/default-markdown.html @@ -15,7 +15,6 @@ - \ No newline at end of file diff --git a/assets/js/api-actionnetwork.js b/assets/js/api-actionnetwork.js deleted file mode 100644 index 237750b2e6..0000000000 --- a/assets/js/api-actionnetwork.js +++ /dev/null @@ -1,116 +0,0 @@ -(function (window, document, undefined) { - //capture all DOM Elements - var heroForm = document.querySelector(".hero-signup"); - var heroFormInput = document.getElementById("hero-signup"); - var heroBtn = document.getElementById("hero-signup-btn"); - - var contactForm = document.querySelector(".contact-form"); - var contactFormEmail = document.getElementById("contact-email"); - var contactFormBtn = document.getElementById("contact-form-btn"); - - var heroFormConfirm = document.querySelector(".form-confirmation strong"); - var contactFormConfirm = document.querySelector( - ".contact-form .form-confirmation strong" - ); - - // API CONNECTION INFO - var ACTION_NETWORK_API = ""; - var url = "https://actionnetwork.org/api/v2/people/"; - - // FORM SUBMISSION HELPER FUNCTIONS - var submitEmail = function (url = ``, email) { - var postData = { - person: { - email_addresses: [{ - address: email - }] - } - }; - - return fetch(url, { - method: "POST", - headers: { - "OSDI-API-Token": ACTION_NETWORK_API, - "Content-Type": "application/json" - }, - body: JSON.stringify(postData) - }).then(response => response.json()); - }; - - var setPostMessage = function (targetNode, error) { - var successMessage = document.createTextNode( - "Thanks! You'll hear from us soon." - ); - var errorMessage = document.createTextNode(error); - - if (error) { - targetNode.innerHTML = ''; - targetNode.appendChild(errorMessage); - } else { - targetNode.innerHTML = ''; - targetNode.appendChild(successMessage); - } - }; - - var validateEmail = function (email) { - var pattern = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/ - - return pattern.test(email); - } - - // EVENT LISTENERS FOR FORM SUBMISSIONS - if (heroBtn) { - heroBtn.addEventListener("click", function (event) { - event.preventDefault(); - var email = heroFormInput.value; - - if (validateEmail(email)) { - submitEmail(url, email) - .then(function (data) { - if (data.error) { - setPostMessage(heroFormConfirm, data.error); - } else { - setPostMessage(heroFormConfirm); - } - - heroForm.reset(); - }) - .catch(function (error) { - var errorMessage = document.createTextNode(error.message); - heroFormConfirm.appendChild(errorMessage); - heroForm.reset(); - }); - } else { - setPostMessage(heroFormConfirm, "Invalid Email Format"); - } - }); - } - - if (contactFormBtn) { - contactFormBtn.addEventListener("click", function (event) { - event.preventDefault(); - var email = contactFormEmail.value; - - if (validateEmail(email)) { - submitEmail(url, email) - // submitEmail(url, email) - .then(function (data) { - if (data.error) { - setPostMessage(contactFormConfirm, data.error); - } else { - setPostMessage(contactFormConfirm); - } - - contactForm.reset(); - }) - .catch(function (error) { - var errorMessage = document.createTextNode(error.message); - contactFormConfirm.appendChild(errorMessage); - contactForm.reset(); - }); - } else { - setPostMessage(contactFormConfirm, "Invalid Email Format"); - } - }); - } -})(window, document);