From 9e04cd43b03b7c178ef1ef8e8047017a1c5f07cc Mon Sep 17 00:00:00 2001 From: Musselman Date: Wed, 29 Nov 2023 23:50:13 -0600 Subject: [PATCH] Move delete functio javascript back into html The {{.Filename}} does not propogate to the javascript files --- static/build/editor.js | 27 --------------------------- templates/edit.html | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/static/build/editor.js b/static/build/editor.js index a887a5e..eb7f619 100644 --- a/static/build/editor.js +++ b/static/build/editor.js @@ -88,12 +88,6 @@ function confirmOverwrite() { } } -function confirmDeletion() { - if (confirm("Are you sure you want to delete {{.Filename}}?")) { - const filename = "{{.Filename}}"; - deleteFile(filename); - } -} // Function to focus on the editor when body is clicked function focusOnEditor() { @@ -241,27 +235,6 @@ function addVideo() { } } -function deleteFile(filename) { - // Send a POST request to the server to delete the specified file - fetch("/delete", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ files: [filename] }), - }) - .then(response => { - if (response.ok) { - window.location.replace("/home"); - } else { - // Handle the error, e.g., display an error message - console.error("Error deleting file"); - } - }) - .catch(error => { - console.error("Error deleting file:", error); - }); -} function insertLink() { var url = prompt('Enter the URL:'); diff --git a/templates/edit.html b/templates/edit.html index 9b2bbb4..2fc65f9 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -11,7 +11,7 @@ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> - @@ -95,7 +95,7 @@ disabled> - + @@ -166,13 +166,43 @@ - +