diff options
author | Marvin Borner | 2020-10-01 16:45:33 +0200 |
---|---|---|
committer | Marvin Borner | 2020-10-01 16:45:33 +0200 |
commit | ce6a00fa25bd12774fa86ee384e840565ecf965b (patch) | |
tree | 8a4e2e1d719f7a3a26330dd4b9c46b08b150e779 /quotes/public/script.js | |
parent | f2b0241434ff2ba4e461235a4c5d905487e537d1 (diff) |
Added quotes frontend
Diffstat (limited to 'quotes/public/script.js')
-rw-r--r-- | quotes/public/script.js | 28 |
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); |