akf-forum/views/create_thread.ejs

52 lines
1.4 KiB
Plaintext
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
2022-08-26 20:22:46 +03:00
<%- include("extra/meta", {title: "Create thread!" }) %>
<body style="text-align: center;">
2022-08-27 10:31:16 +03:00
<link rel="stylesheet" href="/css/create_thread.css" />
<%- include("extra/navbar") %>
<form>
2022-09-17 00:27:38 +03:00
<h2 class="title"style="align-self: baseline;">Title:</h2>
<input name="title" maxlength="128" class="input" required></input>
2022-08-26 20:57:55 +03:00
<h2 class="title" style="align-self: baseline;">Content:</h2>
2022-09-17 00:27:38 +03:00
<textarea rows="4" cols="50" maxlength="1024" name="content" class="input" required></textarea>
2022-09-09 20:55:05 +03:00
<h2 class="title" style="align-self: baseline;">Category:</h2>
2022-09-09 20:47:28 +03:00
<select name="category">
<% for (const category of categories) { %>
2022-09-09 20:55:05 +03:00
<option value="<%= category.id %>"><%= category.name %></option>
2022-09-09 20:47:28 +03:00
<% } %>
</select>
<button class="btn-primary" style="width:100%" type="submit">Create Thread!</button>
</form>
<script type="module">
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
e.preventDefault();
const form = e.target;
const data = new FormData(form);
const response = await request("/api/threads/", "POST", {
title: data.get("title"),
2022-09-09 20:47:28 +03:00
content: data.get("content"),
2022-09-09 20:55:05 +03:00
category: data.get("category")
});
if (response)
window.location.href = "/threads/" + response.id;
});
</script>
</body>
</html>