aboutsummaryrefslogtreecommitdiff
path: root/quotes/public/script.js
diff options
context:
space:
mode:
authorMarvin Borner2020-10-03 13:08:28 +0200
committerMarvin Borner2020-10-03 13:08:28 +0200
commita6cd52452e504c23921bb0be32e883b9efd97da7 (patch)
tree3dd2d07131abbd5138b1a1d973780503004a746c /quotes/public/script.js
parent069e4d5a3bb03d4fcba46ae40657eb55b8581c53 (diff)
Frontend fixes
Diffstat (limited to 'quotes/public/script.js')
-rw-r--r--quotes/public/script.js19
1 files changed, 10 insertions, 9 deletions
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",
- `<li>${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${
+ `<li>${elem["name"]} ${elem["middlename"] ? elem["middlename"] : ""}${elem["surname"]}: ${
elem["quote"]
- }${elem["owner"] ? '<span data-id="' + elem["id"] + '">[Löschen]</span></li>' : ""}`,
+ }${elem["owner"] ? ' <span data-id="' + elem["id"] + '">[x]</span></li>' : ""}`,
);
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();
+ });
+ });
});
}