Skip to content

Commit 93f5a98

Browse files
committed
Mededelingen verbetert. Minder onnodig ophalen van vakken en rooster.
1 parent 00f193d commit 93f5a98

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

schedule.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ async function announcements() {
6666
localStorage.getItem("mededelingenAan") != "true"
6767
)
6868
return;
69-
const url = `https://${schoolName}.zportal.nl/api/v3/announcements?current=true&user=~me&access_token=${accessToken}`;
70-
const response = await fetch(url);
69+
const url = `https://${schoolName}.zportal.nl/api/announcements?current=true&user=~me&fields=start,end,title,text`;
70+
const response = await fetch(url, {
71+
headers: {
72+
Authorization: `Bearer ${accessToken}`,
73+
},
74+
});
7175
if (!response.ok) {
7276
throw new Error(`Error ${response.status}: ${response.statusText}`);
7377
}
@@ -265,7 +269,10 @@ function closeDialog() {
265269
.replace(" monochrome", "")
266270
);
267271
}
268-
if (localStorage.getItem("volVaknaam") == "true") {
272+
if (
273+
localStorage.getItem("volVaknaam") == "true" &&
274+
!localStorage.getItem("subjects")
275+
) {
269276
fetchFullSubjectNames();
270277
}
271278
if (
@@ -277,10 +284,8 @@ function closeDialog() {
277284
fetchSchedule(window.year, window.week);
278285
}
279286
// Nodig voor correct sluiten dialoog
280-
dialogs.forEach((dialog) => {
281-
dialog.addEventListener("close", () => {
282-
closeDialog();
283-
});
287+
document.getElementById("dialog").addEventListener("close", () => {
288+
closeDialog();
284289
});
285290
function viewTrans(func) {
286291
if (!document.startViewTransition) {
@@ -350,11 +355,19 @@ function renderAnnouncements() {
350355
article.classList.add("announcement");
351356

352357
article.innerHTML = `
353-
<h2>${item.title || "Mededeling"}</h2>
354-
<p>${item.text || ""}</p>
358+
<strong>${item.title || "Mededeling"}</strong>
355359
<small>${
356-
item.start ? new Date(item.start * 1000).toLocaleDateString() : ""
360+
item.start
361+
? new Date(item.start * 1000).toLocaleString([], {
362+
year: "numeric",
363+
month: "short",
364+
day: "numeric",
365+
hour: "2-digit",
366+
minute: "2-digit",
367+
})
368+
: ""
357369
}</small>
370+
<p class="change">${item.text || ""}</p>
358371
`;
359372

360373
content.appendChild(article);

style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,11 @@ dialog .btn:active {
638638
#announcementsButton {
639639
transition: all 0.1s ease-in-out;
640640
}
641-
641+
.announcement {
642+
display: flex;
643+
flex-direction: column;
644+
gap: 0.25rem;
645+
}
642646
button:not(:disabled) {
643647
cursor: pointer;
644648
}

0 commit comments

Comments
 (0)