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:29, 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;
            position:relative;
        ">
            <button type="button" style="
                cursor:pointer;
                padding:6px 10px;
            ">🌐 Language ▾</button>

            <div id="languageDropdownContent" style="
                display:none;
                position:absolute;
                top:100%;
                left:0;
                background:#fff;
                border:1px solid #ccc;
                min-width:160px;
                z-index:9999;
                box-shadow:0 2px 6px rgba(0,0,0,0.2);
            "></div>
        </div>
    `);

    // İçerik ekleme
    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>');
    }

    // Link stilleri (olmazsa üst üste yapışırlar)
    content.find("a").css({
        display: "block",
        padding: "8px 12px",
        textDecoration: "none",
        color: "#000",
        whiteSpace: "nowrap"
    });

    // Hover efekti, çünkü insanız
    content.find("a").hover(
        function() { $(this).css("background", "#f0f0f0"); },
        function() { $(this).css("background", "#fff"); }
    );

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

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

    // Dışarı tıklayınca kapat
    $(document).on("click", function() {
        $("#languageDropdownContent").hide();
    });
});