-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.html
239 lines (239 loc) · 8.24 KB
/
contact.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="Daniel Diril" />
<meta
name="description"
content="Contact author of Mini-car racing - online game"
/>
<meta
name="og:title"
property="og:title"
content="Mini-car racing (contact)"
/>
<title>Mini-car racing ВРАЖЕННЯ</title>
<link rel="stylesheet" href="./styles/contact/styles.css" />
<link rel="icon" href="./icons-and-images/engine2.webp" alt="Icon" />
</head>
<body>
<span
style="
position: absolute;
font-size: 10vh;
cursor: pointer;
color: white;
top: 2vh;
right: 3vh;
"
onclick="window.close()"
>✕</span
>
<noscript>
У вас заборонений Javascript. Перевірте налаштування браузеру
</noscript>
<div class="dialog">Hold your device horizontally</div>
<input type="checkbox" id="checkboxCover" />
<input type="checkbox" id="checkboxPage1" />
<input type="checkbox" id="checkboxPage2" />
<form action="https://formspree.io/f/xeqywdpp" method="POST">
<div class="cover" id="cover">
<div class="front-page" style="transform: translateZ(1px)">
Тут ти заповнюєш анкету інформацією
</div>
<div
class="back-page"
style="transform: rotateY(180deg) translateZ(-1px)"
>
Це буде адресовано автору гри!
</div>
<label for="checkboxCover"></label>
</div>
<div class="page" id="page1">
<div class="front-page">
<label for="checkboxPage1" style="justify-self: end; align-self: end"
>→</label
>
<label for="email" aria-label="Email address"
>Ваша електронна пошта</label
>
<input
aria-label="Email address"
aria-required="true"
id="email"
type="email"
name="email"
placeholder="me@gmail.com"
required
/>
</div>
<div class="back-page">
<label
style="justify-self: start; align-self: end"
for="checkboxPage1"
>←</label
>
<label for="rating">Ваша оцінка з 10 балів</label>
<input
type="number"
name="rating"
min="0"
max="10"
step="0.1"
id="rating"
required
placeholder="10?"
/>
</div>
</div>
<div class="page" id="page2">
<div class="front-page">
<label for="checkboxPage2" style="justify-self: end; align-self: end"
>→</label
>
<label
for="message"
aria-label="Your message"
style="justify-self: center"
>Ваша думка:</label
>
<textarea
maxlength="140"
required
aria-label="Your message"
aria-required="true"
placeholder="Розробник зверне увагу!"
name="message"
id="message"
></textarea>
</div>
<div class="back-page">
<button type="button" aria-label="Send">Надіслати</button>
<script type="text/javascript">
(function () {
const lang = localStorage.getItem("language")
? localStorage.getItem("language")
: "ukrainian";
if (lang == "english") {
document.querySelector("#cover .back-page").textContent =
"It will be sent to the author of game";
document.querySelector("#cover .front-page").textContent =
"Here you should complete an application form";
document.querySelector(
"#page1 .front-page label:nth-of-type(2)"
).textContent = "Your email";
document.querySelector(
"#page1 .back-page label:nth-of-type(2)"
).textContent = "Your rating out of 10";
document.querySelector(
"#page2 .front-page label:nth-of-type(2)"
).textContent = "Your thoughts";
document.querySelector('button[type="button"]').textContent =
"Send";
document.querySelector("textarea").placeholder =
"Developer will pay close attention to it!";
}
})();
</script>
<label
for="checkboxPage2"
style="justify-self: start; align-self: end"
>←</label
>
</div>
</div>
<div class="back-cover"></div>
</form>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
const email = document.getElementById("email"),
rating = document.getElementById("rating"),
message = document.getElementById("message"),
allowedEmailProviders = [
"gmail.com",
"icloud.com",
"yahoo.com",
"hotmail.com",
],
emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
function setEventListeners() {
rating.oninput = function (e) {
visualInputValidation(e, !rating.value == "");
checkRating(e);
rating.value = rating.value;
};
message.onblur = (e) => {
visualInputValidation(e, !message.value == "");
};
email.onblur = (e) => {
const isValid = isEmailValid();
visualInputValidation(e, isValid);
if (!isValid)
alert(
localStorage.language == "ukrainian"
? "Неправильний email"
: "Wrong email"
);
};
document
.querySelector('[type="button"]')
.addEventListener("click", formSubmitting);
document
.getElementById("checkboxPage1")
.addEventListener("input", function (e) {
document
.getElementById("checkboxCover")
.toggleAttribute("disabled", e.target.checked);
});
}
function checkRating(e) {
if (e.target.value > 10 || e.target.value < 0) {
alert("Please enter a rating between 0 and 10");
e.target.value = "";
rating.style.color = "red";
return;
}
const ratingValue = parseInt(rating.value),
goodRatingColor = "green",
badRatingColor = "red",
actualRatingColor =
ratingValue >= 8
? goodRatingColor
: ratingValue <= 2
? badRatingColor
: "black";
if (ratingValue > 10) rating.value = 10;
rating.style.color = actualRatingColor;
}
function visualInputValidation(e, successCondition) {
e.target.style.border = successCondition
? "2px solid green"
: "2px solid red";
}
function formSubmitting() {
const isValid =
isEmailValid() && message.value != "" && rating.value != "";
if (isValid) document.querySelector("form").submit();
else {
alert(
localStorage.language == "ukrainian"
? "Заповніть всі поля"
: "Fill in all fields"
);
}
}
function isEmailValid() {
if (!emailRegex.test(email?.value)) return false;
const provider = email?.value.split("@")[1];
if (!allowedEmailProviders.includes(provider)) return false;
return true;
}
visualInputValidation({ target: rating }, !rating.value == "");
visualInputValidation({ target: message }, !message.value == "");
visualInputValidation({ target: email }, isEmailValid());
setEventListeners();
});
</script>
</body>
</html>