MediaWiki:Common.js: Difference between revisions
From WikiMSK
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
for (i = 0; i < headings.length; i++) { | for (i = 0; i < headings.length; i++) { | ||
headings[i].innerHTML = '<button aria-expanded="false">' + headings[i].innerHTML + '<svg aria-hidden="true" focusable="false" viewBox="0 0 10 10"><rect class="vert" height="8" width="2" y="1" x="4"/><rect height="2" width="8" y="4" x="1"/></svg></button>'; | headings[i].innerHTML = '<button aria-expanded="false">' + headings[i].innerHTML + '<svg aria-hidden="true" focusable="false" viewBox="0 0 10 10"><rect class="vert" height="8" width="2" y="1" x="4"/><rect height="2" width="8" y="4" x="1"/></svg></button>'; | ||
const getContent = (elem) => { | |||
let elems = [] | |||
while (elem.nextElementSibling && elem.nextElementSibling.tagName !== 'H2') { | |||
elems.push(elem.nextElementSibling) | |||
elem = elem.nextElementSibling | |||
} | |||
} | |||
} | } | ||
}); | }); |
Revision as of 08:37, 22 August 2020
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
// Get all the <h2> headings
const headings = document.querySelectorAll('.mw-parser-output h2');
for (i = 0; i < headings.length; i++) {
headings[i].innerHTML = '<button aria-expanded="false">' + headings[i].innerHTML + '<svg aria-hidden="true" focusable="false" viewBox="0 0 10 10"><rect class="vert" height="8" width="2" y="1" x="4"/><rect height="2" width="8" y="4" x="1"/></svg></button>';
const getContent = (elem) => {
let elems = []
while (elem.nextElementSibling && elem.nextElementSibling.tagName !== 'H2') {
elems.push(elem.nextElementSibling)
elem = elem.nextElementSibling
}
}
}
});