From c252e76dd665ddd0cfa84ffdaa26fb52f0796600 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Fri, 2 Oct 2020 13:58:22 +0200
Subject: Added oisjgoiesjgoseijgf
---
quotes/index.js | 2 +-
quotes/public/index.html | 11 ++++++++++-
quotes/public/script.js | 24 +++++++++++++++++-------
quotes/public/style.css | 12 ++++++++++++
4 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/quotes/index.js b/quotes/index.js
index c125548..ad9fa97 100644
--- a/quotes/index.js
+++ b/quotes/index.js
@@ -22,7 +22,7 @@ app.post("/api/add", checkUser, async (req, res) => {
app.get("/api/list", checkUser, async (req, res) => {
const quotes = await db.query(
- "SELECT quotes.id, name, middlename, surname, quote FROM quotes INNER JOIN users AS a ON author_id = a.id ORDER BY name"
+ "SELECT q.id, a.name, a.middlename, a.surname, q.quote, c.name AS class FROM quotes AS q INNER JOIN users AS a ON author_id = a.id INNER JOIN class AS c ON a.class_id = c.id ORDER BY a.name"
);
res.json(quotes);
});
diff --git a/quotes/public/index.html b/quotes/public/index.html
index 6f7665c..32a46ec 100644
--- a/quotes/public/index.html
+++ b/quotes/public/index.html
@@ -26,7 +26,16 @@
-
+
+
+
+
+
+
+
+
+
+
diff --git a/quotes/public/script.js b/quotes/public/script.js
index 74f74df..2c112e4 100644
--- a/quotes/public/script.js
+++ b/quotes/public/script.js
@@ -1,5 +1,4 @@
const dropdown = document.getElementById("author");
-const quotes = document.getElementById("quotes");
dropdown.insertAdjacentHTML("beforeend", '');
@@ -16,12 +15,14 @@ function appendOption(response) {
function appendQuote(response) {
response.forEach((elem) => {
- quotes.insertAdjacentHTML(
- "beforeend",
- `${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${
- elem["quote"]
- }`
- );
+ document
+ .getElementById(elem["class"])
+ .insertAdjacentHTML(
+ "beforeend",
+ `${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${
+ elem["quote"]
+ }`
+ );
});
}
@@ -32,3 +33,12 @@ fetch("/auth/api/list")
fetch("/quotes/api/list")
.then((response) => response.json())
.then((response) => appendQuote(response));
+
+const classes = ["TGI13.1", "TGI13.2", "TGM13.1", "TGM13.2", "TGTM13.1"];
+classes.forEach((clazz) => {
+ document.getElementById("open_" + clazz).addEventListener("click", () => {
+ const ul = document.getElementById(clazz);
+ if (ul.style.display === "none") ul.style.display = "block";
+ else ul.style.display = "none";
+ });
+});
diff --git a/quotes/public/style.css b/quotes/public/style.css
index 2c9c695..aac80ac 100644
--- a/quotes/public/style.css
+++ b/quotes/public/style.css
@@ -22,6 +22,18 @@ div {
background: white;
}
+button:not([type="submit"]) {
+ background-color: #eee;
+ color: #444;
+ cursor: pointer;
+ padding: 18px;
+ width: 100%;
+ border: none;
+ text-align: left;
+ outline: none;
+ font-size: 15px;
+}
+
input,
button,
select {
--
cgit v1.2.3