jQuery(document).ready(function() { jQuery("#studentPatronType").click(function(){ showPatronType("Berkeley Law Students", "showStudent"); }); jQuery("#facultyStaffPatronType").click(function(){ showPatronType("Berkeley Law Faculty and Staff", "showFacStaff"); }); jQuery("#vsPatronType").click(function(){ showPatronType("Berkeley Law Visiting Scholars", "showVS"); }); jQuery("#bexPatronType").click(function(){ location.href = "bex.html"; }); jQuery("#nonLawUCBPatronType").click(function(){ showPatronType("Non-Law UCB Faculty, Staff and Students", "showNonLawUCB"); }); jQuery("#visitorPatronType").click(function(){ showPatronType("Visitors", "showVisitor"); }); }); function showPatronType(label, patronClass) { jQuery("#postIdentificationContent").hide(); jQuery("#patronTypeLabel").html(label); jQuery(".showable").hide(); if(jQuery.support.cssFloat) jQuery("#content").css({"height" : "inherit"}); jQuery("." + patronClass).show(); jQuery("#postIdentificationContent").show(); } function renderTodaysHours(){ const todaysHours = document.getElementById('todaysHours'); if(todaysHours){ var yyyymmdd = new Date().toISOString().split('T')[0].replace(/-/g, ''); var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://www.law.berkeley.edu/library/hours/hours.json'); xhr.responseType = 'json'; xhr.onload = function() { console.log('here'); if (this.status === 200) { const data = this.response; // Already an object const filteredWeeks = data.weeks.filter(week => week.thisWeek == true); const thisWeek = filteredWeeks[0]; const today = thisWeek[new Date().toLocaleDateString('en-US', { weekday: 'long'}).substring(0,2).toLowerCase()]; if(today.hours.mrr && today.hours.sa){ todaysHours.innerHTML = `
Today's Hours