From eeb4b52192e913bef0da881b5f2fdfa4ec33da35 Mon Sep 17 00:00:00 2001 From: Masahiko AMANO Date: Tue, 7 Jan 2025 14:51:14 +0300 Subject: [PATCH] feat(web): add quote delete action --- web/static/js/quotes.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/web/static/js/quotes.js b/web/static/js/quotes.js index 3920f14..715ca3c 100644 --- a/web/static/js/quotes.js +++ b/web/static/js/quotes.js @@ -51,7 +51,7 @@ function escapedString(str) { function renderBlockQuote(quote) { return ` -
+

${escapedString(quote.text)}

@@ -62,7 +62,7 @@ function renderBlockQuote(quote) { -
@@ -140,6 +140,21 @@ function reload() { load(); } +function quoteDelete(quote_id) { + $.ajax({ + url: `/api/quotes/${quote_id}`, + type: "DELETE", + success: function (resp) { + reload(); + $("#error").addClass("hidden"); + }, + error: function (err) { + $("#error-message").text(err.responseJSON.error); + $("#error").removeClass("hidden"); + }, + }); +} + $(document).on("click", "#btn-add-open", function (e) { now = new Date; now = new Date(now.getTime() - now.getTimezoneOffset() * 60000);