blob: 914f910f8362de543bf47ea28116d731551b9444 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
const list = document.getElementById("list");
fetch("api/prediction")
.then((r) => r.json())
.then((r) => {
r.forEach((d) => {
const teacherList = list.querySelector(`div[data-teacher="${d.tid}"]`);
if (teacherList) {
const ul = teacherList.querySelector("ul");
addLI(d, ul);
} else {
const div = document.createElement("div");
div.dataset.teacher = `${d.tid}`;
const h3 = document.createElement("h3");
const email = `${san(d.tname)}.${san(d.tsur)}@rbs-ulm.de`;
h3.textContent = `${d.tname} ${d.tsur}: ${email}`;
const ul = document.createElement("ul");
addLI(d, ul);
div.append(h3, ul);
list.appendChild(div);
}
});
});
function addLI(d, ul) {
const li = document.createElement("li");
li.textContent = `${d.uname} ${d.umid || ""} ${d.usur} (${d.class})`;
ul.appendChild(li);
}
const san = (name) =>
name.toLowerCase().replace(/ß/g, "ss").replace(/ä/g, "ae").replace(/ü/g, "ue").replace(/ö/g, "oe");
|