2023-07-14 17:33:11 -04:00
|
|
|
(async function () {
|
|
|
|
const fetched = await fetch("https://loc.sh/int/directory");
|
2021-07-06 14:19:07 -04:00
|
|
|
const data = await fetched.json();
|
2023-07-14 17:33:11 -04:00
|
|
|
const table = document.getElementById("directory");
|
|
|
|
|
2021-07-06 14:19:07 -04:00
|
|
|
let completed = 0;
|
2023-07-14 17:33:11 -04:00
|
|
|
document.getElementById("loading").innerText += ` ${completed}/${
|
|
|
|
data.length - 1
|
|
|
|
}`;
|
2021-07-06 14:19:07 -04:00
|
|
|
for (const info of data.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
|
|
completed++;
|
2023-07-14 17:33:11 -04:00
|
|
|
document.getElementById(
|
|
|
|
"loading"
|
|
|
|
).innerText = `Loading... | ${completed}/${data.length}`;
|
|
|
|
const fetched2 = await fetch(
|
|
|
|
`https://loc.sh/int/directory?id=${info.userID}`
|
|
|
|
);
|
2021-07-06 14:19:07 -04:00
|
|
|
const user = await fetched2.json();
|
|
|
|
if (!user.staff) continue;
|
2023-07-14 17:33:11 -04:00
|
|
|
|
2021-07-06 14:19:07 -04:00
|
|
|
const row = table.insertRow();
|
|
|
|
let name = `<strong>${user.username}</strong>`;
|
2023-07-14 17:33:11 -04:00
|
|
|
row.insertCell().innerHTML = `<img src="${user.avatarURL}" alt="${user.username}" style="width:30px;height:30px;"> ${name} ${info.isManager ? " [k]" : ""}`;
|
|
|
|
|
|
|
|
let departmentAndTitle = "";
|
2021-07-06 14:19:07 -04:00
|
|
|
if (info.title && info.dept) {
|
|
|
|
departmentAndTitle += `${info.title}, ${info.dept}`;
|
|
|
|
} else if (info.dept) {
|
|
|
|
departmentAndTitle += info.dept;
|
|
|
|
}
|
|
|
|
row.insertCell().innerText = departmentAndTitle;
|
2023-07-14 17:33:11 -04:00
|
|
|
row.insertCell().innerHTML = info.emailAddress
|
|
|
|
? `<a href="mailto:${info.emailAddress}">${info.emailAddress}</a> `
|
|
|
|
: "";
|
2021-07-06 14:19:07 -04:00
|
|
|
|
2023-07-14 17:33:11 -04:00
|
|
|
let rankings = "<ul>";
|
2021-07-06 14:19:07 -04:00
|
|
|
if (info.additionalRoles && info.additionalRoles.length > 0) {
|
|
|
|
for (const rank of info.additionalRoles) {
|
2023-07-14 17:33:11 -04:00
|
|
|
rankings += `<li>${rank}</li>`;
|
|
|
|
}
|
|
|
|
rankings += "</ul>";
|
2021-07-06 14:19:07 -04:00
|
|
|
} else {
|
2023-07-14 17:33:11 -04:00
|
|
|
rankings = "";
|
2021-07-06 14:19:07 -04:00
|
|
|
}
|
|
|
|
}
|
2023-07-14 17:33:11 -04:00
|
|
|
document.getElementById("loading").style.display = "none";
|
|
|
|
table.style.display = "block";
|
2021-07-06 14:19:07 -04:00
|
|
|
})();
|