From 33f37588c88d59b051b4a829f1e98dc03d8f9848 Mon Sep 17 00:00:00 2001 From: Damian Date: Thu, 15 Jun 2023 07:08:44 +0000 Subject: [PATCH] Finally finished this, will add more content (cough @matthew) --- index.html | 81 +++++++++++++++++++++++----------------------- script.js | 94 ++++++++++++++++++++++++++---------------------------- 2 files changed, 86 insertions(+), 89 deletions(-) diff --git a/index.html b/index.html index d4a5db8..042f20c 100644 --- a/index.html +++ b/index.html @@ -1,46 +1,47 @@ - - - - - - - - Staff Directory + + + + - - + Staff Directory - - - -
-

- Staff Directory -

+ - - - - - - - - - - -
NameTitle/DepartmentEmail
+ + + +
+ + + + + + + + + +
NameTitle/DepartmentEmail
- - - -
- + + + +
+ + diff --git a/script.js b/script.js index 5bc3d9f..30ec6de 100644 --- a/script.js +++ b/script.js @@ -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 = `${user.username}`; - let pn = []; - - row.insertCell().innerHTML = `${user.username} ${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 ? `${info.emailAddress} ` : ''; + 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; - // row2.insertCell().innerHTML = `${name}`; - let rankings = ''; - } else { - rankings = ''; - } - // row2.insertCell().innerHTML = rankings; + const row = table.insertRow(); + let name = `${user.username}`; + row.insertCell().innerHTML = `${user.username} ${name} ${info.isManager ? " [k]" : ""}`; + + 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 + ? `${info.emailAddress} ` + : ""; + + let rankings = ""; + } else { + rankings = ""; + } + } + document.getElementById("loading").style.display = "none"; + table.style.display = "block"; +})();