mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-22 20:10:40 +03:00
54 lines
No EOL
1.4 KiB
Text
54 lines
No EOL
1.4 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<%- include("extra/meta", {title: "Create thread!" }) %>
|
|
|
|
<body style="text-align: center;">
|
|
<link rel="stylesheet" href="/css/create_thread.css" />
|
|
|
|
<%- include("extra/navbar") %>
|
|
|
|
|
|
<form>
|
|
<h2 class="title" style="align-self: baseline;">Title:</h2>
|
|
<input name="title" maxlength="128" class="input" required></input>
|
|
<h2 class="title" style="align-self: baseline;">Content:</h2>
|
|
<textarea rows="4" cols="50" maxlength="1024" name="content" class="input" required></textarea>
|
|
<h2 class="title" style="align-self: baseline;">Category:</h2>
|
|
|
|
<select name="category">
|
|
<% for (const category of categories) { %>
|
|
<option value="<%= category.id %>"><%= category.name %></option>
|
|
<% } %>
|
|
</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"),
|
|
content: data.get("content"),
|
|
category: data.get("category")
|
|
});
|
|
|
|
|
|
if (response)
|
|
window.location.href = "/threads/" + response.id;
|
|
|
|
|
|
});
|
|
</script>
|
|
<%- include("extra/footer") %>
|
|
|
|
</body>
|
|
|
|
</html> |