From 99acb1bd2a32c347979b2aaec588cc491033811f Mon Sep 17 00:00:00 2001 From: Anatoly Date: Sat, 23 Oct 2021 17:59:50 +0300 Subject: [PATCH] Added a delete function --- delete.php | 3 +++ index.php | 6 +++--- main.js | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 delete.php diff --git a/delete.php b/delete.php new file mode 100644 index 0000000..28ff122 --- /dev/null +++ b/delete.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/index.php b/index.php index a5dacb8..67e2444 100644 --- a/index.php +++ b/index.php @@ -103,7 +103,7 @@ $filesize = number_format($filesize, 2, ",", " ") . $msr; } - echo "\n"; } echo "
\n"; - echo "
\n"; } else { if ($ext == "mp4") { echo "📼"; @@ -142,8 +141,9 @@ if ($clr == " list-group-item-warning") { echo "
\n"; } - echo "\n"; } + echo "🗑"; + echo "\n"; } } closedir($dh); diff --git a/main.js b/main.js index 0e6b2c8..6cd0ffd 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,17 @@ $(document).on('click', 'div.dropdown-menu', function (e) { e.stopPropagation(); +}); + +const buttons = document.querySelectorAll('.delete-button') +buttons.forEach((button) => { + button.addEventListener("click", async function(event) { + const response = await fetch("delete.php", { + method: 'POST', + headers: { + 'Accept': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/x-www-form-urlencoded' + }, + body: `file=${event.target.dataset.file}` + }); + }) }); \ No newline at end of file