MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 141:
document.body;
// Collect headings (
var items = [];
var headings = root.querySelectorAll('h2, h3, h4, h5, h6');
headings.forEach(function (h) {
var level = parseInt(h.tagName.slice(1), 10);
if (level < 2 || level >
var headline = h.querySelector('.mw-headline') || h;
var id = headline.id || h.id;
Line 691 ⟶ 690:
/* ── Hide DEEP (nested) level-6 headings from the sidebar (Vector) TOC
The doc pages carry repeated h6 sub-entries that clutter the TOC. MediaWiki's
heading instead. We hide ONLY NESTED h6: a TOP-LEVEL section that happens to
be h6 (e.g. Cover / Audit Information) is KEPT, because hiding a numbered
top-level entry leaves a gap in MediaWiki's static TOC numbers (0 -> 3). */
(function () {
function headingFor(anchor) {
Line 717 ⟶ 716:
if (href.charAt(0) !== '#' || href.length < 2) { return; }
var h = headingFor(href.slice(1));
if (!h
// Only hide NESTED h6 (deep repeated sub-entries). A top-level h6 section
// is kept so the top-level numbering stays contiguous.
var nested = li.parentElement && li.parentElement.closest &&
li.parentElement.closest('.vector-toc-list-item');
if (nested) { li.style.display = 'none'; }
});
}
| |||