Skip to content

Instantly share code, notes, and snippets.

@dzoladz
Created May 10, 2022 00:53
Show Gist options
  • Save dzoladz/9adbf58ae849ef803e124cd8c5ad4e60 to your computer and use it in GitHub Desktop.
Save dzoladz/9adbf58ae849ef803e124cd8c5ad4e60 to your computer and use it in GitHub Desktop.
Scratch/Draft JS for Bib Location to Bib Location Mapping Client-Side
document.addEventListener("DOMContentLoaded", function(event) {
// EGCC eBook Locations
const ebookBibLocations = ['ebkga', 'ebkeb', 'ebkpe'];
// Create eBook Search Parameters
let array, searchParameters, displayEbooks
array = ebookBibLocations.map(el => '&b=' + el);
searchParameters = array.join('');
// Grab the Body element
xbody = document.body
// Does WebPAC Search Pattern Match?
if (
( window.location.href.match('/search/\\?searchtype=')
|| window.location.href.match('/search/X\\?SEARCH=') )
// AND hasn't already been modified?
&& !window.location.href.match(searchParameters) ) {
// We need some time to refresh the search parameters
xbody.style.cssText += 'display: none;';
setTimeout(() => {
xbody.style.cssText += 'display: inherit;';
}, "1500")
// Append eBook Locations to Search
displayEbooks = window.location.href + searchParameters;
location.replace(displayEbooks)
} else {
console.log('no match');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment