Registration has been disabled and the moderation extension has been turned off.
Contact an admin on Discord or EDF if you want an account. Also fuck bots.

MediaWiki:Common.js

From Encyclopedia Dramatica
This is an old revision of this page, as edited by imported>MarioMario456 at 14:22, 31 October 2021. It may differ significantly from the current revision.
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

setInterval(function () {
  var elements = document.getElementsByClassName('blink');
  for (index = 0; index < elements.length; index++) {
    if (elements[index].style.visibility === 'visible') {
      elements[index].style.visibility = 'hidden';
    } else {
      elements[index].style.visibility = 'visible';
    }
  }
}, 1000);



/* Collapsible toggle */

$(document).ready(function() {
	$(".collapsibletoggletext").click(function() {
		$(this).parent().children(".collapsibletoggletext").removeClass("hiddentext");
		$(this).addClass("hiddentext");
	});
});

/* Cycle forwards or backwards through elements one at a time via click */

$(function(){
    $(".cyclesequence").find(".cyclesequencelinknext").click(function(){
        if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").length === 0) {
            $(this).closest(".cyclesequence").find(".cyclesequenceitem:first").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
       }
       else {
           $(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
         }
    });
});

$(function(){
    $(".cyclesequence").find(".cyclesequencelinkprev").click(function(){
        if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").length === 0) {
            $(this).closest(".cyclesequence").find(".cyclesequenceitem:last").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
       }
       else {
           $(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
         }
    });
});

/* Click link to show one or more items and hide other items */

$(document).ready(function() {
	$(".morphlink").click(function() {
		var correspondingContent = $(this).data("correspondingcontent");
		$("#" + correspondingContent).removeClass("hiddentext");
		$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
	});
});

/* Legacy collapse code. Being kept for backwards compatibility.
   Based on WhiteMystery's original script, but it converts the legacy collapsibles instead. */

function legacyCollapsibles() {
	var allElements = document.getElementsByTagName("*");
	var collapsibleRegex = new RegExp("^co;(.+?);(.+?);(.+?);(.+?)(;(.+?))?$");
	for (var i = 0; i < allElements.length; i++) {
		if (collapsibleRegex.test(allElements[i].className)) {
			console.warn("One or more templates are using obsolete collapse code. Please convert said templates to the new format.");
			var collapsibleValues = collapsibleRegex.exec(allElements[i].className);
			var collapseText = collapsibleValues[1];
			var expandText = collapsibleValues[2];
			var defaultState = collapsibleValues[3];
			var correspondingContent = collapsibleValues[4];
			var toggleColor = collapsibleValues[6];
			allElements[i].className = "mw-customtoggle-" + correspondingContent + " collapsibletoggle showhidetext";
			allElements[i].style.color = toggleColor;
			var collapsibleContent = document.getElementsByClassName(correspondingContent);
			collapsibleContent[0].id = "mw-customcollapsible" + correspondingContent;
			if (defaultState == "0") {
				allElements[i].innerHTML = "<span class=\"collapsibletoggletext hiddentext\">" + collapseText + "</span><span class=\"collapsibletoggletext\">" + expandText + "</span>";
				collapsibleContent[0].className = "mw-collapsible mw-made-collapsible mw-collapsed";
				collapsibleContent[0].style.display = "none";
			}
			else {
				allElements[i].innerHTML = "<span class=\"collapsibletoggletext\">" + collapseText + "</span><span class=\"collapsibletoggletext hiddentext\">" + expandText + "</span>";
				collapsibleContent[0].className = "mw-collapsible mw-made-collapsible";
			}
		}
	}
}

$(document).ready(legacyCollapsibles);