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
imported>MarioMario456
will see if this works or not
Line 49: Line 49:
/* Click link to show one or more items and hide other items */
/* Click link to show one or more items and hide other items */


/* function morph(){
function morph(){
     var elements = document.getElementsByClassName("morphlink");
     var elements = document.getElementsByClassName("morphlink");
     for(let i = 0; i < elements.length; i++){
     for(let i = 0; i < elements.length; i++){
Line 65: Line 65:
}
}


morph();*/
morph();

Revision as of 14:50, 20 September 2021

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

$(function(){
    $(".collapsibletoggle").find(".collapsibletoggletext").click(function(){
        $(this).closest(".collapsibletoggle").find(".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");
         }
    });
});

$(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 */

function morph(){
    var elements = document.getElementsByClassName("morphlink");
    for(let i = 0; i < elements.length; i++){
        elements[i].addEventListener("click",function(){
            var selectedElement = document.getElementById(this.dataset.correspondingcontent);
            selectedElement.classList.remove("hiddentext");
            var selectedSiblings = selectedElement.parentNode.children;
            for(let j = 0; j < selectedSiblings.length; j++){
                if(selectedSiblings[j].classList.contains("morphcontent")){
                    selectedSiblings[j].classList.add("hiddentext");
                }
            }
        });
    }
}

morph();