MediaWiki:Common.js: Difference between revisions

From Auranogi
mNo edit summary
mNo edit summary
Line 13: Line 13:
console.log("Checking for datatables");
console.log("Checking for datatables");


document.querySelectorAll('.datatable').forEach(function(node) {
setTimeout(function() {
console.log("Setting up datatable", node);
document.querySelectorAll('.datatable').forEach(function(node) {
const headerClone = node.querySelector('tr').cloneNode(true);
console.log("Setting up datatable", node);
const thead = document.createElement('thead');
const headerClone = node.querySelector('tr').cloneNode(true);
thead.appendChild(headerClone);
const thead = document.createElement('thead');
node.prepend(thead);
thead.appendChild(headerClone);
new DataTable(node);
node.prepend(thead);
node.querySelector('tbody tr').remove()
new DataTable(node);
});
node.querySelector('tbody tr').remove()
});
}, 120);
 
// Remove generated subcategories if page has a CategoryTree
// Remove generated subcategories if page has a CategoryTree

Revision as of 19:36, 26 October 2023

/* Any JavaScript here will be loaded for all users on every page load. */
function importPage(name, type) {
	return mw.loader.load( '/index.php?title=' + name + '&action=raw&ctype=' + type, type );
}

function importScript(name) { return importPage(name, 'text/javascript'); }

importScript('MediaWiki:DynamicNav.js');

$(function () {
	// document.querySelector('.CategoryTreeSection [href="/view/Category:Dungeon_Variants"').parentElement.parentElement.remove();
	
	console.log("Checking for datatables");

	setTimeout(function() {
		document.querySelectorAll('.datatable').forEach(function(node) {
			console.log("Setting up datatable", node);
			const headerClone = node.querySelector('tr').cloneNode(true);
			const thead = document.createElement('thead');
			thead.appendChild(headerClone);
			node.prepend(thead);
			new DataTable(node);
			node.querySelector('tbody tr').remove()
		});
	}, 120);

	
	// Remove generated subcategories if page has a CategoryTree
	setTimeout(function() {
		const cat = document.querySelector('.CategoryTreeTag');
		console.log('Checking to remove gened subcats', cat);
		
		if (!cat) document.querySelector('.mw-category-generated').style.display = "block";
	}, 120);

}());