To support note deletion

This commit is contained in:
2024-06-24 15:43:03 -04:00
parent d24c304c97
commit fbf5ac564a
9 changed files with 33 additions and 17 deletions

View File

@ -302,7 +302,7 @@ function showSave() {
/**
* Function to discard the note by clearing all input fields and closing the menu.
*/
function discardNote() {
function deleteNote(noteId, link) {
document.querySelector('#noteTitle').value = '';
document.querySelector('#speaker').value = 0;
document.querySelector('#series').value = 0;
@ -313,23 +313,26 @@ function discardNote() {
document.querySelector('#noteDate').value = '';
document.querySelector('#noteId').value = '';
fetch('/index.php/discard-note', {
var row = link.parentElement.parentElement;
fetch('/index.php/delete-note', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'id': document.querySelector('#noteId').value
'id': noteId
})
.then(response => response.json())
.then(data => {
if (data.msg == 'deleted') {
alert('Note deleted.');
}
})
});
})
.then(response => response.json())
.then(data => {
if (data.msg != 'deleted') {
return;
}
openRef();
alert('Note deleted.');
row.remove();
});
}
function newSpeaker() {

File diff suppressed because one or more lines are too long