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.
 
(39 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);


function ModifySidebar( action, section, name, link ) {
/* Collapsible toggle */
try {
switch ( section ) {
case 'languages':
var target = 'p-lang';
break;
case 'toolbox':
var target = 'p-tb';
break;
case 'navigation':
var target = 'p-navigation';
break;
default:
var target = 'p-' + section;
break;
}
 
if ( action == 'add' ) {
var node = document.getElementById( target )
  .getElementsByTagName( 'div' )[0]
  .getElementsByTagName( 'ul' )[0];


var aNode = document.createElement( 'a' );
$(document).ready(function() {
var liNode = document.createElement( 'li' );
$(".collapsibletoggletext").click(function() {
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext");
});
});


aNode.appendChild( document.createTextNode( name ) );
/* Cycle forwards or backwards through elements one at a time via click */
aNode.setAttribute( 'href', link );
liNode.appendChild( aNode );
liNode.className = 'plainlinks';
node.appendChild( liNode );
}


if ( action == 'remove' ) {
$(function(){
var list = document.getElementById( target )
    $(".cyclesequence").find(".cyclesequencelinknext").click(function(){
  .getElementsByTagName( 'div' )[0]
        if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").length === 0) {
  .getElementsByTagName( 'ul' )[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");
        }
    });
});


var listelements = list.getElementsByTagName( 'li' );
/* Click link to show one or more items and hide other items */


for ( var i = 0; i < listelements.length; i++ ) {
$(function() {
if (
$(".morphlink").click(function() {
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
var correspondingContent = $(this).data("correspondingcontent");
listelements[i].getElementsByTagName( 'a' )[0].href == link
if ($(this).parents(".morphcontainer").length) {
)
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext");
{
if ($("#" + correspondingContent).length) // morphing object uses IDs
list.removeChild( listelements[i] );
$("#" + 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. */


} catch( e ) {
function createLegacyCollapsibles() {
// let's just ignore what's happened
var allElements = $("span");
return;
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;
}
}
}
}
}


function CustomizeModificationsOfSidebar() {
$(document).ready(function() {
// adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
createLegacyCollapsibles();
ModifySidebar( 'add', 'toolbox', 'Sysop Tasks', 'https://www.encyclopediadramatica.online/index.php?title=ED:ST' );
$(".legacycollapsible").click(function() {
ModifySidebar( 'add', 'toolbox', 'Moderation', 'https://www.encyclopediadramatica.online/index.php?title=Special:Moderation' );
var expandText = $(this).data("expandtext");
ModifySidebar( 'add', 'toolbox', 'Broken Pix', 'https://www.encyclopediadramatica.online/index.php?title=Category:Pages_with_broken_file_links' );
var collapseText = $(this).data("collapsetext");
// removes [[Special:Upload|Special:Upload]] from toolbox
var correspondingContent = $(this).data("correspondingcontent");
 
$("." + correspondingContent).toggleClass("hiddentext");
}
if ($(this).text() == expandText)
 
$(this).text(collapseText);
jQuery( CustomizeModificationsOfSidebar );
else
$(this).text(expandText);
});
});

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