From a6cd52452e504c23921bb0be32e883b9efd97da7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 3 Oct 2020 13:08:28 +0200 Subject: Frontend fixes --- app.js | 4 ++-- mottovote/public/script.js | 10 +++++----- overview/public/index.html | 4 ++-- quotes/public/script.js | 19 ++++++++++--------- quotes/public/style.css | 10 ++++++++++ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/app.js b/app.js index 8200713..fcb7a8a 100644 --- a/app.js +++ b/app.js @@ -21,7 +21,7 @@ app.use( resave: false, saveUninitialized: true, cookie: { secure: false }, - }) + }), ); app.use(express.urlencoded({ extended: true })); @@ -29,7 +29,7 @@ app.use(express.json()); app.use("/", express.static(__dirname + "/overview/public")); app.use("/motto", checkUser, motto); -app.use("/mottovote", mottovote); +app.use("/mottovote", checkUser, mottovote); app.use("/quotes", checkUser, quotes); app.use("/poll", checkUser, poll); app.use("/auth", auth); diff --git a/mottovote/public/script.js b/mottovote/public/script.js index 05ca940..2a9f602 100644 --- a/mottovote/public/script.js +++ b/mottovote/public/script.js @@ -8,17 +8,17 @@ async function get() { for (const motto of mottos) { const row = document.createElement("div"); const id = motto.id; - + for (let i = 0; i < maxVotes; i++) { const cb = document.createElement("input"); cb.type = "checkbox"; cb.value = id; - cb.checked = motto.votes && motto.votes-- > 0 + cb.checked = motto.votes && motto.votes-- > 0; row.append(cb); } - + const text = document.createElement("span"); - text.textContent = `${motto.name} ${motto.description ? "-" : ""} ${motto.description}` + text.textContent = `${motto.name} ${motto.description ? "-" : ""} ${motto.description}`; row.append(text); window.vote.appendChild(row); @@ -50,4 +50,4 @@ function addListeners() { if (res === "ok") location.reload(); else alert(res); }); -} \ No newline at end of file +} diff --git a/overview/public/index.html b/overview/public/index.html index 980e48e..98aa670 100644 --- a/overview/public/index.html +++ b/overview/public/index.html @@ -25,10 +25,10 @@ nutzen könnt:

Falls ihr uns bei der Entwicklung helfen wollt, Fehler gefunden habt oder Fragen an uns habt, könnt ihr 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(); + }); + }); }); } diff --git a/quotes/public/style.css b/quotes/public/style.css index aac80ac..4ead1a1 100644 --- a/quotes/public/style.css +++ b/quotes/public/style.css @@ -34,6 +34,16 @@ button:not([type="submit"]) { font-size: 15px; } +li { + word-wrap: break-word; +} + +span { + float: right; + color: red; + cursor: pointer; +} + input, button, select { -- cgit v1.2.3