MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показаны 2 промежуточные версии этого же участника)
Строка 1: Строка 1:
if (mw.config.get('wgPageName') === 'Тест') {
(function () {
     window.addEventListener('load', function () {
     if (window.raceInfoLoaded) return;
        var banner = document.createElement('div');
    window.raceInfoLoaded = true;
        banner.id = 'info-banner';
        banner.innerHTML = 'Внимание: информация на этой странице может измениться!';
        document.body.appendChild(banner);
       
        var style = document.createElement('style');
        style.innerHTML =
            '#info-banner {' +
            'position: fixed;' +
            'top: 0;' +
            'left: 0;' +
            'width: 100%;' +
            'background-color: #f0ad4e;' +
            'color: #fff;' +
            'text-align: center;' +
            'padding: 10px 0;' +
            'font-size: 16px;' +
            'z-index: 9999;' +
            'font-weight: bold;' +
            '}';


         document.head.appendChild(style);
    function showRaceInfo(race) {
         var infoBox = document.getElementById('race-info-box');
        var description = document.getElementById(race);
        if (description) {
            infoBox.innerHTML = description.innerHTML;
            infoBox.style.display = 'block';
        }
    }


         banner.addEventListener('click', function () {
    document.addEventListener("DOMContentLoaded", function () {
            banner.style.display = 'none';
         var cards = document.querySelectorAll('.race-card');
        cards.forEach(function (card) {
            card.addEventListener("click", function (event) {
                event.preventDefault();
                showRaceInfo(card.getAttribute("data-race"));
            });
         });
         });
     });
     });
}
})();

Текущая версия от 21:18, 15 февраля 2025

(function () {
    if (window.raceInfoLoaded) return;
    window.raceInfoLoaded = true;

    function showRaceInfo(race) {
        var infoBox = document.getElementById('race-info-box');
        var description = document.getElementById(race);
        if (description) {
            infoBox.innerHTML = description.innerHTML;
            infoBox.style.display = 'block';
        }
    }

    document.addEventListener("DOMContentLoaded", function () {
        var cards = document.querySelectorAll('.race-card');
        cards.forEach(function (card) {
            card.addEventListener("click", function (event) {
                event.preventDefault();
                showRaceInfo(card.getAttribute("data-race"));
            });
        });
    });
})();