MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ /* Any JavaScript here will be loaded for all users on every page load. */

/* Downpour Spoiler Tags */

var sps = document.getElementsByClassName('dp-spoiltag'); for (var i=0; i < sps.length; i++) { if (!sps[i].dataset.spoiltagcontent || sps[i].dataset.spoiltagcontent == '') { sps[i].dataset.spoiltagcontent = 'Downpour content' }	sps[i].innerHTML = '' + sps[i].innerHTML + ' '; var links = sps[i].getElementsByTagName('a'); for (var i1=0; i1 < links.length; i1++) { links[i1].addEventListener('mouseover', function (event) {event.stopPropagation}); }; };

/* Colored Text Toggle */

var coltogbutton = document.getElementById('coltogbutton'); if (coltogbutton) { var collist = document.querySelectorAll('[style*="color"], .SRS, .NSH, .WO, .EOC, .PI, .GS, .SI, .HR, .BSM, .CW, .FivePebbles, .EP, .FP, .HF, .NGI, .UU, .Andrew, .Will, .Screams, .Dakras, .Cappin, .Norgad'); collist.forEach(function (v) {		v.dataset.color = v.style.color;	}); var coltog = true; var ischecked = ' checked'; if (coltogbutton.innerHTML == 'Off') { textColorToggle; ischecked = ''; };	coltogbutton.style.display = 'inline'; coltogbutton.innerHTML = 'Colored text:  '; coltogbutton.outerHTML = coltogbutton.outerHTML + '&ensp; [ Set preferences ]  '; function textColorToggle { if (coltog) { collist.forEach(function (v) {				v.style.color = 'inherit';			}); } else { collist.forEach(function (v) {				v.style.color = v.dataset.color;			}); };		coltog = !coltog; }; };

/* Music Queueable Soundfiles */

if (mw.config.get("wgPageName") == "Music") { if (document.getElementById("queueswitch")) { document.getElementById("queueswitch").style.display = "inline"; document.getElementById("queueswitch").innerHTML = "Queue:  "; };

function togglequeuer { enabled = !enabled; (enabled) ? playingtoqueue : queuetoplaying; };	function addtoqueue(event) { if (!enabled || queue[0] == event.currentTarget) { laststarted = event.currentTarget; return; };		qc = queuecheck(event.currentTarget); if (!qc || queue[0].paused) { if (!queue[0] || queue[0].paused) { queue[0] = event.currentTarget; if (qc) { queue = queue.slice(0,qc).concat(queue.slice(qc+1,queue.length)); };			} else { queue.push(event.currentTarget); };			event.currentTarget.addEventListener("ended", nextinqueue); };		if (queue[0] != event.currentTarget) { event.currentTarget.pause; };	};	function nextinqueue { queue.shift; if (queue[0]) { queue[0].play; };	};	function queuecheck(t) { for (var i=0; i<queue.length; i++) { if (queue[i] == t) { return i;			}; };		return false; };	function playingtoqueue { queue = []; for (var i=0; i<trs.length; i++) { if (!trs[i].paused && trs[i] != laststarted) { trs[i].pause; };		};		if (laststarted) { queue[0] = laststarted; queue[0].addEventListener("ended", nextinqueue); };	};	function queuetoplaying { //for (var i=0; i<queue.length; i++) { //	queue[i].play; //};		queue = []; };	const trs = document.getElementsByTagName("audio"); for (var i=0; i<trs.length; i++) { trs[i].addEventListener("play", addtoqueue); };

document.getElementById("queuetoggler").addEventListener("click", togglequeuer); var queue = []; var enabled = false; var laststarted = null; };

/* Collections */ $(function {	var tabbers = document.getElementsByClassName("ru-wiki-tabber");	for (i = 0; i < tabbers.length; i++) {		var tabber = tabbers[i].id;

document.getElementById(tabber + "-buttons").id = tabber + "-" + i + "-buttons"; document.getElementById(tabber + "-tabs").id = tabber + "-" + i + "-tabs"; document.getElementById(tabber).id = tabber + "-" + i;

var tabber = tabbers[i].id;

var tabber_buttons = document.getElementById(tabber + "-buttons").children; var tabber_tabs = document.getElementById(tabber + "-tabs").children;

for (j = 0; j < tabber_buttons.length; j++) { var tabber_button = tabber_buttons[j]; var tabber_tab = tabber_tabs[j]; var button_id = tabber + "-" + j;			var tab_id = button_id + "-tab";

tabber_button.classList.add("button-tabber"); tabber_button.id = button_id; tabber_button.setAttribute('tabber', tabber); tabber_button.addEventListener('click', button_tabber_click); tabber_tab.id = tab_id;

if (j === 0) tabber_button.classList.add("button-active"); else $(tabber_tab).hide; if (tabber_button.children) for (k = 0; k < tabber_button.children.length; k++) tabber_button.children[k].style = "pointer-events: none;"; }	} }); function button_tabber_click {	var attr_tabber = this.getAttribute('tabber');	var tab_id = this.id + "-tab";	var tabber_tabs = document.getElementById(attr_tabber + "-tabs").children;	console.log('tab_id:', tab_id);	document.querySelector(".button-active[tabber=" + attr_tabber + "]").classList.remove("button-active");	this.classList.add("button-active");	for (i = 0; i < tabber_tabs.length; i++) {		var tabber_tab = tabber_tabs[i];		if (tabber_tab.id == tab_id) {			$(tabber_tab).show;		} else {			$(tabber_tab).hide;		}	} }

/* Collapsible TOC sections */ var toc = document.getElementById('toc'); if (toc) { var tocnum = 0; if (document.getElementById('fulltoccollapse')) { var tocsecs_All = document.getElementsByClassName('toclevel-' + (document.getElementById('fulltoccollapse').innerHTML || '1')); for (i=0; i<tocsecs_All.length; i++) { if (tocsecs_All[i].querySelector('ul')) { tocsecs_All[i].dataset.toccollapse = tocnum; tocnum++; };		};	};	var ctcs = document.getElementsByClassName('customtoccollapse'); if (ctcs) { var tocsecs_Cust = toc.getElementsByTagName('li'); for (i=0; i<ctcs.length; i++) { var pes = ctcs[i].previousElementSibling; var ref = pes.querySelector('span.mw-headline').id; for (j=0; j<tocsecs_Cust.length; j++) { if (tocsecs_Cust[j].querySelector('a').getAttribute('href').substring(1) == ref && tocsecs_Cust[j].querySelector('ul')) { if (!tocsecs_Cust[j].dataset.toccollapse) { tocsecs_Cust[j].dataset.toccollapse = tocnum; tocnum++; } else { tocsecs_Cust[j].removeAttribute('data-toccollapse'); };					break; };			};		};	};	document.querySelectorAll('[data-toccollapse]').forEach(function(v) {		addcollapse(v);	}); function addcollapse(el) { el.querySelectorAll('[data-toccollapse]').forEach(function(v) {			addcollapse(v);		}); el.innerHTML = ' ' + el.innerHTML; }; };