2022-09-09 20:47:28 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<%- include("extra/meta", {title: "Create Category!" }) %>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<%- include("extra/navbar") %>
|
2023-05-24 15:40:09 +03:00
|
|
|
<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
|
|
|
|
2023-05-24 15:40:09 +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>
|
2023-05-24 15:40:09 +03:00
|
|
|
<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>
|
2023-05-24 15:40:09 +03:00
|
|
|
<script src="/js/editor.js"></script>
|
2022-09-09 20:47:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
<script type="module">
|
2023-05-24 15:40:09 +03:00
|
|
|
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"),
|
2023-05-24 15:40:09 +03:00
|
|
|
desp: simplemde.value()
|
2022-09-09 20:47:28 +03:00
|
|
|
});
|
2023-05-24 15:40:09 +03:00
|
|
|
|
|
|
|
simplemde.clearAutosavedValue();
|
2022-09-09 20:47:28 +03:00
|
|
|
|
|
|
|
if (response)
|
|
|
|
window.location.href = "/categories/" + response.id;
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
2022-09-17 00:51:52 +03:00
|
|
|
<%- include("extra/footer") %>
|
|
|
|
|
|
|
|
</body>
|
2022-09-09 20:47:28 +03:00
|
|
|
|
2022-09-17 00:51:52 +03:00
|
|
|
</html>
|