Finally finished this, will add more content (cough @matthew)

merge-requests/1/head
Damian 2023-06-15 07:08:44 +00:00
parent 3529e44e7a
commit 33f37588c8
2 changed files with 86 additions and 89 deletions

View File

@ -1,30 +1,26 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en" data-bs-theme="dark">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="author" content="Damian Freeman" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Staff Directory</title> <title>Staff Directory</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/github-dark.min.css" rel="stylesheet"> rel="icon"
href="https://static.libraryofcode.org/library_of_code.png"
/>
<style> <link
body { href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
background-color: #181a1b; rel="stylesheet"
color: #eee; integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM"
} crossorigin="anonymous"
</style> />
</head> </head>
<body> <body>
<div class="container-fluid"> <div class="container-fluid">
<h1> <table class="table" id="directory">
Staff Directory
</h1>
<table class="table" id="directory" style="color: white;">
<thead> <thead>
<tr> <tr>
<th scope="col">Name</th> <th scope="col">Name</th>
@ -32,11 +28,15 @@
<th scope="col">Email</th> <th scope="col">Email</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody></tbody>
</tbody>
</table> </table>
<div id="loading" class="alert alert-info" role="alert" style="display: block;"> <div
id="loading"
class="alert alert-info"
role="alert"
style="display: block"
>
Loading... | Loading... |
</div> </div>
@ -44,3 +44,4 @@
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,52 +1,48 @@
// Removed useless bits of code
(async function () { (async function () {
const fetched = await fetch('https://loc.sh/int/directory'); const fetched = await fetch("https://loc.sh/int/directory");
//const fetched = await fetch('http://localhost:3890/int/directory');
const data = await fetched.json(); const data = await fetched.json();
const table = document.getElementById('directory'); const table = document.getElementById("directory");
//const table2 = document.getElementById('roles');
// users.sort((a, b) => a.firstname.localeCompare(b.firstname))
let completed = 0; let completed = 0;
document.getElementById('loading').innerText += ` ${completed}/${data.length - 1}` document.getElementById("loading").innerText += ` ${completed}/${
data.length - 1
}`;
for (const info of data.sort((a, b) => a.name.localeCompare(b.name))) { for (const info of data.sort((a, b) => a.name.localeCompare(b.name))) {
completed++; completed++;
document.getElementById('loading').innerText = `Loading... | ${completed}/${data.length}`; document.getElementById(
// console.log(info); "loading"
const fetched2 = await fetch(`https://loc.sh/int/directory?id=${info.userID}`); ).innerText = `Loading... | ${completed}/${data.length}`;
//const fetched2 = await fetch(`http://localhost:3890/int/directory?id=${info.userID}`); const fetched2 = await fetch(
`https://loc.sh/int/directory?id=${info.userID}`
);
const user = await fetched2.json(); const user = await fetched2.json();
// console.log(user);
if (!user.staff) continue; if (!user.staff) continue;
const row = table.insertRow();
//const row2 = table2.insertRow();
let name = `<strong>${user.username}</strong>`;
let pn = [];
row.insertCell().innerHTML = `<img src="${user.avatarURL}" alt="${user.username}" style="width:30px;height:30px;"> ${name} ${user.res.isManager ? ' [k]' : ''}`; const row = table.insertRow();
// row.insertCell().innerText = `${info.userID} | #${user.discriminator}`; let name = `<strong>${user.username}</strong>`;
let departmentAndTitle = ''; row.insertCell().innerHTML = `<img src="${user.avatarURL}" alt="${user.username}" style="width:30px;height:30px;"> ${name} ${info.isManager ? " [k]" : ""}`;
let departmentAndTitle = "";
if (info.title && info.dept) { if (info.title && info.dept) {
departmentAndTitle += `${info.title}, ${info.dept}`; departmentAndTitle += `${info.title}, ${info.dept}`;
} else if (info.dept) { } else if (info.dept) {
departmentAndTitle += info.dept; departmentAndTitle += info.dept;
} }
row.insertCell().innerText = departmentAndTitle; row.insertCell().innerText = departmentAndTitle;
row.insertCell().innerHTML = info.emailAddress ? `<a href="mailto:${info.emailAddress}">${info.emailAddress}</a> ` : ''; row.insertCell().innerHTML = info.emailAddress
? `<a href="mailto:${info.emailAddress}">${info.emailAddress}</a> `
: "";
// row2.insertCell().innerHTML = `${name}`; let rankings = "<ul>";
let rankings = '<ul>';
if (info.additionalRoles && info.additionalRoles.length > 0) { if (info.additionalRoles && info.additionalRoles.length > 0) {
for (const rank of info.additionalRoles) { for (const rank of info.additionalRoles) {
rankings += `<li>${rank}</li>` rankings += `<li>${rank}</li>`;
} }
rankings += '</ul>'; rankings += "</ul>";
} else { } else {
rankings = ''; rankings = "";
} }
// row2.insertCell().innerHTML = rankings;
} }
document.getElementById('loading').style.display = "none"; document.getElementById("loading").style.display = "none";
document.getElementById('directory').style.display = "block"; table.style.display = "block";
})(); })();