You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -36,27 +35,30 @@ async function showOfficeBanner() {
36
35
.then(r=>r.ok ? r.text() : "");
37
36
if(!text){console.warn("failed to load calendar ")};
38
37
39
-
40
38
constnow=newDate();
41
-
letallmatch=text.matchAll(/DTSTART:(\d+T\d+Z)/g);
42
-
// Extract all dates.
43
-
for(consttofallmatch){
44
-
if(!t)continue;
45
-
letd=format8601(t[1]);
46
-
// if today
47
-
if(now.toDateString()==d.toDateString()){
48
-
// if not finished.
49
-
if(now.getTime()<d.getTime()+3600000){
50
-
// if not started
51
-
if(now<d){
52
-
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on today, starting ${d.toLocaleTimeString([],{hour: '2-digit',minute:'2-digit'})}. Drop in for any queries.`,"calendar-banner");
53
-
54
-
}else{
55
-
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on now. <a href="${MEETING_LINK}">Join Zoom Meeting Now</a> for any queries.</p>`,"calendar-banner");
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on today, starting ${date.toLocaleTimeString([],{hour: '2-digit',minute:'2-digit'})}. Drop in for any queries.`,"calendar-banner");
53
+
}else{
54
+
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on now. <a href="${MEETING_LINK}">Join Zoom Meeting Now</a> for any queries.</p>`,"calendar-banner");
55
+
}
56
56
}
57
+
break;
57
58
}
58
-
break;
59
59
}
60
+
}catch(error){
61
+
console.warn("ICAL parsing failed",error);
60
62
}
61
63
}
62
64
@@ -81,14 +83,15 @@ function format8601(str){
81
83
constdateStringFormatted=
82
84
str.substring(0,4)+'-'+
83
85
str.substring(4,6)+'-'+
84
-
str.substring(6,8)+
85
-
str.substring(8,9)+
86
+
str.substring(6,8)+'T'+
86
87
str.substring(9,11)+':'+
87
88
str.substring(11,13)+':'+
88
-
str.substring(13,15)+
89
-
str.substring(15,16);
89
+
str.substring(13,15)+'+12:00';
90
90
returnnewDate(dateStringFormatted);
91
91
}
92
+
93
+
showOfficeBanner();
94
+
92
95
// Remove me later
93
96
// showOfficeBanner().then(() => {
94
97
// if (!document.getElementById("calendar-banner")){
0 commit comments