-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (35 loc) · 1.18 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "xxxxx",
authDomain: "themasstracker.firebaseapp.com",
databaseURL: "https://themasstracker.firebaseio.com",
projectId: "themasstracker",
storageBucket: "themasstracker.appspot.com",
messagingSenderId: "383038531913",
appId: "1:383038531913:web:4361a9f73608f81ef25298"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Reference contactInfo collections
let contactInfo = firebase.database().ref("infos");
// Listen for a submit
document.querySelector(".contact-form").addEventListener("submit", submitForm);
function submitForm(e) {
e.preventDefault();
// Get input Values
let name = document.querySelector("#name").value;
let email = document.querySelector("#email").value;
let message = document.querySelector("#message").value;
console.log(name, email, message);
saveContactInfo(name, email, message);
document.querySelector(".contact-form").reset();
}
// Save infos to Firebase
function saveContactInfo(name, email, message) {
let newContactInfo = contactInfo.push();
newContactInfo.set({
name: name,
email: email,
message: message
});
}