blob: 546ee1bcc165d054bda94213f2cb5908b4a7964b (
plain) (
blame)
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
|
<!-- localization-template -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="manifest" href="manifest.json">
<title>SyncTube</title>
<link rel="icon" href="img/favicon.svg" type="image/svg+xml">
<link id="usertheme" href="css/des.css" rel="stylesheet">
<link id="usertheme" href="css/setup.css" rel="stylesheet">
<link id="customcss" href="css/custom.css" rel="stylesheet">
</head>
<body>
<main class="setup">
<img class="welcome-image" src="img/welcome.webp" alt="Welcome to Dohee Cinema">
<h1 class="setup-title">Welcome to the Dohee Cinema</h1>
<p>put in the password for entry</p>
<form id="setup-form" class="setup-form">
<input type="password" name="password" placeholder="Password">
<div id="form-errors" class="form-errors"></div>
<button type="submit">Enter</button>
</form>
</main>
<script>
const formElement = document.getElementById("setup-form");
const errorsElement = document.getElementById("form-errors");
formElement.addEventListener("submit", function (e) {
e.preventDefault();
const { password } = formElement.elements;
const payload = {
password: password.value,
};
fetch("/gate", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) })
.then(res => res.json())
.then(response => handleResponse(response))
.catch(() => handleResponse(null));
}, true);
function handleResponse(response) {
if (response && response.success === true) {
window.location.href = "/";
return;
}
showErrors(errorsElement, ["Incorrect password. Not cool man"]);
}
function showErrors(container, errors) {
container.innerHTML = "";
errors.forEach((message) => {
const errorEl = document.createElement("div");
errorEl.innerText = message;
container.appendChild(errorEl);
});
}
</script>
</body>
</html>
|