const dropdown = document.getElementById("author"); dropdown.insertAdjacentHTML("beforeend", ''); function appendOption(response) { response.forEach((elem) => { dropdown.insertAdjacentHTML( "beforeend", ``, ); }); } function appendQuote(response) { response.forEach((elem) => { document .getElementById(elem["class"]) .insertAdjacentHTML( "beforeend", `
  • ${elem["name"]} ${elem["middlename"] ? elem["middlename"] : " "}${elem["surname"]}: ${ elem["quote"] }
  • `, ); }); } fetch("/auth/api/list?class=all") .then((response) => response.json()) .then((response) => appendOption(response)); 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"; }); });