s1llyw0rdz/web/handler/html/create_status.html
2021-11-28 08:40:11 +01:00

49 lines
No EOL
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>status cafe</title>
<meta name="description" content="your friends' updates">
<style>
body {
background-color: lightblue;
font-family: Verdana;
}
</style>
</head>
<body>
<main>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
{{ end }}
{{ if .flash }}
<p>{{ .flash }}</p>
{{ end }}
<form action="/add?silent=1" method="post" name="update-status">
<div class="field">
<textarea name="content" placeholder="What's new?" required style="width: 100%; box-sizing: border-box; height: 120px" autofocus></textarea>
</div>
<br>
<input type="submit" value="Submit">
</form>
</main>
</div>
<script>
document.forms["update-status"].onsubmit = function (event) {
event.preventDefault();
fetch("/add?silent=1", {
method: "POST",
body: new FormData(document.forms["update-status"])
})
.then(response => response.ok)
.then(submitted => {
if (submitted) {
window.close()
window.location = "/"
}
})
}
</script>
</body>
</html>