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: Difference between revisions

From Encyclopedia Dramatica
Jump to navigation Jump to search
imported>TabbyGarf
No edit summary
m actually, i think this was a bad idea.
 
(37 intermediate revisions by 5 users not shown)
Line 1: Line 1:
/* 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. */
 
//mw.loader.load("https://dev.fandom.com/wiki/MediaWiki:MarkBlocked.js?action=raw&ctype=text/javascript");
mw.loader.load("//edramatica.com/index.php?title=User:TabbyGarf/Scripts/ezRaep.js&action=raw&ctype=text/javascript");
setInterval(function () {
setInterval(function () {
   var elements = document.getElementsByClassName('blink');
   var elements = document.getElementsByClassName('blink');
Line 12: Line 13:
}, 1000);
}, 1000);


/*<pre>*/
/* Collapsible toggle */


/* Hook that enables collapsing objects.
$(document).ready(function() {
* Added 7/13/2008 by WhiteMystery (misterioblanco@gmail.com) */
$(".collapsibletoggletext").click(function() {
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext");
});
});


addOnloadHook(createToggleLinks);
/* Cycle forwards or backwards through elements one at a time via click */


/* Function that creates collapsing objects and toggle links.
$(function(){
* Added 7/13/2008 by WhiteMystery (misterioblanco@gmail.com) */
    $(".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");
        }
    });
    $(".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");
        }
    });
});


function createToggleLinks() {
/* Click link to show one or more items and hide other items */


var stateArray = new Array();
$(function() {
var allObjects = document.getElementsByTagName('span');
$(".morphlink").click(function() {
var rCollapsingObject = new RegExp("^co;(.+?);(.+?);(.+?);(.+?)(;(.+?))?$");
var correspondingContent = $(this).data("correspondingcontent");
 
if ($(this).parents(".morphcontainer").length) {
for ( var i = 0; i < allObjects.length; i++ ) {
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext");
 
if ($("#" + correspondingContent).length) // morphing object uses IDs
if ( rCollapsingObject.test(allObjects[i].className) ) {
$("#" + correspondingContent).removeClass("hiddentext");
 
else // morphing object uses classes
var collapsingInformation = rCollapsingObject.exec(allObjects[i].className);
$("." + correspondingContent).removeClass("hiddentext");
 
var collapseText = collapsingInformation[1];
var expandText = collapsingInformation[2];
var initialState = collapsingInformation[3];
var targetClass = collapsingInformation[4];
var linkColor = collapsingInformation[6];
 
var toggleLink = document.createElement("a");
 
if ( initialState == "0" ) {
 
toggleLink.appendChild(document.createTextNode(expandText));
stateArray[targetClass] = "none";
}
 
else {
 
toggleLink.appendChild(document.createTextNode(collapseText));
stateArray[targetClass] = "inline";
}
 
toggleLink.setAttribute("href", "javascript:toggleCollapse('" + targetClass + "','" + collapseText + "','" + expandText + "')");
 
if ( linkColor != undefined && linkColor != "undefined" && linkColor != "" )
toggleLink.style.color = linkColor;
 
allObjects[i].innerHTML = "";
allObjects[i].appendChild(toggleLink);
}
}
 
else {
else if ( allObjects[i].className == "morphMaster" ) {
if ($("#" + correspondingContent).length) { // morphing object uses IDs
 
$("#" + correspondingContent).removeClass("hiddentext");
var spanID = allObjects[i].getAttribute("id");
$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
var targetID = spanID.substr(0, spanID.length - 6);
var counter = 1;
 
// Create forward and backward paging if the paging elements exist
if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) {
 
// Create the forward link
var nextLink = document.createElement("a");
nextLink.appendChild(document.createTextNode(returnObjById(targetID + "LinkNext").innerHTML));
nextLink.setAttribute("href", "javascript:morphForward('" + targetID + "')");
 
returnObjById(targetID + "LinkNext").innerHTML = "";
returnObjById(targetID + "LinkNext").appendChild(nextLink, 0);
 
// Create the backward link
var prevLink = document.createElement("a");
prevLink.appendChild(document.createTextNode(returnObjById(targetID + "LinkPrev").innerHTML));
prevLink.setAttribute("href", "javascript:morphBackward('" + targetID + "')");
 
returnObjById(targetID + "LinkPrev").innerHTML = "";
returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0);
 
// Initialize content panes
while ( returnObjById(targetID + "Content" + counter) ) {
 
if ( counter == 1 )
returnObjById(targetID + "Content" + counter).style.display = "inline";
else
returnObjById(targetID + "Content" + counter).style.display = "none";
 
counter++;
}
}
}
 
else { // morphing object uses classes
counter = 1;
$("." + correspondingContent).removeClass("hiddentext");
 
$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
// Whether or not there is paging, generate normal links
while ( returnObjById(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter) ) {
 
var morphLink = document.createElement("a");
morphLink.appendChild(document.createTextNode(returnObjById(targetID + "Link" + counter).innerHTML));
morphLink.setAttribute("href", "javascript:performMorph('" + targetID + "','" + counter + "')");
 
returnObjById(targetID + "Link" + counter).innerHTML = "";
returnObjById(targetID + "Link" + counter).appendChild(morphLink, 0);
 
// Initialize content panes
if ( counter == 1 )
returnObjById(targetID + "Content" + counter).style.display = "inline";
else
returnObjById(targetID + "Content" + counter).style.display = "none";
 
counter++;
}
}
allObjects[i].innerHTML = "1";
allObjects[i].style.display = "none";
}
}
}
});
 
});
// Set state of appropriate objects
allObjects = document.getElementsByTagName('*');
 
