window.addEventListener('DOMContentLoaded', function() {
// function to get cookie value
const getCookie = (name) => {
let cookieArr = document.cookie.split(";");
for(let i = 0; i < cookieArr.length; i++) {
let cookiePair = cookieArr[i].split("=");
if(name === cookiePair[0].trim()) {
return decodeURIComponent(cookiePair[1]);
}
}
return null;
}
let preferedLocation = getCookie('prefered_location');
// mapping the location to the corresponding id
let locationToIdMap = {
'UC Baytown': 'UCBaytown',
'PC Baytown': 'PCBaytown',
'UC Crosby': 'UCCrosby'
};
let locationId = locationToIdMap[preferedLocation];
if (locationId) {
// If locationId exists, append it as a hash to the current URL
window.location.hash = locationId;
}
});