Difference between revisions of "User:Knightmare/common.js"

From ARMCO
Jump to navigation Jump to search
(Blanked the page)
Tag: Blanking
 
Line 1: Line 1:
// Create a function to enable the collapse/expand functionality
function addCollapseExpand() {
// Add a toggle button for each nested list
var subLists = toc.querySelectorAll('ul');

subLists.forEach(function(subList) {
// Create a button to toggle the sublist
var toggleButton = document.createElement('button');
toggleButton.textContent = '▸'; // Right arrow for collapsed state
toggleButton.classList.add('toc-toggle');
subList.parentElement.insertBefore(toggleButton, subList);

// Set up event listener to handle the click (toggle state)
toggleButton.addEventListener('click', function() {
if (subList.style.display === 'none') {
subList.style.display = 'block'; // Expand the list
toggleButton.textContent = '▸'; // Change button to right arrow
} else {
subList.style.display = 'none'; // Collapse the list
toggleButton.textContent = '▶'; // Change button to down arrow
}
});
});
}

// Run the collapse/expand functionality
addCollapseExpand();
})();

Latest revision as of 16:28, 18 November 2024