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}); }; };

/* 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; };