Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
Строка 1: Строка 1:
const table = document.getElementById("law");
const table = document.getElementById("law");


if (pageName === "Шаблон:Таблица_Космический_Закон") {
if (pageName != "Шаблон:Таблица_Космический_Закон") {
   const allObjects = document.querySelectorAll(".law-object");
   const allObjects = document.querySelectorAll(".law-object");
   allObjects.forEach(el => el.style.display = "block");
   allObjects.forEach(el => el.style.display = "none");
} else {
 
    let current = null;
  let current = null;
     let currentCell = null;
     let currentCell = null;
    const table = document.getElementById("law");
     if (table) {
     if (table) {
         table.addEventListener("click", function (event) {
         table.addEventListener("click", function (event) {
          const cell = event.target.closest("td");
        const cell = event.target.closest("td");
          if (!cell) return;
        if (!cell) return;
          if (!cell.dataset.id) return;
        if (!cell.dataset.id) return;
     
   
          if (current !== null) {
        if (current !== null) {
             document.getElementById(current).style.display = "none";
             document.getElementById(current).style.display = "none";
             if (currentCell) currentCell.classList.remove("law-selected");
             if (currentCell) currentCell.classList.remove("law-selected");
          }
        }
     
       
          if (cell.dataset.id === current) {
        if (cell.dataset.id === current) {
             current = null;
             current = null;
             currentCell = null;
             currentCell = null;
             return;
             return;
          }
        }
     
       
          current = cell.dataset.id;
        current = cell.dataset.id;
          currentCell = cell;
        currentCell = cell;
     
       
          document.getElementById(current).style.display = "block";
        document.getElementById(current).style.display = "block";
          cell.classList.add("law-selected");
        cell.classList.add("law-selected");
         });
         });
      }
    }
}
}



Версия от 01:57, 4 августа 2025

const table = document.getElementById("law");

if (pageName != "Шаблон:Таблица_Космический_Закон") {
  const allObjects = document.querySelectorAll(".law-object");
  allObjects.forEach(el => el.style.display = "none");

  let current = null;
    let currentCell = null;
    if (table) {
        table.addEventListener("click", function (event) {
        const cell = event.target.closest("td");
        if (!cell) return;
        if (!cell.dataset.id) return;
    
        if (current !== null) {
            document.getElementById(current).style.display = "none";
            if (currentCell) currentCell.classList.remove("law-selected");
        }
        
        if (cell.dataset.id === current) {
            current = null;
            currentCell = null;
            return;
        }
        
        current = cell.dataset.id;
        currentCell = cell;
        
        document.getElementById(current).style.display = "block";
        cell.classList.add("law-selected");
        });
    }
}

mw.loader.using('jquery', function () {
  $(function () {
    $('.vtabs').each(function () {
      const $container = $(this);
      const $buttons = $container.find('.vtabs-button');
      const $contents = $container.find('.vtabs-content');

      $buttons.each(function (index) {
        $(this).on('click', function () {
          $buttons.removeClass('active');
          $contents.removeClass('active');

          $(this).addClass('active');
          $contents.eq(index).addClass('active');
        });
      });
    });
  });
});