Finally finished this, will add more content (cough @matthew)
parent
3529e44e7a
commit
33f37588c8
43
index.html
43
index.html
|
@ -1,30 +1,26 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="author" content="Damian Freeman" />
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<h1>
|
||||
Staff Directory
|
||||
</h1>
|
||||
|
||||
<table class="table" id="directory" style="color: white;">
|
||||
<table class="table" id="directory">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
|
@ -32,11 +28,15 @@
|
|||
<th scope="col">Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
<tbody></tbody>
|
||||
</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... |
|
||||
</div>
|
||||
|
||||
|
@ -44,3 +44,4 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
60
script.js
60
script.js
|
@ -1,52 +1,48 @@
|
|||
// Removed useless bits of code
|
||||
|
||||
(async function() {
|
||||
const fetched = await fetch('https://loc.sh/int/directory');
|
||||
//const fetched = await fetch('http://localhost:3890/int/directory');
|
||||
(async function () {
|
||||
const fetched = await fetch("https://loc.sh/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))
|
||||
const table = document.getElementById("directory");
|
||||
|
||||
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))) {
|
||||
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}`);
|
||||
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();
|
||||
// console.log(user);
|
||||
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]' : ''}`;
|
||||
// row.insertCell().innerText = `${info.userID} | #${user.discriminator}`;
|
||||
let departmentAndTitle = '';
|
||||
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]" : ""}`;
|
||||
|
||||
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> ` : '';
|
||||
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) {
|
||||
for (const rank of info.additionalRoles) {
|
||||
rankings += `<li>${rank}</li>`
|
||||
rankings += `<li>${rank}</li>`;
|
||||
}
|
||||
rankings += '</ul>';
|
||||
rankings += "</ul>";
|
||||
} else {
|
||||
rankings = '';
|
||||
rankings = "";
|
||||
}
|
||||
// row2.insertCell().innerHTML = rankings;
|
||||
}
|
||||
document.getElementById('loading').style.display = "none";
|
||||
document.getElementById('directory').style.display = "block";
|
||||
})();
|
||||
|
||||
document.getElementById("loading").style.display = "none";
|
||||
table.style.display = "block";
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue