aboutsummaryrefslogtreecommitdiff
path: root/quotes/public/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'quotes/public/script.js')
-rw-r--r--quotes/public/script.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/quotes/public/script.js b/quotes/public/script.js
new file mode 100644
index 0000000..3fbc676
--- /dev/null
+++ b/quotes/public/script.js
@@ -0,0 +1,28 @@
+const dropdown = document.getElementById("author");
+
+dropdown.insertAdjacentHTML("beforeend", '<option selected="true" disabled>Author auswählen...</option>');
+
+function append(response) {
+ response.forEach((elem) => {
+ dropdown.insertAdjacentHTML(
+ "beforeend",
+ `<option ${elem["id"]}>${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${
+ elem["surname"]
+ }</option>`
+ );
+ });
+}
+
+// TODO: Add api list endpoint
+// fetch("/auth/api/list")
+// .then((response) => response.json())
+// .then((response) => append(response));
+
+const exampleJson = [
+ { id: 1, name: "Lars", middlename: null, surname: "Baum" },
+ { id: 2, name: "Marvin", middlename: null, surname: "Giraffe" },
+ { id: 3, name: "Dominik", middlename: null, surname: "Apfel" },
+ { id: 4, name: "Daniel", middlename: null, surname: "Torte" },
+];
+
+append(exampleJson);