MediaWiki:Common.js: различия между версиями
Страница интерфейса MediaWiki
Дополнительные действия
Admin (обсуждение | вклад) Нет описания правки |
Admin (обсуждение | вклад) Нет описания правки |
||
| Строка 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 = " | allObjects.forEach(el => el.style.display = "none"); | ||
let current = null; | |||
let currentCell = null; | let currentCell = null; | ||
if (table) { | if (table) { | ||
table.addEventListener("click", function (event) { | 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"; | 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) { | |||
current = null; | current = null; | ||
currentCell = null; | currentCell = null; | ||
return; | return; | ||
} | |||
current = cell.dataset.id; | |||
currentCell = cell; | |||
document.getElementById(current).style.display = "block"; | |||
cell.classList.add("law-selected"); | |||
}); | }); | ||
} | |||
} | } | ||