-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (38 loc) · 1.11 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
44
45
46
47
48
49
50
51
(function () {
const firebaseConfig = {
// REMOVED FOR GITHUB
};
firebase.initializeApp(firebaseConfig);
}());
// Database reference
const dbRefObject = firebase.database().ref('comments');
// Contact Form
function firebasePush(inputName,inputComment){
dbRefObject.push().set(
{
'name': inputName.value,
'comment': inputComment.value
}
);
}
let contactButton = document.getElementById('contact');
let contactExit = document.getElementById('exit');
let contactBox = document.getElementById('contactBox');
const form = document.getElementById('contactForm');
const name = document.getElementById('name');
const comment = document.getElementById('comment');
contactButton.addEventListener('click',()=>{
contactBox.style.display = 'block';
});
contactExit.addEventListener('click',()=>{
contactBox.style.display = 'none';
form.reset();
});
if(form){
form.addEventListener('submit', (event)=>{
contactBox.style.display = 'none';
event.preventDefault();
firebasePush(name,comment);
form.reset();
});
}