Add pinned today, webhook support and style changes
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
<button id="shuffle-notes" class="shuffle-btn" type="button">Shuffle notes</button>
|
||||
<button id="sort-backlinks" class="shuffle-btn" type="button">Sort by backlinks</button>
|
||||
<button id="sort-created" class="shuffle-btn" type="button">Sort by created date</button>
|
||||
<button id="sort-modified" class="shuffle-btn" type="button">Sort by modified date</button>
|
||||
<button id="jump-current" class="shuffle-btn" type="button">Jump to current note</button>
|
||||
</div>
|
||||
<div id="file-list">{{NAV_ITEMS}}</div>
|
||||
@ -73,6 +74,7 @@
|
||||
const shuffleNotesBtn = document.getElementById("shuffle-notes");
|
||||
const sortBacklinksBtn = document.getElementById("sort-backlinks");
|
||||
const sortCreatedBtn = document.getElementById("sort-created");
|
||||
const sortModifiedBtn = document.getElementById("sort-modified");
|
||||
const jumpCurrentBtn = document.getElementById("jump-current");
|
||||
const fileLinks = Array.from(document.querySelectorAll("#file-list .file-link"));
|
||||
const activeFileLink = document.querySelector("#file-list .file-link.active");
|
||||
@ -151,6 +153,58 @@
|
||||
});
|
||||
reorderLinks(links);
|
||||
});
|
||||
|
||||
sortModifiedBtn.addEventListener("click", function () {
|
||||
const links = Array.from(fileList.querySelectorAll(".file-link"));
|
||||
links.sort(function (a, b) {
|
||||
const aTs = Number.parseInt(a.getAttribute("data-modified-ts") || "0", 10);
|
||||
const bTs = Number.parseInt(b.getAttribute("data-modified-ts") || "0", 10);
|
||||
if (aTs !== bTs) {
|
||||
return bTs - aTs;
|
||||
}
|
||||
const aKey = a.getAttribute("data-search") || "";
|
||||
const bKey = b.getAttribute("data-search") || "";
|
||||
return aKey.localeCompare(bKey);
|
||||
});
|
||||
reorderLinks(links);
|
||||
});
|
||||
})();
|
||||
|
||||
(function () {
|
||||
document.addEventListener("click", function (e) {
|
||||
const btn = e.target.closest(".webhook-send-btn");
|
||||
if (!btn) return;
|
||||
const file = btn.getAttribute("data-file");
|
||||
const heading = btn.getAttribute("data-heading");
|
||||
btn.disabled = true;
|
||||
btn.textContent = "Sending\u2026";
|
||||
fetch("/webhook", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ file: file, heading: heading }),
|
||||
})
|
||||
.then(function (resp) { return resp.json(); })
|
||||
.then(function (data) {
|
||||
if (data.ok) {
|
||||
btn.textContent = "Sent!";
|
||||
btn.classList.add("webhook-sent");
|
||||
} else {
|
||||
btn.textContent = "Error: " + (data.error || "unknown");
|
||||
btn.classList.add("webhook-error");
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
btn.textContent = "Failed";
|
||||
btn.classList.add("webhook-error");
|
||||
})
|
||||
.finally(function () {
|
||||
setTimeout(function () {
|
||||
btn.disabled = false;
|
||||
btn.textContent = "Start work";
|
||||
btn.classList.remove("webhook-sent", "webhook-error");
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user