MediaWiki:Common.js

From The Portal Wiki
Revision as of 16:01, 18 July 2020 by Aardvark (talk | contribs) (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: →‎Make the language and edition selectors work: function showLanguage(event, language) { var...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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. */
/* Make the language and edition selectors work */
function showLanguage(event, language) {

    var i, langcontent, languagetab, newcontent;

    // Get all elements with class="language-content" and hide them
    langcontent = document.getElementsByClassName("language-items");
    for (i = 0; i < langcontent.length; i++) {
      langcontent[i].style.display = "none";
    }

    // Get all elements with class="tab-language" and remove the class "active"
    languagetab = document.getElementsByClassName("tab-language");
    for (i = 0; i < languagetab.length; i++) {
      languagetab[i].className = languagetab[i].className.replace(" active", "");
    }

    // Show the current content, and add an "active" class to the button that opened the tab
    newcontent = document.getElementsByClassName("language-items" + " " + language);
    for (i = 0; i < newcontent.length; i++) {
      newcontent[i].style.display = "initial";
    }
    event.currentTarget.className += " active";
    return;
}

function showEdition(event, edition) {
    return;
}