MediaWiki:Common.js: различия между версиями
Страница интерфейса MediaWiki
Дополнительные действия
Admin (обсуждение | вклад) Нет описания правки Метка: отменено |
Admin (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
||
| Строка 84: | Строка 84: | ||
var ip = element.getAttribute("data-ip"); | var ip = element.getAttribute("data-ip"); | ||
var port = element.getAttribute("data-port"); | var port = element.getAttribute("data-port"); | ||
var url = "https://node.goonhub.com | var url = "https://node.goonhub.com/status?ip="+encodeURIComponent(ip)+"&port="+encodeURIComponent(port); | ||
fetch(url) | fetch(url) | ||
.then(function(response) { | .then(function(response) { | ||
Версия от 10:47, 9 августа 2025
const pageName = mw.config.get("wgPageName");
if (pageName != "Шаблон:Таблица_Космический_Закон") {
let current = null;
let currentCell = null;
const table = document.getElementById("law");
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");
});
}
} else {
const allObjects = document.querySelectorAll(".law-object");
allObjects.forEach(el => el.style.display = "block");
}
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');
});
});
});
});
});
mw.loader.using('mediawiki.util', function () {
$(function () {
$('.colstr-header').each(function () {
$(this).on('click', function () {
const $panel = $(this).closest('.colstr-panel');
const isOpen = $panel.toggleClass('open').hasClass('open');
$(this).attr('aria-expanded', isOpen);
});
});
});
});
let isJopa = false;
if (pageName == "Заглавная_страница") {
document.querySelector('.pashalka-jopa-trigger').addEventListener('click', () => {
if (isJopa) return;
const container = document.querySelector('.pashalka-jopa');
const jopa = document.createElement('div');
jopa.className = 'jopa';
jopa.textContent = '>Ѡ<';
container.appendChild(jopa);
isJopa = true;
});
}
document.querySelectorAll(".server-hook").forEach(function(element) {
var ip = element.getAttribute("data-ip");
var port = element.getAttribute("data-port");
var url = "https://node.goonhub.com/status?ip="+encodeURIComponent(ip)+"&port="+encodeURIComponent(port);
fetch(url)
.then(function(response) {
if (!response.ok) {
throw new Error(response.status);
}
return response.json();
})
.then(function(data) {
element.textContent = data.response.players;
})
.catch(function(error) {
element.textContent = "⨉";
});
});