// moved into wordpress itself jQuery("section .column:nth-child(2) .building-block .row .color-dark.grey .clipped-content").load("/library/hours.php?view=home"); /* var mores = ["", "students.html", "/library/resources-for/faculty-3/"]; for(var i = 0; i < mores.length; i++){ var link = jQuery(jQuery(".content-hover-card .card-content > a")[i]).attr("href"); if(mores[i] !== "") jQuery(jQuery(".content-hover-card .card-content")[i]).append("

more ...

"); } */ jQuery(jQuery(".content-hover-card .card-content")[1]).append("

more Student Resources...

"); jQuery(jQuery(".content-hover-card .card-content")[2]).append("

more Faculty Resources...

"); jQuery(".content-hover-card .card-content > a").remove(); jQuery(jQuery("#libSearch h3 span.tab")[0]).click(function(){ jQuery("#libSearch form").hide(); jQuery(jQuery("#libSearch form")[0]).show(); jQuery("#libSearch h3").removeClass(); jQuery(jQuery("#libSearch h3")[1]).addClass("inactive"); }); jQuery(jQuery("#libSearch h3 span.tab")[1]).click(function(){ jQuery("#libSearch form").hide(); jQuery(jQuery("#libSearch form")[1]).show(); jQuery("#libSearch h3").removeClass(); jQuery(jQuery("#libSearch h3")[0]).addClass("inactive"); });; jQuery(jQuery("#libSearch h3 span.library-help")[0]).click(function(){ window.open("https://www.law.berkeley.edu/library/library-information/collections/collection-search/", "libraryHelp"); });; jQuery(jQuery("#libSearch h3 span.library-help")[1]).click(function(){ window.open("https://www.law.berkeley.edu/library/library-information/collections/collection-search/", "libraryHelp"); }); jQuery("#library-ticker .arrow").click(function(){ location.href = "https://www.law.berkeley.edu/library/whatsNew.php"; }); 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

Full hours and access

`; } } }; xhr.send(); } } function fireTopDB(){ window.open(jQuery("select[name='topDatabase']").val(), '_blank'); return false; } function layCrumbs(pageID, terminalLabel = false){ var target = jQuery.find("#menu-library-menu .page-item-" + pageID)[0]; if(target) { lis = jQuery(target).parentsUntil("#menu-library-menu").filter("li"); var crumbs = Array(lis.length); for(var i = 0; i < lis.length; i++){ firstChild = jQuery(lis[i]).children()[0]; if(firstChild.tagName.match(/^a$/i)) { crumbs[i] = firstChild.outerHTML; } else if(firstChild.tagName.match(/button/i)){ crumbs[i] = firstChild.innerText; } } crumbs.reverse(); if(terminalLabel) crumbs.push(terminalLabel); crumbsString = crumbs.join(' '); jQuery('.breadcrumbs .row li:last').html(crumbsString); } } function toTitleCase(str) { return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); } function to12hhmm(raw){ // 0730-2330, e.g. var fromTo = raw.split('-'); var from = fromTo[0]; var to = fromTo[1]; var hh = from.substring(0,2); var mm = from.substring(2,4); var prepared = hh > 12 ? hh-12 : hh.replace(/^0/, ''); prepared += ':' + mm; apm = hh > 12 ? 'pm' : 'am'; prepared += apm + '-'; var hh = to.substring(0,2); var mm = to.substring(2,4); prepared += hh > 12 ? hh-12 : hh; prepared += ':' + mm; apm = hh > 12 ? 'pm' : 'am'; prepared += apm; return prepared; } jQuery(document).ready(function(){ renderTodaysHours(); jQuery('#menu-footer-menu').append("
  • Staff Tools
  • "); });