(async function () {
const fetched = await fetch("https://loc.sh/int/directory");
const data = await fetched.json();
const table = document.getElementById("directory");
let completed = 0;
document.getElementById("loading").innerText += ` ${completed}/${
data.length - 1
}`;
for (const info of data.sort((a, b) => a.name.localeCompare(b.name))) {
completed++;
document.getElementById(
"loading"
).innerText = `Loading... | ${completed}/${data.length}`;
const fetched2 = await fetch(
`https://loc.sh/int/directory?id=${info.userID}`
);
const user = await fetched2.json();
if (!user.staff) continue;
const row = table.insertRow();
let name = `${user.username}`;
row.insertCell().innerHTML = ` ${name} ${info.isManager ? " [k]" : ""}`;
let departmentAndTitle = "";
if (info.title && info.dept) {
departmentAndTitle += `${info.title}, ${info.dept}`;
} else if (info.dept) {
departmentAndTitle += info.dept;
}
row.insertCell().innerText = departmentAndTitle;
row.insertCell().innerHTML = info.emailAddress
? `${info.emailAddress} `
: "";
let rankings = "