akf-forum/themes/common/views/create_category.ejs

49 lines
1.4 KiB
Text
Raw Normal View History

2022-09-09 20:47:28 +03:00
<!DOCTYPE html>
<html lang="en">
<%- include(dataset.getFile(dataset.theme.codename +"/views/extra/meta"), {title: "Create Category!" }) %>
2022-09-09 20:47:28 +03:00
<body>
<%- include(dataset.getFile(dataset.theme.codename +"/views/extra/navbar")) %>
<link rel="stylesheet" href="/libs/simplemde/simplemde.min.css">
<script src="/libs/simplemde/simplemde.min.js"></script>
2022-09-09 20:47:28 +03:00
<form class="post">
2022-09-09 20:47:28 +03:00
<h2 class="title" style="align-self: baseline;">Name:</h2>
2022-09-17 20:25:19 +03:00
<input name="name" class="input" required ></input>
2022-09-09 20:47:28 +03:00
<h2 class="title" style="align-self: baseline;">Description:</h2>
<div style="width: 100%;">
<textarea id="textarea"></textarea>
</div>
2022-09-09 20:47:28 +03:00
<button class="btn-primary" style="width:100%" type="submit">Create Category!</button>
</form>
<script src="/js/editor.js"></script>
2022-09-09 20:47:28 +03:00
<script type="module">
const simplemde = editor("category-create");
2022-09-09 20:47:28 +03:00
import request from "../../js/request.js";
document.addEventListener("submit", async e => {
e.preventDefault();
const data = new FormData(e.target);
2022-09-17 00:51:52 +03:00
2022-09-09 20:47:28 +03:00
const response = await request("/api/categories/", "POST", {
name: data.get("name"),
desp: simplemde.value()
2022-09-09 20:47:28 +03:00
});
simplemde.clearAutosavedValue();
2022-09-09 20:47:28 +03:00
if (response)
window.location.href = "/categories/" + response.id;
});
</script>
<%- include(dataset.getFile(dataset.theme.codename +"/views/extra/footer")) %>
2022-09-17 00:51:52 +03:00
</body>
2022-09-09 20:47:28 +03:00
2022-09-17 00:51:52 +03:00
</html>