From 2b9ad226c6735c674123618dee04fda4177f8d79 Mon Sep 17 00:00:00 2001 From: Damian Freeman Date: Wed, 22 Feb 2023 23:11:31 +0000 Subject: [PATCH] Update script.js --- script.js | 104 ++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/script.js b/script.js index 11b6b93..39e5d89 100644 --- a/script.js +++ b/script.js @@ -1,56 +1,52 @@ -(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 = []; - if (info.pn && info.pn.length > 0) { - for (const nominal of info.pn) { - pn.push(`${nominal}`) - } - name += `, ${pn.join(', ')}`; - } - row.insertCell().innerHTML = `${user.username} ${name}`; - // 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} ` : ''; - row.insertCell().innerText = user.pager ? user.pager : ''; - row.insertCell().innerText = info.extension ? info.extension : ''; +// Removed useless bits of code - row2.insertCell().innerHTML = `${name}`; - let rankings = ''; - } else { - rankings = ''; - } - row2.insertCell().innerHTML = rankings; - } - document.getElementById('loading').style.display = "none"; - document.getElementById('directory').style.display = "block"; -})(); + document.getElementById('loading').style.display = "none"; + document.getElementById('directory').style.display = "block"; + })(); +