2025-11-07 18:16:14 +00:00
|
|
|
document.addEventListener('readystatechange', () => {
|
|
|
|
|
const newBlogBtn = document.getElementById("create-post");
|
|
|
|
|
if (newBlogBtn) newBlogBtn.addEventListener("click", event => {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
const id = prompt("Enter an ID for this blog post:");
|
|
|
|
|
if (id == null || id == "") return;
|
|
|
|
|
|
|
|
|
|
fetch("/api/v1/blog", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
|
body: JSON.stringify({id})
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.ok) location = "/admin/blogs/" + id;
|
|
|
|
|
else {
|
|
|
|
|
res.text().then(err => {
|
|
|
|
|
alert(err);
|
|
|
|
|
console.error(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
alert("Failed to create release. Check the console for details.");
|
|
|
|
|
console.error(err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|