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

View File

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