User:Erutuon/scripts/catfix.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/catfix.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/catfix.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/catfix.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/catfix.js you have here. The definition of the word User:Erutuon/scripts/catfix.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/catfix.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
jQuery(function () {
	'use strict';
	
	var wrapper;
	
	// Apply only to pages in the Category namespace
	// containing an element with the id "catfix".
	// Set window.disableCatfix to true to prevent this script from running.
	if (!(mw.config.get('wgNamespaceNumber') === 14
	&& (wrapper = document.getElementById("catfix"))))
		return;

	// Get the language name and script wrapper.
	var langName = wrapper.className.split("CATFIX-");
	wrapper = wrapper.getElementsByTagName("*") || document.createElement("span");
	
	var anchor = "";
	if (langName && langName.length > 0)
		anchor = langName;
	
	function isEntry(namespaceName, pageName) {
		// main, Talk, Citations, Reconstruction,
		// Appendix if it starts with language name and "/"
		return .indexOf(namespaceName) != -1
			|| (namespaceName == "Appendix"
				&& pageName.slice(0, langName.length + 1) == langName + "/");
	}
	
	var formattedNamespaces = mw.config.get("wgFormattedNamespaces");
	
	function wrapNode(node, wrapper) {
		var parent = node.parentNode;
		wrapper.appendChild(node);
		parent.appendChild(wrapper);
	}
	
	// Process each link in the category listing.
	jQuery("#mw-pages > .mw-content-ltr li > a, #newest-and-oldest-pages tr li > a")
		.each(function () {
			try {
				var titleobj = new mw.Title(this.textContent || this.innerText);
				var namespaceName = formattedNamespaces;
				var pageName = titleobj.getNameText();
				
				if (!isEntry(namespaceName, pageName))
					return;
				
				// Add the anchor if applicable.
				if (.indexOf(namespaceName) !== -1)
					this.hash = anchor;
				
				var textNodeToWrap;
				// Choose the part of the link text to wrap
				// - in mainspace, the whole link
				// - in Talk and Citations, the part after the namespace prefix
				// - in Reconstruction and Appendix, the part after the
				//   namespace prefix and language name
				if (namespaceName === "") {
					textNodeToWrap = this;
				} else {
					if (.indexOf(namespaceName) !== -1) {
						textNodeToWrap = document.createTextNode(pageName);
						$(this).empty()
							.append(titleobj.getNamespacePrefix())
							.append(textNodeToWrap);
					} else if (.indexOf(namespaceName) !== -1) {
						var split = pageName.split("/", 2);
						if (split.length !== 2) {
							throw new TypeError("Malformed title: " + pageName);
						}
						var langPrefix = split;
						textNodeToWrap = document.createTextNode(split);
						$(this).empty()
							.append(titleobj.getNamespacePrefix() + langPrefix + "/")
							.append(textNodeToWrap);
						
					}
				}
				
				wrapNode(textNodeToWrap, wrapper.cloneNode(false));
			} catch (e) {
				console.error(e);
			}
		});
});