const { invoke } = window.__TAURI__.core; const appWindow = window.__TAURI__.window.getCurrentWindow(); document.querySelector(".titlebar-drag").addEventListener("mousedown", (event) => { if (event.button === 0) appWindow.startDragging(); }); document.querySelector("#minimize-window").addEventListener("click", () => appWindow.minimize()); document.querySelector("#maximize-window").addEventListener("click", () => appWindow.toggleMaximize()); document.querySelector("#close-window").addEventListener("click", () => appWindow.close()); let menuBarToggled = false; let greetInputEl; let greetMsgEl; get_notes_list(); window.addEventListener('contextmenu', (e) => { e.preventDefault(); }); function toggle_menu() { let leftColumn = document.querySelector("#left-column"); let toggleSearch = document.querySelector("#toggle-search"); let searchBar = document.querySelector("#search_bar"); let leftColumnDivider = document.querySelector("#left-column-divider"); let notesListParent = document.querySelector(".notes-list-parent"); let leftBarIcon = document.querySelector("#toggle-left-bar-icon"); let toolBar = document.querySelector(".toolbar"); if (!menuBarToggled) { notesListParent.style.transition = ''; toggleSearch.style.transition = ''; leftColumn.style.minWidth = '4rem'; leftColumn.style.width = '4rem'; leftBarIcon.style.rotate = '90deg'; leftBarIcon.style.fill = 'var(--color-accent)' toggleSearch.style.opacity = '0%'; searchBar.style.display = 'none'; leftColumnDivider.style.display = 'none'; notesListParent.style.opacity = '0%'; toolBar.style.borderBottomLeftRadius = '1rem'; toolBar.style.borderBottomRightRadius = '1rem'; } else { notesListParent.style.transition = '0.25s opacity ease 0.2s'; toggleSearch.style.transition = '0.25s opacity ease 0.2s'; leftBarIcon.style.fill = 'var(--color-icon)' leftBarIcon.style.rotate = '270deg'; leftColumn.style.minWidth = '15rem'; toggleSearch.style.display = 'inline-block'; searchBar.style.display = 'flex'; leftColumnDivider.style.display = 'block'; leftColumn.style.width = '40%'; toggleSearch.style.opacity = '100%'; notesListParent.style.display = 'block'; notesListParent.style.opacity = '100%'; toolBar.style.borderBottomLeftRadius = '0'; toolBar.style.borderBottomRightRadius = '10px'; } menuBarToggled = !menuBarToggled; } function toggle_search() { document.querySelector("#search_input").value = ""; get_notes_list(); } function on_search_input() { get_notes_list(); } async function get_notes_list() { try { let notes = await invoke("get_notes_list", { search: document.querySelector("#search_input").value }); let notes_list = document.querySelector(".notes-list"); notes_list.innerHTML = ""; notes.forEach(note => { let item = document.createElement("div"); item.innerHTML = `

${note.title}

${new Date(note.created_at).toDateString()} ${new Date(note.created_at).toLocaleTimeString().split(':')[0]}:${new Date(note.created_at).toLocaleTimeString().split(':')[1]}

${note.text}

`; notes_list.appendChild(item); }); } catch (error) { console.error("Fehler beim Laden:", error); } }