User:Erutuon/scripts/mainspaceHeaders.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/mainspaceHeaders.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/mainspaceHeaders.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/mainspaceHeaders.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/mainspaceHeaders.js you have here. The definition of the word User:Erutuon/scripts/mainspaceHeaders.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/mainspaceHeaders.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
mw.loader.using('mediawiki.Title').done(function () {
	const search = new mw.Title('Special:Search');

	$('tr td:first-child').get().forEach(function (element) {
		let parent;
		const textNode = (function (node) {
			while (node && !(node instanceof Text))
				parent = node, node = node.firstChild;
			return node;
		})(element);
		
		if (!(textNode instanceof Text))
			 return console.error(element);
		
		const text = textNode.nodeValue;
		const query = '"' + text + '" insource:/= *'
			+ text.replace(//g, '\\$&') + ' *=/';
		const url = search.getUrl({ search: query, ns0: 1 });
		
		const link = document.createElement('a');
		link.href = url;
		link.appendChild(textNode);
		parent.appendChild(link);
		
		// Add class to parent table row so that crossed out headers can be hidden.
		if (parent.nodeName === 'DEL') {
			let tableRow = parent;
			while (tableRow && tableRow.nodeName !== 'TR')
				tableRow = tableRow.parentNode;
			tableRow.classList.add('crossed-out');
		}
	});
	
	const crossedOut = $('.crossed-out');
	if (crossedOut.length === 0)
		return;
	
	mw.loader.using('oojs-ui').done(function () {
		const what = 'crossed-out headers';
		const hideText = 'Hide ' + what;
		const showText = 'Show ' + what;
		
		const button = new OO.ui.ButtonWidget();
		
		button.setLabel(showText);
		crossedOut.first().closest('table').before(button.$element);
		
		var shown = false;
		crossedOut.toggle(shown);
		
		button.$element.click(function () {
			shown = !shown;
			crossedOut.toggle(shown);
			button.setLabel(shown ? hideText : showText);
		});
	});
});