-
Notifications
You must be signed in to change notification settings - Fork 2
/
Index.html
139 lines (135 loc) · 3.94 KB
/
Index.html
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form with Azure</title>
<script type="text/javascript">
async function sendEmail() {
const data = {
name: document.getElementById("name").value,
email: document.getElementById("email").value,
message: document.getElementById("message").value
};
try {
showLoader();
const response = await fetch("https://contactformwithazure.azurewebsites.net/api/SendEmails", {
method: "POST",
body: JSON.stringify(data),
headers: { "Content-Type": "application/json" },
});
if (!response.ok) {
throw new Error("Network response was not ok");
}
setTimeout(location.reload(), 5000);
} catch (error) {
console.error("There was an error submitting the form", error);
}
}
function showLoader() {
document.getElementById("loader").style.display = "block";
document.getElementById("emailForm").style.display = "none";
}
</script>
<style>
h1 {
text-align: center;
}
form {
display: flex;
flex-direction: column;
align-items: left;
width: 100%;
max-width: 600px;
margin: 0 auto;
}
label {
font-weight: bold;
margin-bottom: 0.5rem;
}
input,
textarea {
border: none;
border-radius: 0.5rem;
padding: 1rem;
margin-bottom: 0.1rem;
outline: auto;
}
#loader {
display: none;
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 120px;
height: 120px;
margin: -76px 0 0 -76px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}
@-webkit-keyframes animatebottom {
from {
bottom: -100px;
opacity: 0
}
to {
bottom: 0px;
opacity: 1
}
}
@keyframes animatebottom {
from {
bottom: -100px;
opacity: 0
}
to {
bottom: 0;
opacity: 1
}
}
</style>
</head>
<body>
<h1>Contact Form</h1>
<div id="loader"></div>
<form id="emailForm" onsubmit="sendEmail();return false;">
<br />
<label>Name:</label>
<input type="text" id="name" placeholder="name" required" />
<br />
<label>Email:</label>
<input type="email" id="email" placeholder="email" required" />
<br />
<label>Message:</label>
<textarea placeholder="message" id="message" required"></textarea>
<br />
<button type="submit">Submit</button>
</form>
</body>
</html>