mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 11:02:28 +08:00
36 lines
971 B
TypeScript
36 lines
971 B
TypeScript
import "../stylesheets/bootstrap.scss";
|
|
|
|
/**
|
|
* Fetch note with given ID from backend
|
|
*
|
|
* @param noteId of the given note to be fetched. If false, fetches current note.
|
|
*/
|
|
async function fetchNote(noteId: string | null = null) {
|
|
if (!noteId) {
|
|
noteId = document.body.getAttribute("data-note-id");
|
|
}
|
|
|
|
const resp = await fetch(`api/notes/${noteId}`);
|
|
|
|
return await resp.json();
|
|
}
|
|
|
|
document.addEventListener(
|
|
"DOMContentLoaded",
|
|
() => {
|
|
const toggleMenuButton = document.getElementById("toggleMenuButton");
|
|
const layout = document.getElementById("layout");
|
|
|
|
if (toggleMenuButton && layout) {
|
|
toggleMenuButton.addEventListener("click", () => layout.classList.toggle("showMenu"));
|
|
}
|
|
},
|
|
false
|
|
);
|
|
|
|
// workaround to prevent webpack from removing "fetchNote" as dead code:
|
|
// add fetchNote as property to the window object
|
|
Object.defineProperty(window, "fetchNote", {
|
|
value: fetchNote
|
|
});
|