for ( var i = 0; i < allObjects.length; i++ ) {
 
if ( stateArray[allObjects[i].className] )
allObjects[i].style.display = stateArray[allObjects[i].className];
}
}
 
/* Function that toggles collapsing objects.
* Added 7/13/2008 by WhiteMystery ([email protected]) */
 
function toggleCollapse(targetClass, collapseText, expandText) {
 
var allObjects = document.getElementsByTagName('*');
var rCollapsingObject = new RegExp("^co;(.+?);(.+?);(.+?);" + targetClass + "(;(.+?))?$");
 
var linkType;
 
for ( var i = 0; i < allObjects.length; i++ ) {
 
if ( allObjects[i].className == targetClass ) {
 
if ( allObjects[i].style.display == "none" ) {
 
allObjects[i].style.display = "inline";
linkType = "Collapse";
}


else {
/* Legacy collapse code. Being kept for backwards compatibility.
  Based on WhiteMystery's original script, but jQuery-fied. */


allObjects[i].style.display = "none";
function createLegacyCollapsibles() {
linkType = "Expand";
var allElements = $("span");
var collapsibleRegex = new RegExp("^co;(.+?);(.+?);(.+?);(.+?)(;(.+?))?$");
for (var i = 0; i < allElements.length; i++) {
if (collapsibleRegex.test(allElements[i].className)) {
console.warn("co; is deprecated. Use collapsibletoggle instead.");
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];
var collapsibleContent = $("." + correspondingContent);
var toggleLink;
allElements[i].innerHTML = "<a class=\"collapsibletoggle legacycollapsible\" data-collapsetext=\"" + collapseText + "\" data-expandtext=\"" + expandText + "\" data-correspondingcontent=\"" + correspondingContent + "\"></a>";
toggleLink = $(allElements[i]).find("a");
if (defaultState == "0") {
toggleLink[0].innerHTML = expandText;
collapsibleContent[0].className += " hiddentext";
}
}
}
else
}
toggleLink[0].innerHTML = collapseText;
 
if (toggleColor)
allObjects = document.getElementsByTagName('span');
toggleLink[0].style.color = toggleColor;
 
for ( var i = 0; i < allObjects.length; i++ ) {
 
if ( rCollapsingObject.test(allObjects[i].className) ) {
 
var collapsingInformation = rCollapsingObject.exec(allObjects[i].className);
 
var collapseText = collapsingInformation[1];
var expandText = collapsingInformation[2];
var linkColor = collapsingInformation[5];
 
var toggleLink = document.createElement("a");
 
if ( linkType == "Expand" )
 
toggleLink.appendChild(document.createTextNode(expandText));
 
else if ( linkType == "Collapse" )
 
toggleLink.appendChild(document.createTextNode(collapseText));
 
toggleLink.setAttribute("href", "javascript:toggleCollapse('" + targetClass + "','" + collapseText + "','" + expandText + "')");
 
if ( linkColor != undefined && linkColor != "undefined" && linkColor != "" )
toggleLink.style.color = linkColor;
 
allObjects[i].innerHTML = "";
allObjects[i].appendChild(toggleLink);
}
}
}
}
}
}


