Skip to content

Commit

Permalink
staff list
Browse files Browse the repository at this point in the history
  • Loading branch information
ear1grey committed Sep 23, 2024
1 parent 4349b8c commit eebf757
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/staff/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

<img id=logo src="../logo.svg" alt="University of Portsmouth">

<nav class="top-nav">
<p>Filter by Staff:</p>
</nav>

<header>
<h1>Loading&hellip;</h1>
</header>
Expand Down
26 changes: 26 additions & 0 deletions docs/staff/staff.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ function sortEvents() {
}
}

const allStaff = new Set();



function createEvent(event) {
const eventElem = document.querySelector('#event-template').content.cloneNode(true).firstElementChild;
Expand Down Expand Up @@ -114,15 +117,21 @@ function createEvent(event) {

staffElem.textContent = 'Staff: ';
eventElem.dataset.staff = JSON.stringify(event.staff);


for (const staff of event.staff) {
const parts = staff.toLowerCase().split(' ');
staffElem.innerHTML += `<a href="./?staff=${parts.join('_')}">${staff}</a>, `;
allStaff.add(staff);
}
staffElem.innerHTML = staffElem.innerHTML.replace(/(^[,\s]+)|([,\s]+$)/g, '');
}

if (event.ugpts) {
eventElem.dataset.staff = JSON.stringify(data.staff.ugpts);
for (const staff of data.staff.ugpts) {
allStaff.add(staff);
}
}

eventElem.dataset.time = event.time;
Expand Down Expand Up @@ -224,10 +233,27 @@ function allEventsHidden(dayElem) {
return true;
}

function populateStaffList() {
// add all staff to top-nav
const staffList = document.querySelector('.top-nav');

const showStaff = Array.from(allStaff).sort();

for (const staff of showStaff ) {
console.log(staff);

const staffElem = document.createElement('li');
staffElem.innerHTML = `<a href="./?staff=${staff.replaceAll(' ', '_')}">${staff}</a>`;
staffList.append(staffElem);
}

}

async function main() {
await fetchData();
setTitle();
populateDays();
populateStaffList();
const params = new URLSearchParams(window.location.search);
if (params.has('staff')) {
const staffName = params.get('staff').replaceAll('_', ' ').toLowerCase();
Expand Down

0 comments on commit eebf757

Please sign in to comment.