akf-forum/views/createThread.ejs

51 lines
1.3 KiB
Text
Raw Normal View History

2022-03-13 16:16:46 +03:00
<!DOCTYPE html>
<html lang="en">
2022-08-26 16:27:29 +03:00
<%- include("extra/old_header", {title: "Create Thread!" }) %>
2022-03-13 16:16:46 +03:00
2022-03-26 23:28:10 +03:00
<body>
2022-03-13 16:16:46 +03:00
2022-08-26 16:27:29 +03:00
<%- include("extra/old_navbar", {user}) %>
2022-03-13 16:16:46 +03:00
2022-03-22 21:25:09 +03:00
<form>
2022-03-26 23:28:10 +03:00
<h2>Title:</h2>
<input name="title"></input>
2022-03-22 21:25:09 +03:00
2022-03-26 23:28:10 +03:00
<hr>
<h2>Content:</h2>
<textarea rows="4" cols="50" name="content"></textarea>
2022-03-22 21:25:09 +03:00
2022-03-26 23:28:10 +03:00
<hr>
2022-08-11 15:36:28 +03:00
<button class="big" type="submit">Create Thread!</button>
2022-03-26 23:28:10 +03:00
</form>
2022-03-22 21:25:09 +03:00
<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) {
alert("Thread opened");
window.location.href = "/threads/" + response.id;
}
});
</script>
2022-08-26 16:27:29 +03:00
<%- include("extra/old_footer") %>
2022-03-26 23:28:10 +03:00
</body>
2022-03-13 16:16:46 +03:00
</html>