User:Bequw/bc-ad.js

Hello, you have come here looking for the meaning of the word User:Bequw/bc-ad.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Bequw/bc-ad.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Bequw/bc-ad.js in singular and plural. Everything you need to know about the word User:Bequw/bc-ad.js you have here. The definition of the word User:Bequw/bc-ad.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Bequw/bc-ad.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// <nowiki>
// Switches the year-numbering system from BCE/CE to BC/AD
// Now available as a gadget: ]
/* globals addOnloadHook */
"use strict";

function yearFormatSwitch() {
	if (!document.querySelectorAll) return;
	
	// This code supports date labels formatted using the following wikitext. (See {{B.C.E}} and {{C.E.}}.) BCE can be replaced by CE:
	
	// <small class="ce-date">]</small>
	var datetags = document.querySelectorAll('.ce-date');
	for (var i = 0; i < datetags.length; i++) {
		var datetag = datetags;
		if (datetag.firstChild && datetag.firstChild.firstChild && datetag.firstChild.firstChild.firstChild) {
			if (datetag.firstChild.firstChild.firstChild.nodeValue === "CE") {
				if (typeof datetag.firstChild.setAttribute === "function") {
					datetag.firstChild.setAttribute("href", "https://dictious.com/en/Appendix:Glossary#AD");
				}
				datetag.firstChild.firstChild.innerHTML = "AD";
				if (datetag.previousSibling) {
					var patt = /((?:\d{1,4} ?(?:-|–|to) ?)?\d{1,4}) ?$/g; // first if hyphen-minus, then en-dash
					var val = datetag.previousSibling.nodeValue;
					var matches = val.match(patt);
					if (matches !== null) {
						var lastMatch = matches;
						datetag.previousSibling.nodeValue = datetag.previousSibling.nodeValue.substr(0, datetag.previousSibling.nodeValue.length - lastMatch.length);
						if(!datetag.nextSibling)
							datetag.parentElement.appendChild(document.createTextNode(" " + lastMatch));
						else
							datetag.nextSibling.nodeValue = " " + lastMatch + datetag.nextSibling.nodeValue;
					}
				}
			}
			else {
				if (typeof datetag.firstChild.setAttribute === "function") {
					datetag.firstChild.setAttribute("href", "https://dictious.com/en/Appendix:Glossary#BC");
				}
				datetag.firstChild.firstChild.innerHTML = "BC";
			}
		}
	}
	
	// This code supports dates formatted in the following fashion:
	
	// <small class="ce-date2">CE</small>
	
	// The tag <small> can be replaced with <span> or something else.
	var datetags2 = document.querySelectorAll(".ce-date2");
	for (i = 0; i < datetags2.length; ++i ) {
		var datetag2 = datetags2;
		var convert = { "BCE": "BC", "CE": "AD" };
		datetag2.innerHTML = convert;
	}
}

$(yearFormatSwitch);

// </nowiki>