Toggle menu
7
27
38
5.2K
Sanarchive
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js

MediaWiki interface page
Revision as of 20:33, 11 January 2026 by Pumpkin (talk | contribs)

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)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
$(function() {
    // Sadece anasayfada çalışacak
    if (!mw.config.get("wgIsMainPage")) return;

    var host = window.location.hostname;

    // Dropdown HTML
    var dropdown = $(`
        <div id="languageDropdown" style="display:inline-block;">
            <button>🌐 Language ▾</button>
            <div id="languageDropdownContent" style="display:none;"></div>
        </div>
    `);

    // İçerik
    var content = $("#languageDropdownContent", dropdown);

    if (host === "tr.sanarsiv.org") {
        content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>');
        content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>');
    } 
    else if (host === "az.sanarsiv.org") {
        content.append('<a href="https://az.sanarsiv.org/wiki/Ana_səhifə">Azərbaycanca</a>');
        content.append('<a href="https://tr.sanarsiv.org/">Türkçe</a>');
    }

    // Sayfaya ekle
    $("#content").append(dropdown);

    // Aç / kapa
    $("#languageDropdown button").click(function(e) {
        e.stopPropagation();
        $("#languageDropdownContent").toggle();
    });

    // Dışarı tıklayınca kapat
    $(document).click(function(event) {
        if (!$(event.target).closest('#languageDropdown').length) {
            $("#languageDropdownContent").hide();
        }
    });
});