@@ -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} ) ;
285290function 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 ) ;
0 commit comments