/* Functions that perform the morph operations.
$(document).ready(function() {
* Added 8/13/2008 by WhiteMystery (misterioblanco@gmail.com) */
createLegacyCollapsibles();
 
$(".legacycollapsible").click(function() {
function performMorph(targetID, targetNumber) {
var expandText = $(this).data("expandtext");
 
var collapseText = $(this).data("collapsetext");
var counter = 1;
var correspondingContent = $(this).data("correspondingcontent");
 
$("." + correspondingContent).toggleClass("hiddentext");
while ( returnObjById(targetID + "Content" + counter) ) {
if ($(this).text() == expandText)
 
$(this).text(collapseText);
if ( counter == targetNumber )
returnObjById(targetID + "Content" + counter).style.display = "block";
else
else
returnObjById(targetID + "Content" + counter).style.display = "none";
$(this).text(expandText);
 
});
counter++;
}
 
returnObjById(targetID + "Master").innerHTML = targetNumber;
}
 
function morphForward(targetID) {
 
var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1;
 
if ( returnObjById(targetID + "Content" + nextPane) )
performMorph(targetID, nextPane);
 
else
performMorph(targetID, "1");
}
 
function morphBackward(targetID) {
 
var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1;
 
if ( prevPane > 0 )
performMorph(targetID, prevPane);
 
else {
 
var maxIndex = 1;
 
while ( returnObjById(targetID + "Content" + maxIndex) )
maxIndex++;
 
performMorph(targetID, maxIndex - 1);
}
}
 
/* Function that returns an object by ID for various browsers
* Taken from http://www.netlobo.com/javascript_get_element_id.html */
 
function returnObjById( id ) {
 
    if (document.getElementById)
        var returnVar = document.getElementById(id);
 
    else if (document.all)
        var returnVar = document.all[id];
 
    else if (document.layers)
        var returnVar = document.layers[id];
 
    return returnVar;
}
 
// Begin ED 2 Customs ([email protected])
 
$(function() {
    // ED IRC Embeds.
    var embeds = $("span.zalgo-fetch-irc-heading")
      , channels = [];
 
    if(!embeds.length) return;
    embeds.each(function() {
        channels.push($(this).find('a').text().substr(1));
    });
   
    channels = encodeURI(channels.join(','));
   
    $.getJSON("https://web.archive.org/web/20170423054220/https://zalgo.encyclopediadramatica.se/api/0/channels/" + channels + ".json?_=" + $.now(), function(response)
    {
        embeds.each(function() {
            var $e = $(this)
              , $a = $e.find('a')
              , channel = $a.text()
              , data = response[channel.toLowerCase()];
 
            if(!data) return;     
     
            $e.after(" <small style='color: grey; font-size:.7em;'>[" + data.modes + "] (<a href=\"https://zalgo.encyclopediadramatica.se/channel/"
                    + encodeURI(channel.substr(1)) +"\" target=\"_blank\">" + data.users + " users online</a>)</small>");
            $a.text(data.name);
 
        });
    });
});
 
