2024-05-29 22:35:45 +00:00
|
|
|
const config = require( './config.json' );
|
2024-05-24 16:15:14 +00:00
|
|
|
const init = () => {
|
2024-05-29 22:35:45 +00:00
|
|
|
if ( !config.VectorWrapTablesTemporary ) {
|
|
|
|
return;
|
|
|
|
}
|
2024-05-29 18:38:19 +00:00
|
|
|
const tables = document.querySelectorAll( '.mw-parser-output table.wikitable:not(.floatright):not(.floatleft)' );
|
2024-05-24 16:15:14 +00:00
|
|
|
Array.from( tables ).forEach( ( table ) => {
|
|
|
|
// Don't wrap tables within tables
|
|
|
|
const parent = table.parentElement;
|
2024-05-28 21:36:07 +00:00
|
|
|
if (
|
|
|
|
parent && table.matches( '.wikitable' ) &&
|
|
|
|
!parent.matches( '.noresize' ) &&
|
|
|
|
!parent.closest( 'table' )
|
|
|
|
) {
|
2024-05-24 16:15:14 +00:00
|
|
|
const wrapper = document.createElement( 'div' );
|
|
|
|
wrapper.classList.add( 'noresize' );
|
|
|
|
parent.insertBefore( wrapper, table );
|
|
|
|
wrapper.appendChild( table );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
init
|
|
|
|
};
|