From a6cd52452e504c23921bb0be32e883b9efd97da7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 3 Oct 2020 13:08:28 +0200 Subject: Frontend fixes --- quotes/public/script.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'quotes/public/script.js') diff --git a/quotes/public/script.js b/quotes/public/script.js index 8132019..a681e6d 100644 --- a/quotes/public/script.js +++ b/quotes/public/script.js @@ -19,19 +19,20 @@ function appendQuote(response) { .getElementById(elem["class"]) .insertAdjacentHTML( "beforeend", - `
  • ${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${ + `
  • ${elem["name"]} ${elem["middlename"] ? elem["middlename"] : ""}${elem["surname"]}: ${ elem["quote"] - }${elem["owner"] ? '[Löschen]
  • ' : ""}`, + }${elem["owner"] ? ' [x]' : ""}`, ); const span = document.querySelector(`li span[data-id="${elem["id"]}"]`); - if (span) span.addEventListener("click", (event) => { - fetch("api/delete/" + event.target.getAttribute("data-id"), { method: "DELETE" }) - .then((response) => response.text()) - .then((response) => { - if (response == "ok") event.target.parentNode.remove(); - }); - }); + if (span) + span.addEventListener("click", (event) => { + fetch("api/delete/" + event.target.getAttribute("data-id"), { method: "DELETE" }) + .then((response) => response.text()) + .then((response) => { + if (response == "ok") event.target.parentNode.remove(); + }); + }); }); } -- cgit v1.2.3