This commit is contained in:
Jonas Platte
2022-11-10 19:02:25 +01:00
commit f92b5c56ff
6 changed files with 974 additions and 0 deletions

37
index.html Normal file
View File

@@ -0,0 +1,37 @@
<!doctype html>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Secret Santa</title>
<h1>Secret Santa</h1>
<select id="person">
<option selected disabled>Who is drawing?</option>
<option value="Alice">Alice</option>
<option value="Bob">Bob</option>
<option value="Carol">Carol</option>
<option value="Dave">Dave</option>
</select>
<div id="result"></div>
<script>
document.getElementById("person").addEventListener('change', event => {
const options = {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ "person": event.target.value })
};
console.log(options);
fetch("/secret-santa-api/", options)
.then(response => response.text())
.then(text => {
document.getElementById("result").textContent = `Your draw: ${text}`;
});
});
</script>