National Renewable Energy Platform

Roy Kyozaire



Share Post

Leave a Reply

Your email address will not be published. Required fields are marked *

document.addEventListener("DOMContentLoaded", function () { // --- SAFETY CHECK: Run ONLY on the RA Projects page --- const pagePath = window.location.pathname.replace(/\/$/, ""); if (pagePath !== "/ra-projects") { return; // Stop the script on every other page } // --- Your actual script starts here --- const pills = Array.from(document.querySelectorAll(".proj-pill")); const panels = Array.from(document.querySelectorAll(".proj-panel")); function projSelect(target, btn) { // deactivate all pills.forEach(p => p.classList.remove("active")); panels.forEach(p => p.classList.remove("active")); // activate current if (btn) btn.classList.add("active"); const panel = document.querySelector(`#${target}`); if (panel) panel.classList.add("active"); // update hash history.replaceState(null, null, "#" + target); } // handle click pills.forEach(pill => { pill.addEventListener("click", () => { const target = pill.getAttribute("data-target"); projSelect(target, pill); }); }); // handle hash on page load const hash = window.location.hash.replace("#", ""); const defaultTarget = hash || pills[0].getAttribute("data-target"); const startupBtn = pills.find(p => p.getAttribute("data-target") === defaultTarget); if (startupBtn) startupBtn.click(); });