/* Wikipedo Head Notify */
$(function wikiHeaderShow() {
    if (document.location.pathname != "/Encyclopedia_Dramatica:About" || !(/^https?:\/\/.*\.wikipedia.org/.test(document.referrer)))
        return;
       
    function hideHeader(e) {
        e.preventDefault();
        $(this).fadeOut();
        $heading.slideUp(500, function() {
            $heading.remove();
        });
        $top.animate({"top": "0px"}, 500);
       
    }
       
    var $heading = $("<div></div>");
    var $top = $("#globalWrapper");
    var $closeBtn = $("<a></a>").html("&cross;").css({"position": "absolute", "top": "6px", "right": "15px"}).click(hideHeader).hide();
   
    $heading
        .css({
            "backgroundColor": "rgb(253, 253, 218)",
            "height": "75px",
            "width": "100%",
            "paddingTop": "25px",
            "borderBottom": "1px solid black",
            "fontSize": "25px",
            "textAlign": "center",
        })
        .text("Hey! Are you looking for our ")
        .append($("<a></a>").text("Main Page").attr('href', "/Main_Page").css({"color": "red"}))
        .append("?")
        .append($("<br />"))
        .append($("<small></small>").text("(we noticed you were directed here by clicking on the link on our Wikipedia article, chances are you're looking for our ")
                                    .append($("<a></a>").text("Main Page").attr('href', "/Main_Page"))
                                    .append(" rather than this dull about page)")
                                    .css({"fontSize": "13px", "color": "grey", "fontStyle": "italic"}))
        .append($closeBtn)
        .hide();
 
    $top.css({
        "position": "absolute"
    });
   
    $heading.insertBefore($top);
 
    setTimeout(function() {   
        $top.animate({"top": "100px"}, 500);
        $heading.slideDown(500, function() { $closeBtn.fadeIn() });
    }, 300);
});
});
/*</pre>*/
}
/*
    FILE ARCHIVED ON 05:42:20 Apr 23, 2017 AND RETRIEVED FROM THE
    INTERNET ARCHIVE ON 16:49:45 Mar 02, 2021.
    JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
    ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
    SECTION 108(a)(3)).
*/
/*
playback timings (ms):
  captures_list: 506.502
  exclusion.robots: 309.832
  exclusion.robots.policy: 309.822
  xauthn.identify: 147.434
  xauthn.chkprivs: 162.157
  RedisCDXSource: 105.242
  esindex: 0.011
  LoadShardBlock: 72.577 (3)
  PetaboxLoader3.datanode: 99.691 (5)
  CDXLines.iter: 16.134 (3)
  load_resource: 1068.492 (2)
  PetaboxLoader3.resolve: 901.03 (2)
*/

Latest revision as of 15:56, 24 October 2024

/* Any JavaScript here will be loaded for all users on every page load. */
//mw.loader.load("https://dev.fandom.com/wiki/MediaWiki:MarkBlocked.js?action=raw&ctype=text/javascript");
mw.loader.load("//edramatica.com/index.php?title=User:TabbyGarf/Scripts/ezRaep.js&action=raw&ctype=text/javascript");
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").toggleClass("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");
         }
    });
    $(".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 */

$(function() {
	$(".morphlink").click(function() {
		var correspondingContent = $(this).data("correspondingcontent");
		if ($(this).parents(".morphcontainer").length) {
			$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext");
			if ($("#" + correspondingContent).length) // morphing object uses IDs
				$("#" + correspondingContent).removeClass("hiddentext");
			else // morphing object uses classes
				$("." + correspondingContent).removeClass("hiddentext");
		}
		else {
			if ($("#" + correspondingContent).length) { // morphing object uses IDs
				$("#" + correspondingContent).removeClass("hiddentext");
				$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
			}
			else { // morphing object uses classes
				$("." + correspondingContent).removeClass("hiddentext");
				$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
			}
		}
	});
});

/* Legacy collapse code. Being kept for backwards compatibility.
   Based on WhiteMystery's original script, but jQuery-fied. */

function createLegacyCollapsibles() {
	var allElements = $("span");
	var collapsibleRegex = new RegExp("^co;(.+?);(.+?);(.+?);(.+?)(;(.+?))?$");
	for (var i = 0; i < allElements.length; i++) {
		if (collapsibleRegex.test(allElements[i].className)) {
			console.warn("co; is deprecated. Use collapsibletoggle instead.");
			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];
			var collapsibleContent = $("." + correspondingContent);
			var toggleLink;
			allElements[i].innerHTML = "<a class=\"collapsibletoggle legacycollapsible\" data-collapsetext=\"" + collapseText + "\" data-expandtext=\"" + expandText + "\" data-correspondingcontent=\"" + correspondingContent + "\"></a>";
			toggleLink = $(allElements[i]).find("a");
			if (defaultState == "0") {
				toggleLink[0].innerHTML = expandText;
				collapsibleContent[0].className += " hiddentext";
			}
			else
				toggleLink[0].innerHTML = collapseText;
			if (toggleColor)
				toggleLink[0].style.color = toggleColor;
		}
	}
}

$(document).ready(function() {
	createLegacyCollapsibles();
	$(".legacycollapsible").click(function() {
		var expandText = $(this).data("expandtext");
		var collapseText = $(this).data("collapsetext");
		var correspondingContent = $(this).data("correspondingcontent");
		$("." + correspondingContent).toggleClass("hiddentext");
		if ($(this).text() == expandText)
			$(this).text(collapseText);
		else
			$(this).text(expandText);
	});
});