MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
document.addEventListener('DOMContentLoaded', function() { | |||
var popup = document.getElementById('concert-list-popup'); | |||
var trigger = document.getElementById('concert-list-trigger'); | |||
var closeButton = document.querySelector('.close-button'); | |||
trigger.addEventListener('click', function() { | |||
popup.style.display = 'flex'; | |||
}); | |||
closeButton.addEventListener('click', function() { | |||
popup.style.display = 'none'; | |||
}); | |||
window.addEventListener('click', function(event) { | |||
if (event.target == popup) { | |||
popup.style.display = 'none'; | |||
} | |||
}); | |||
}); | |||
Revision as of 00:47, 12 October 2024
document.addEventListener('DOMContentLoaded', function() {
var popup = document.getElementById('concert-list-popup');
var trigger = document.getElementById('concert-list-trigger');
var closeButton = document.querySelector('.close-button');
trigger.addEventListener('click', function() {
popup.style.display = 'flex';
});
closeButton.addEventListener('click', function() {
popup.style.display = 'none';
});
window.addEventListener('click', function(event) {
if (event.target == popup) {
popup.style.display = 'none';
}
});
});
document.addEventListener("DOMContentLoaded", function() {
var trigger = document.getElementById("trigger");
var popup = document.getElementById("popup");
trigger.addEventListener("click", function() {
if (popup.style.display === "none" || popup.style.display === "") {
popup.style.display = "block";
popup.style.top = trigger.offsetTop + trigger.offsetHeight + "px";
popup.style.left = trigger.offsetLeft + "px";
} else {
popup.style.display = "none";
}
});
// Закрытие окна при клике вне его
document.addEventListener("click", function(event) {
if (!trigger.contains(event.target) && !popup.contains(event.target)) {
popup.style.display = "none";
}
});
});
// MediaWiki:Common.js
$(document).ready(function() {
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false
}
});
});
document.addEventListener("DOMContentLoaded", function() {
var zoomBtn = document.getElementById('zoom-btn');
var image = document.getElementById('zoomable-image');
var zoomLevels = [1, 1.1, 1.2, 1.5, 1.8]; // Уровни зума
var currentZoomLevel = 0;
if (zoomBtn && image) {
zoomBtn.addEventListener('click', function() {
currentZoomLevel = (currentZoomLevel + 1) % zoomLevels.length;
image.style.transform = 'scale(' + zoomLevels[currentZoomLevel] + ')';
zoomBtn.textContent = 'Zoom ' + Math.round((zoomLevels[currentZoomLevel] - 1) * 100) + '%';
});
}
});
document.addEventListener("DOMContentLoaded", function() {
// Найдите элементы меню тем
var themeLinks = document.querySelectorAll('body #p-personal li#p-themes ul li a');
// Измените названия тем
themeLinks.forEach(function(link) {
if (link.textContent.includes('⧼theme-sai⧽')) {
link.textContent = 'SaI';
}
// Добавьте дополнительные условия для других тем
});
});
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using(['mediawiki.util'], function() {
var theme = mw.config.get('theme'); // Получить активную тему
if (theme === 'light') {
mw.util.addCSS('@import url("/extensions/ThemeToggle/modules/dropdownSwitcher/dark.css");');
} else if (theme === 'dark') {
mw.util.addCSS('@import url("/extensions/ThemeToggle/modules/dropdownSwitcher/dark.css");');
}
});
document.addEventListener('DOMContentLoaded', function() {
const toggle = document.querySelector('.mw-customtoggle-myDivision23');
const collapsible = document.getElementById('mw-customcollapsible-myDivision23');
toggle.addEventListener('click', function() {
collapsible.classList.toggle('open');
});
});
document.addEventListener('DOMContentLoaded', function() {
const tooltipTriggers = document.querySelectorAll('.underline-hover');
tooltipTriggers.forEach(trigger => {
trigger.addEventListener('click', function() {
const tooltip = this.querySelector('.tooltip-text');
tooltip.classList.toggle('show-tooltip');
});
});
});
// Получаем кнопку Themetoggle
const themeToggleBtn = document.querySelector('.theme-toggle-btn');
const infoboxElements = document.querySelectorAll('.infobox');
themeToggleBtn.addEventListener('click', () => {
// Проверяем, какая тема выбрана, и соответственно применяем стили к infobox
if (themeToggleBtn.classList.contains('dark-theme')) {
infoboxElements.forEach(element => {
element.style.backgroundColor = '#333';
element.style.color = '#fff';
});
} else {
infoboxElements.forEach(element => {
element.style.backgroundColor = '#fff';
element.style.color = '#000';
});
}
});
// Функция для генерации случайной страницы
function redirectToRandomPage() {
var pages = ['Page1', 'Page2', 'Page3']; // Замените на ваши страницы
var randomPage = pages[Math.floor(Math.random() * pages.length)];
window.location.href = mw.config.get('wgScript') + '?title=' + encodeURIComponent(randomPage);
}
// Добавляем обработчик к ссылке
$(document).ready(function() {
$('#random-link').click(function(event) {
event.preventDefault(); // Предотвращаем стандартное действие ссылки
redirectToRandomPage();
});
});
// Добавляем таблицу в нижний левый угол на всех страницах
$(document).ready(function() {
$('body').append('<div id="corner-table" class="wikitable" style="position: absolute; bottom: 0; left: 0; z-index: 1000;"><table><tr><td>Тест</td></tr></table></div>');
});
document.addEventListener("DOMContentLoaded", function() {
var themeElement = document.querySelector("body #p-personal li#p-themes");
if (themeElement) {
themeElement.style.borderRight = "1px solid #333";
themeElement.style.padding = "0 .5em";
themeElement.style.marginRight = "0";
themeElement.style.position = "relative";
themeElement.style.listStyle = "none";
themeElement.style.color = "black"; // Черный цвет текста
}
})