« MediaWiki:Gadget-autonum.js » : différence entre les versions
Aller à la navigation
Aller à la recherche
(Page créée avec « →* * Auto-number headings * * @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings * @author Krinkle * @version 2021-10-03 : var toc = document.querySelector('#toc'); if (toc) { document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline').forEach(function (headline) { var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber'); if (num) headline.prepend(num.textContent + ' '); });... ») |
(Aucune différence)
|
Dernière version du 29 septembre 2023 à 09:38
1 /**
2 * Auto-number headings
3 *
4 * @source https://www.mediawiki.org/wiki/Snippets/Auto-number_headings
5 * @author Krinkle
6 * @version 2021-10-03
7 */
8 var toc = document.querySelector('#toc');
9 if (toc) {
10 document.querySelectorAll('.mw-parser-output :is(h1,h2,h3,h4,h5,h6) .mw-headline').forEach(function (headline) {
11 var num = toc.querySelector('a[href="#' + CSS.escape(headline.id) + '"] .tocnumber');
12 if (num) headline.prepend(num.textContent + ' ');
13 });
14 } else {
15 document.body.classList.add('tpl-autonum');
16 }