diff --git a/assets/js/main.js b/assets/js/main.js index 3f52c31..34a580c 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -203,7 +203,6 @@ jQuery(document).ready(function() { // Ensures valid email is supplied $(".subscribe").click(function () { if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(document.getElementById('email').value)) { - document.getElementById('email').value = "" document.getElementById('email').placeholder = "Thank you for subscribing to our newsletters." } else { document.getElementById('email').value = "" @@ -211,5 +210,50 @@ jQuery(document).ready(function() { } }); })(jQuery); -// News letter Form -// use email + + + +// Storing Newsletter emails in Firebase DB + +// Your web app's Firebase configuration + var firebaseConfig = { + apiKey: "XXXXXXXXXXX", + authDomain: "XXXXXXXXXXX", + databaseURL: "XXXXXXXXXXX", + projectId: "XXXXXXXXXXX", + storageBucket: "XXXXXXXXXXX", + messagingSenderId: "XXXXXXXXXXX", + appId: "XXXXXXXXXXX", + measurementId: "XXXXXXXXXXX" + }; + + // Initialize Firebase + firebase.initializeApp(firebaseConfig); + firebase.analytics(); + +// Reference messages collection +var messagesRef = firebase.database().ref('Emails'); + +document.getElementById('newsletterForm').addEventListener('submit', submitForm); + +//submit form +function submitForm(e){ + e.preventDefault(); + + // Get values + var email = document.getElementById("email").value; + + // Save message + saveMessage(email); + + // Clear form + document.getElementById('newsletterForm').reset(); +} + +// Save message to firebase +function saveMessage(email){ + var newMessageRef = messagesRef.push(); + newMessageRef.set({ + email:email + }); +} \ No newline at end of file diff --git a/index.html b/index.html index b084061..675b3ba 100644 --- a/index.html +++ b/index.html @@ -825,12 +825,14 @@

Frequently Asked Questions

SUBSCRIBE TO OUR NEWSLETTER

-
- - - - -
+
+
+ + + + +
+
@@ -887,6 +889,14 @@

Contact Us

+ + + + + + +