1/* 2 * Load the office hours into the ul elements with identifiers 3 * #officehours-upcoming and #officehours-past 4 */ 5function loadOfficeHours() { 6 var cleanup = function(n) { 7 $( "#no-upcoming-hours" ).hide(); 8 var summ = $( n ).children("span.summary"); 9 var dte = $( n ).children("span.date"); 10 summ.text(summ.text().replace(": DUS", "DUS")); 11 summ.text(summ.text().replace("Office hours ", "")); 12 dte.text(dte.text().replace(/0AM/g, "0am")); 13 dte.text(dte.text().replace(/0PM/g, "0pm")); 14 dte.text(dte.text().replace(/:00/g, "")); 15 dte.text(dte.text().replace(" - ", "-")); 16 dte.text(dte.text().replace(" from ", " ")); 17 // dte.text(dte.text()+":"); 18 if (summ.text().toLowerCase().includes("cancel")) { 19 dte.addClass('cancelled-officehour'); 20 } 21 }; 22 23 // Use an observer to cleanup li entries as they are added. 24 var observer = new MutationObserver(function (mutations) { 25 mutations.forEach(function (mutation) { 26 $.each(mutation.addedNodes, function( index, n ) { 27 cleanup(n); 28 }); 29 }); 30 }); 31 32 var config = { 33 childList: true, 34 }; 35 36 observer.observe($("#officehours-upcoming").get(0), config); 37 38 // use another observer to know when loading is finished 39 // and set the "Loading..." text to say that there are no 40 // office hours 41 var finishedLoadingObserver = new MutationObserver(function (mutations) { 42 $( "#no-upcoming-hours" ).html("<i>No scheduled office hours in next two weeks (see <a href='/contact'>here</a> for more).</i>"); 43 }); 44 45 finishedLoadingObserver.observe($("#officehours-past").get(0), config); 46 47 48 // fetch the calendar. We will fetch one past event (that won't be displayed) so that we 49 // know when the loading of the calendar has finished. 50 formatGoogleCalendar.init({ 51 calendarUrl: 'https://www.googleapis.com/calendar/v3/calendars/boazbarak.org_5kihbkpl17hr0lpr0aunr84svs@group.calendar.google.com/events?key=AIzaSyCR3-ptjHE-_douJsn8o20oRwkxt-zHStY', 52 past: true, 53 upcoming: true, 54 sameDayTimes: true, 55 dayNames: true, 56 upcomingTopN: -1, 57 pastTopN: 1, 58 recurringEvents: true, 59 itemsTagName: 'li', 60 upcomingSelector: '#officehours-upcoming', 61 upcomingHeading: '', 62 pastSelector: '#officehours-past', 63 pastHeading: '', 64 format: ['*date*', ' ', '*summary*'], 65 timeMax: new Date(new Date().getTime() + 15*24*60*60*1000).toISOString() 66 }); 67} 68 69// Run loadOfficeHours once the document is ready 70$( loadOfficeHours );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.