mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-20 11:00:41 +03:00
51 lines
No EOL
1.3 KiB
Text
51 lines
No EOL
1.3 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<%- include("extra/header", {title: "Create Thread!" }) %>
|
|
|
|
<body>
|
|
|
|
<%- include("extra/navbar", {user}) %>
|
|
|
|
|
|
|
|
<form>
|
|
<h2>Title:</h2>
|
|
<input name="title"></input>
|
|
|
|
<hr>
|
|
<h2>Content:</h2>
|
|
<textarea rows="4" cols="50" name="content"></textarea>
|
|
|
|
<hr>
|
|
<button class="big" 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")
|
|
});
|
|
|
|
|
|
if (response.result) {
|
|
alert("Thread opened");
|
|
window.location.href = "/threads/" + response.result.id;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
<%- include("extra/footer") %>
|
|
</body>
|
|
|
|
</html> |