MediaWiki:Common.js

/* 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++) { 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'); coltogbutton.style.display = 'inline'; coltogbutton.innerHTML = 'Colored text:  '; var coltog = true; collist.forEach(function (v) {		v.dataset.color = v.style.color;	}); 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;		}	} }