MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
mNo edit summary
mNo edit summary
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( '/w/index.php?title=MediaWiki:ResponsiveImageMap.js&action=raw&ctype=text/javascript' );
mw.loader.load('/w/index.php?title=MediaWiki:ResponsiveImageMap.js&action=raw&ctype=text/javascript');


$(document).ready(function() {
$(document).ready(function() {
  /* handle the colorful-mode and monochrome mode button */
    /* handle the colorful-mode and monochrome mode button */
  if (localStorage.getItem("client-monochrome-toggle") === "1") {
    if (localStorage.getItem("client-monochrome-toggle") === "1") {
    var allElements = document.querySelectorAll(".colorful-text");
        var allElements = document.querySelectorAll(".colorful-text");
    for(i=0; i<allElements.length; i++)
        for (i = 0; i < allElements.length; i++) {
    {  
            allElements[i].classList.remove('colorful-text');
      allElements[i].classList.remove('colorful-text');
        }
    }
    }
  }


  //==== Movelist Toggles ==== Written by SageVarq
    //==== Movelist Toggles ==== Written by SageVarq
  if (document.getElementsByClassName("movelist-toggles")) {
    if (document.getElementsByClassName("movelist-toggles")) {
    // Hide all move lists
        // Hide all move lists
    var $movelists = $('.movelist');
        var $movelists = $('.movelist');


    var currentMovelist = 1;
        var currentMovelist = 1;


    displayMovelist(currentMovelist);
        displayMovelist(currentMovelist);
    $('.movelist-toggle-button').each(addToggles);
        $('.movelist-toggle-button').each(addToggles);


    function swapMovelist(e) {
        function swapMovelist(e) {
      var movelistToggleClicked = $(this).data("id");
            var movelistToggleClicked = $(this).data("id");
      var nextMovelist = movelistToggleClicked.substring(movelistToggleClicked.length - 1);
            var nextMovelist = movelistToggleClicked.substring(movelistToggleClicked.length - 1);
      if (currentMovelist != nextMovelist) {
            if (currentMovelist != nextMovelist) {
        currentMovelist = nextMovelist;
                currentMovelist = nextMovelist;
        displayMovelist(nextMovelist);
                displayMovelist(nextMovelist);
      }
            }
    }
        }


    function displayMovelist(target) {
        function displayMovelist(target) {
      hideAllMovelists();
            hideAllMovelists();
      $("#movelist-" + target).css("display", "block");
            $("#movelist-" + target).css("display", "block");
      $("#movelist-toggle-" + target).addClass("movelist-toggle-on");
            $("#movelist-toggle-" + target).addClass("movelist-toggle-on");
    }
        }


    function hideAllMovelists() {
        function hideAllMovelists() {
      $movelists.css("display", "none");
            $movelists.css("display", "none");
      $('.movelist-toggle-button').removeClass("movelist-toggle-on").addClass("movelist-toggle-off");
            $('.movelist-toggle-button').removeClass("movelist-toggle-on").addClass("movelist-toggle-off");
    }
        }


    function addToggles() {
        function addToggles() {
      $(this).data("id", $(this).attr("id"));
            $(this).data("id", $(this).attr("id"));
      $(this).click(swapMovelist);
            $(this).click(swapMovelist);
        }
     }
     }
  }


  $('.frameChart-toggle-off').click(function() {
    $('.frameChart-toggle-off').click(function() {
    $('.frameChart-toggle-off').hide();
        $('.frameChart-toggle-off').hide();
    $('.frameChart-toggle-on').show();
        $('.frameChart-toggle-on').show();
    $('.frameChart').hide();
        $('.frameChart').hide();
  });
    });


  $('.frameChart-toggle-on').click(function() {
    $('.frameChart-toggle-on').click(function() {
    $('.frameChart-toggle-off').show();
        $('.frameChart-toggle-off').show();
    $('.frameChart-toggle-on').hide();
        $('.frameChart-toggle-on').hide();
    $('.frameChart').show();
        $('.frameChart').show();
  });
    });


})(this, jQuery, mediaWiki);
})(this, jQuery, mediaWiki);

Revision as of 13:48, 16 August 2022

/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.load('/w/index.php?title=MediaWiki:ResponsiveImageMap.js&action=raw&ctype=text/javascript');

$(document).ready(function() {
    /* handle the colorful-mode and monochrome mode button */
    if (localStorage.getItem("client-monochrome-toggle") === "1") {
        var allElements = document.querySelectorAll(".colorful-text");
        for (i = 0; i < allElements.length; i++) {
            allElements[i].classList.remove('colorful-text');
        }
    }

    //==== Movelist Toggles ==== Written by SageVarq
    if (document.getElementsByClassName("movelist-toggles")) {
        // Hide all move lists
        var $movelists = $('.movelist');

        var currentMovelist = 1;

        displayMovelist(currentMovelist);
        $('.movelist-toggle-button').each(addToggles);

        function swapMovelist(e) {
            var movelistToggleClicked = $(this).data("id");
            var nextMovelist = movelistToggleClicked.substring(movelistToggleClicked.length - 1);
            if (currentMovelist != nextMovelist) {
                currentMovelist = nextMovelist;
                displayMovelist(nextMovelist);
            }
        }

        function displayMovelist(target) {
            hideAllMovelists();
            $("#movelist-" + target).css("display", "block");
            $("#movelist-toggle-" + target).addClass("movelist-toggle-on");
        }

        function hideAllMovelists() {
            $movelists.css("display", "none");
            $('.movelist-toggle-button').removeClass("movelist-toggle-on").addClass("movelist-toggle-off");
        }

        function addToggles() {
            $(this).data("id", $(this).attr("id"));
            $(this).click(swapMovelist);
        }
    }

    $('.frameChart-toggle-off').click(function() {
        $('.frameChart-toggle-off').hide();
        $('.frameChart-toggle-on').show();
        $('.frameChart').hide();
    });

    $('.frameChart-toggle-on').click(function() {
        $('.frameChart-toggle-off').show();
        $('.frameChart-toggle-on').hide();
        $('.frameChart').show();
    });

})(this, jQuery, mediaWiki);