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