-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
51 lines (43 loc) · 1.39 KB
/
main.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
44
45
46
47
48
49
50
51
document.addEventListener("DOMContentLoaded", function () {
var elems = document.querySelectorAll(".fixed-action-btn");
var instances = M.FloatingActionButton.init(elems, options);
instance.open();
});
// Or with jQuery
$(document).ready(function () {
$(".fixed-action-btn").floatingActionButton();
});
var firebaseConfig = {
apiKey: "AIzaSyB6TR6PmXug4xA5sky2S7CCvmdT-PYvR-o",
authDomain: "loginform-79ccd.firebaseapp.com",
databaseURL: "https://loginform-79ccd.firebaseio.com",
projectId: "loginform-79ccd",
storageBucket: "loginform-79ccd.appspot.com",
messagingSenderId: "395311633462",
appId: "1:395311633462:web:f2cbcbcb1171e90588f497",
measurementId: "G-5JC1QY75HS"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const db = firebase.database().ref('message');
document.getElementById('contactForm').addEventListener('submit', submitForm)
function submitForm(e) {
e.preventDefault();
var name = getInputVal('name');
var email = getInputVal('email');
var phone = getInputVal('phone');
saveMessage(name, email, phone);
document.querySelector('.alert').style.display = 'block';
document.getElementById('contactForm').reset();
}
function getInputVal(id) {
return document.getElementById(id).value;
}
function saveMessage(name, email, phone) {
var newMessageRef = db.push();
newMessageRef.set({
name: name,
email: email,
phone: phone,
});
}