add set current date button to blog editor
This commit is contained in:
parent
0c2aaa0b38
commit
09c09b6310
3 changed files with 14 additions and 0 deletions
|
|
@ -32,6 +32,11 @@ input[type="text"] {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#blogpost button#set-current-date {
|
||||||
|
margin: 0 .5em;
|
||||||
|
padding: .4em .8em;
|
||||||
|
}
|
||||||
|
|
||||||
#blogpost h2 {
|
#blogpost h2 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
const blogID = document.getElementById("blogpost").dataset.id;
|
const blogID = document.getElementById("blogpost").dataset.id;
|
||||||
const titleInput = document.getElementById("title");
|
const titleInput = document.getElementById("title");
|
||||||
const publishDateInput = document.getElementById("publish-date");
|
const publishDateInput = document.getElementById("publish-date");
|
||||||
|
const setCurrentDateBtn = document.getElementById("set-current-date");
|
||||||
const descInput = document.getElementById("description");
|
const descInput = document.getElementById("description");
|
||||||
const mdInput = document.getElementById("markdown");
|
const mdInput = document.getElementById("markdown");
|
||||||
const blueskyActorInput = document.getElementById("bluesky-actor");
|
const blueskyActorInput = document.getElementById("bluesky-actor");
|
||||||
|
|
@ -11,6 +12,13 @@ const visInput = document.getElementById("visibility");
|
||||||
const saveBtn = document.getElementById("save");
|
const saveBtn = document.getElementById("save");
|
||||||
const deleteBtn = document.getElementById("delete");
|
const deleteBtn = document.getElementById("delete");
|
||||||
|
|
||||||
|
setCurrentDateBtn.addEventListener("click", () => {
|
||||||
|
let now = new Date;
|
||||||
|
now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
|
||||||
|
publishDateInput.value = now.toISOString().slice(0, 16);
|
||||||
|
saveBtn.disabled = false;
|
||||||
|
});
|
||||||
|
|
||||||
saveBtn.addEventListener("click", () => {
|
saveBtn.addEventListener("click", () => {
|
||||||
fetch("/api/v1/blog/" + blogID, {
|
fetch("/api/v1/blog/" + blogID, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
<label for="publish-date">Publish Date</label>
|
<label for="publish-date">Publish Date</label>
|
||||||
<input type="datetime-local" name="publish-date" id="publish-date" value="{{.Post.TextPublishDate}}">
|
<input type="datetime-local" name="publish-date" id="publish-date" value="{{.Post.TextPublishDate}}">
|
||||||
|
<button type="button" id="set-current-date">Current date</button>
|
||||||
|
|
||||||
<label for="description">Description</label>
|
<label for="description">Description</label>
|
||||||
<textarea
|
<textarea
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue