User:Erutuon/scripts/scriptTitles.js

Hello, you have come here looking for the meaning of the word User:Erutuon/scripts/scriptTitles.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Erutuon/scripts/scriptTitles.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Erutuon/scripts/scriptTitles.js in singular and plural. Everything you need to know about the word User:Erutuon/scripts/scriptTitles.js you have here. The definition of the word User:Erutuon/scripts/scriptTitles.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Erutuon/scripts/scriptTitles.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
/* Script-tags titles in the main and Talk namespaces in a language-agnostic
 * way.
 * Uses ] for script detection.
*/
/* jshint eqeqeq: true */
/* globals mw, $ */

// <nowiki>

'use strict';

$(function () {
	const namespace = mw.config.values.wgCanonicalNamespace;
	
	if ( !.includes(namespace) && mw.config.values.wgAction === 'view' ) {
		console.log('No script class added; not mainspace: ' + namespace + '.');
		return undefined;
	}
	
	let firstHeading = document.getElementById('firstHeading');
	let headerText = firstHeading && firstHeading.firstChild;
	if ( !headerText ) {
		return;
	}
	// This has to be a text node.
	// Latin script doesn't need tagging.
	else if ( headerText.nodeType !== 3 ) {
		// Accommodate span tags created by editable title gadget.
		if ( headerText.nodeName === 'SPAN' ) {
			if ( headerText.classList.length > 0 ) {
				var scriptClassRegex = /^{3}|polytonic|Latinx|Ruminumerals|musical$/;
				for ( const className of headerText.classList ) {
					if ( scriptClassRegex.test(className) ) {
						return;
					}
				}
			}
			headerText = headerText.firstChild;
		} else {
			return;
		}
	}
	
	if ( !//.test(headerText.nodeValue) ) {
		return;
	}
	
	// from https://api.jquery.com/jQuery.getScript
	$.cachedScript = function (url, options) {
			options = $.extend(options || {}, {
				dataType: "script",
				cache: true,
				url: url
			});
		 
			return $.ajax(options);
		};
	
	$.cachedScript(
		'//en.wiktionary.orghttps://en.wiktionary.org/w/index.php?title=User:Erutuon/scripts/scriptRecognition.js&action=raw&ctype=text/javascript')
		.done(function () {
			try {
				let newNodeText = namespace === 'Talk' ?
					mw.config.values.wgPageName.match(/^Talk:(.+)$/) :
					mw.config.values.wgPageName;
				
				newNodeText = newNodeText.replace(/_/g, ' ');
				
				const script = window.getScript(newNodeText);
				if (script) {
					headerText.nodeValue = namespace === 'Talk' ? 'Talk:' : '';
					const newNode = document.createElement("span");
					newNode.className = script;
					newNode.innerHTML = newNodeText;
					var parent = headerText.parentNode;
					if (!parent)
						console.log(headerText, firstHeading);
					parent.insertBefore(newNode, headerText.nextSibling);
					console.log(`Added script class ${script} to header ${mw.config.values.wgPageName}.`);
				} else {
					console.log(`No script detected for ${mw.config.values.wgPageName}.`);
				}
			} catch (error) {
				console.log("Error in adding script tagging to title: ", error);
			}
		});
});

// </nowiki>