Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-- this code runs on each page of the site --*/
- window.onload = function() {
- /*-- gets the current year for the footer copyright text --*/
- document.getElementById("getYear").innerHTML = new Date().getFullYear();
- /*-- checks if the cookie "userhome" is present with a set value, then unhides header and footer elements if a cookie with that value is found --*/
- if (document.cookie.split(';').some((item) => item.includes('userhome=rochdale'))) {
- document.getElementById('menu-item-2542').classList.remove("hidden");
- document.getElementById("footerRochdale").classList.remove("footer-hidden");
- }
- else if (document.cookie.split(';').some((item) => item.includes('userhome=aurora'))) {
- document.getElementById('menu-item-2556').classList.remove("hidden");
- document.getElementById("footerAurora").classList.remove("footer-hidden");
- }
- else if (document.cookie.split(';').some((item) => item.includes('userhome=grantpark'))) {
- document.getElementById('menu-item-2541').classList.remove("hidden");
- document.getElementById("footerGrantpark").classList.remove("footer-hidden");
- }
- else if (document.cookie.split(';').some((item) => item.includes('userhome=southdale'))) {
- document.getElementById('menu-item-2558').classList.remove("hidden");
- document.getElementById("footerSouthdale").classList.remove("footer-hidden");
- }
- else if (document.cookie.split(';').some((item) => item.includes('userhome=eighth'))) {
- document.getElementById('menu-item-2557').classList.remove("hidden");
- document.getElementById("footerEighth").classList.remove("footer-hidden");
- }
- /*-- else: if no "userhome" cookie is found, unhides the CTA to select a location --*/
- else {
- document.getElementById('menu-item-2554').classList.remove("hidden");
- document.getElementById("footerNohome").classList.remove("footer-hidden");
- }
- }
- /*-- this code is only present on individual location pages --*/
- /*-- defines the function to create cookies, runs when a button is clicked, then hides the button and displays a welcome message --*/
- function setCookie(cname,cvalue,exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
- var expires = "; expires="+d.toUTCString();
- document.cookie = cname+"="+cvalue+expires+"; path=/";
- var setLocation = document.getElementById('setlocation');
- var welcomeMsg = document.getElementById('welcome');
- setLocation.className = "current";
- welcomeMsg.className = "display";
- }
- /*-- this code runs when a location page is loaded, it checks if the cookie for that location is present, then hides the button and displays a welcome message if it is found --*/
- function isCurrent() {
- if (document.cookie.split(';').some((item) => item.includes('userhome=LOCATION'))) {
- var setLocation = document.getElementById('setlocation');
- var welcomeMsg = document.getElementById('welcome');
- setLocation.className = "current";
- welcomeMsg.className = "display";
- }
- }
- window.onload = isCurrent();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement