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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показаны 3 промежуточные версии этого же участника)
Строка 1: Строка 1:
document.addEventListener('DOMContentLoaded', function () {
(function () {
     var employees = document.querySelectorAll('.employee');
     if (window.raceInfoLoaded) return;
     for (var i = 0; i < employees.length; i++) {
     window.raceInfoLoaded = true;
         employees[i].addEventListener('click', function () {
 
            var employeeName = this.querySelector('div').textContent.trim();
    function showRaceInfo(race) {
             alert('Вы выбрали сотрудника: ' + employeeName);
         var infoBox = document.getElementById('race-info-box');
         });
        var description = document.getElementById(race);
        if (description) {
            infoBox.innerHTML = description.innerHTML;
             infoBox.style.display = 'block';
         }
     }
     }


     var guides = document.querySelector('.guides');
     document.addEventListener("DOMContentLoaded", function () {
    if (guides) {
        var cards = document.querySelectorAll('.race-card');
        guides.style.cursor = 'pointer';
        cards.forEach(function (card) {
        guides.addEventListener('click', function () {
            card.addEventListener("click", function (event) {
             alert('Открывается руководство');
                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"));
            });
        });
    });
})();