-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
113 lines (67 loc) · 2.33 KB
/
script.js
File metadata and controls
113 lines (67 loc) · 2.33 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// firebase connect
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAfiR4gh2GUcPv-7-vmJQ7hFG5p8AN4g1E",
authDomain: "contactpage-d0a14.firebaseapp.com",
databaseURL: "https://contactpage-d0a14-default-rtdb.firebaseio.com",
projectId: "contactpage-d0a14",
storageBucket: "contactpage-d0a14.appspot.com",
messagingSenderId: "938480960055",
appId: "1:938480960055:web:25723a7672374cbf9a75b2"
};
// // Initialize Firebase
// const app = initializeApp(firebaseConfig);
// // initialize firebase
firebase.initializeApp(firebaseConfig);
// // reference your database
var ContactPageDB = firebase.database().ref("ContactPage");
document.getElementById("ContactPage").addEventListener("submit", submitForm);
function submitForm(e) {
e.preventDefault();
var name = getElementVal("name");
var emailid = getElementVal("emailid");
var msgContent = getElementVal("msgContent");
saveMessages(name, emailid, msgContent);
// enable alert
document.querySelector(".alert").style.display = "block";
// remove the alert
setTimeout(() => {
document.querySelector(".alert").style.display = "none";
}, 2000);
// reset the form
document.getElementById("ContactPage").reset();
}
const saveMessages = (name, emailid, msgContent) => {
var newContactPage = ContactPageDB.push();
newContactPage.set({
name: name,
emailid: emailid,
msgContent: msgContent,
});
};
const getElementVal = (id) => {
return document.getElementById(id).value;
};
// // Email connect
// document.getElementById("ContactPage").addEventListener("submit", submitForm);
// function submitForm(e){
// e.preventDefault()
// Email.send({
// Host:"smtp.gmail.com",
// Username:"",
// Password:"",
// To:"",
// From:document.getElementById("msgContent").value,
// Subject:"this is the subject",
// Body:"And this is the body"
// })
// console.log("kkkkkkkkk")
// // enable alert
// document.querySelector(".alert").style.display = "block";
// // remove the alert
// setTimeout(() => {
// document.querySelector(".alert").style.display = "none";
// }, 2000);
// // reset the form
// document.getElementById("ContactPage").reset();
// }