-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmake-hell.js
41 lines (32 loc) · 1007 Bytes
/
make-hell.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
window.addEventListener("load", function () {
document
.getElementById("passwordPurgatory")
.addEventListener("submit", function (e) {
e.preventDefault();
let password = document.getElementById("password").value;
let feedback = document.getElementById("response");
submitHell(password, feedback);
return false;
});
});
async function submitHell(password, feedback) {
// Hide the existing response
feedback.style.display = "none";
let url = `https://api.passwordpurgatory.com/make-hell?password=${encodeURIComponent(
password
)}`;
let headers = new Headers({
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
});
let params = {
headers,
mode: "cors",
};
let response = await fetch(url, params);
let json = await response.json();
// Add a visible delay before showing the response
setTimeout(function () {
feedback.textContent = json.message;
feedback.style.display = "block";
}, 900);
}