window.addEventListener('load', () => { document.querySelectorAll("div[data-platform-hinted]") .forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem))) document.querySelectorAll("div[tabs-section]") .forEach(elem => elem.addEventListener('click', (event) => toggleSections(event))) document.querySelector(".tabs-section-body") .querySelector("div[data-togglable]") .setAttribute("data-active", "") }) function toggleSections(evt){ if(!evt.target.getAttribute("data-togglable")) return const activateTabs = (containerClass) => { for(const element of document.getElementsByClassName(containerClass)){ for(const child of element.children){ if(child.getAttribute("data-togglable") === evt.target.getAttribute("data-togglable")){ child.setAttribute("data-active", "") } else { child.removeAttribute("data-active") } } } } activateTabs("tabs-section") activateTabs("tabs-section-body") } function togglePlatformDependent(e, container) { let target = e.target if (target.tagName != 'BUTTON') return; let index = target.getAttribute('data-toggle') for(let child of container.children){ if(child.hasAttribute('data-toggle-list')){ for(let bm of child.children){ if(bm == target){ bm.setAttribute('data-active',"") } else if(bm != target) { bm.removeAttribute('data-active') } } } else if(child.getAttribute('data-togglable') == index) { child.setAttribute('data-active',"") } else { child.removeAttribute('data-active') } } }