const tiktok = { name: 'TikTok', url: 'https://www.tiktok.com/@knkx885', logo: ` ` }; const threads = { name: 'Threads', url: 'https://www.threads.net/@knkx885', logo: ` ` }; document.addEventListener('DOMContentLoaded', () => { newsletterButton(); burgerMenuChanges(); footerChanges(); replaceSearch(); }); // Adds a newsletter button to the header next to the donate button function newsletterButton() { let newsletterPresent = false; // Prevents newsletter button from being added multiple times. var menuDonateButton = document.querySelector('.PH-donate-button'); if (!menuDonateButton) { console.error('The class was not found.'); return; } if (window.innerWidth <= 768) { var phNewsletter = `
`; } else { var phNewsletter = `
`; } if (!newsletterPresent) { menuDonateButton.insertAdjacentHTML('beforebegin', phNewsletter); newsletterPresent = true; } } // Custom footer copy added. function footerChanges() { var hasFooterRun = false; var footerAtt = ``; const footerAttribute = document.querySelector(".Page-footer-logo"); if (!footerAttribute) { console.error('The class was not found.'); return; } if (!hasFooterRun) { footerAttribute.insertAdjacentHTML('afterend', footerAtt); hasFooterRun = true; } //addFooterSocialLogo(threads); //addFooterSocialLogo(tiktok); } // Custom burger menu items added. function burgerMenuChanges() { var burgerMenuLogo = `

KNKX delivers jazz, blues and NPR news on air and online from its studios in Seattle and Tacoma.

`; var burgerMenuSocial = `
youtube
`; // Grabs the menu class and inserts the new items var menuAtt = document.querySelector(".PH-ham-m-top"); if (!menuAtt) { console.error(' The class was not found.'); return; } var menuSocial = document.querySelector(".PH-ham-m-content"); if (!menuSocial) { console.error('The class was not found.'); return; } menuAtt.insertAdjacentHTML('afterend', burgerMenuLogo); menuSocial.insertAdjacentHTML('afterend', burgerMenuSocial); } // Custom Google Search, bypasses Grove Search, site search found at '/site-search' function replaceSearch() { var searchForms = document.querySelectorAll('form.PH-search-form'); if (!searchForms) { console.error('The class was not found.'); return; } for (let form of searchForms) { form.action = '/search'; } } // Adds social sites to the footer not supported by Grove function addFooterSocialLogo(platform) { const socialLogoContainer = document.querySelector('.SocialBar-items'); if (!socialLogoContainer) { console.error('Could not find social logos container in the footer.'); return; } if (typeof platform !== 'object' || !platform.name || !platform.url || !platform.logo) { console.error(`Expected a platform object with social logo info. Instead got ${platform}`); return; } socialLogoContainer.insertAdjacentHTML('beforeend', `
  • ${platform.logo} ${platform.name}
  • `); }