2022-09-09 20:47:28 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2023-05-25 17:23:31 +03:00
|
|
|
<%- include(dataset.getFile(dataset.theme.codename +"/views/extra/meta"), {title: "Create Category!" }) %>
|
2022-09-09 20:47:28 +03:00
|
|
|
|
|
|
|
<body>
|
2023-05-25 17:23:31 +03:00
|
|
|
<%- include(dataset.getFile(dataset.theme.codename +"/views/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>
|
2023-05-25 17:23:31 +03:00
|
|
|
<%- 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>
|