Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 23: | Строка 23: | ||
}); | }); | ||
/*Блок временно*/ | |||
if (mw.config.get('wgPageName') === 'Лордзос') { | |||
window.addEventListener('load', function () { | |||
var banner = document.createElement('div'); | |||
banner.id = 'info-banner'; | |||
banner.style.position = 'fixed'; | |||
banner.style.top = '0'; | |||
banner.style.left = '0'; | |||
banner.style.width = '100%'; | |||
banner.style.backgroundColor = '#f0ad4e'; | |||
banner.style.color = '#fff'; | |||
banner.style.textAlign = 'center'; | |||
banner.style.padding = '10px 0'; | |||
banner.style.fontSize = '16px'; | |||
banner.style.zIndex = '9999'; | |||
banner.style.fontWeight = 'bold'; | |||
banner.innerHTML = 'Внимание: информация на этой странице может измениться!'; | |||
document.body.appendChild(banner); | |||
banner.addEventListener('click', function () { | |||
banner.style.display = 'none'; | |||
}); | |||
}); | |||
} | |||
Версия от 12:24, 26 января 2025
/*Подгрузка внешних css js*/
mw.loader.using('mediawiki.util', function () {
var files = mw.util.getParamValue('use'),
userName = mw.config.get('wgUserName') || '', // Обрабатываем null
FileRE = new RegExp('^(?:MediaWiki:|User:' + mw.util.escapeRegExp(userName) + '/)?[^&<>=%#]*\\.(js|css)$'),
path = mw.config.get('wgServer').replace(/^http:/, 'https:') + mw.config.get('wgScript') + '?action=raw&ctype=text/';
if (!files) return;
$.each(files.split('|'), function (k, v) {
var file = $.trim(v), match = FileRE.exec(file);
if (match) {
switch (match[1]) {
case 'js':
mw.loader.load(path + 'javascript&title=' + encodeURIComponent(file), 'text/javascript');
break;
case 'css':
mw.loader.load(path + 'css&title=' + encodeURIComponent(file), 'text/css');
break;
}
}
});
});
/*Блок временно*/
if (mw.config.get('wgPageName') === 'Лордзос') {
window.addEventListener('load', function () {
var banner = document.createElement('div');
banner.id = 'info-banner';
banner.style.position = 'fixed';
banner.style.top = '0';
banner.style.left = '0';
banner.style.width = '100%';
banner.style.backgroundColor = '#f0ad4e';
banner.style.color = '#fff';
banner.style.textAlign = 'center';
banner.style.padding = '10px 0';
banner.style.fontSize = '16px';
banner.style.zIndex = '9999';
banner.style.fontWeight = 'bold';
banner.innerHTML = 'Внимание: информация на этой странице может измениться!';
document.body.appendChild(banner);
banner.addEventListener('click', function () {
banner.style.display = 'none';
});
});
}
/* Лого сайта */
var logoElement = document.getElementsByClassName('citizen-header__logo')[0];
if (logoElement) {
logoElement.innerHTML = '<div class="logo1"><a href="https://spacestories.club/index.php?title=Заглавная страница" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу"><img class="mw-logo-icon" src="/resources/assets/logo.png" alt="" aria-hidden="true" height="32" width="32"></a></div><div class="logo2"><a href="https://spacestories.club/index.php?title=Colonial_Marines" class="mw-logo citizen-header__button" title="Перейти на заглавную страницу CM"><img class="mw-logo-icon" src="/images/0/0d/CMlog.png" alt="" aria-hidden="true" height="32" width="32"></a></div>';
}
/* Перенос page-info в конец footer-places */
var footerPlaces = document.getElementById('footer-places');
var pageInfo = document.getElementsByClassName('page-info')[0];
if (footerPlaces && pageInfo) {
footerPlaces.insertAdjacentHTML('afterEnd', pageInfo.innerHTML);
pageInfo.innerHTML = '';
}
/* Логика цвета через headerColor */
var headerColorElement = document.getElementsByClassName('headerColor')[0];
if (headerColorElement) {
var isValidColor = function (color) {
var el = document.createElement('div');
el.style.backgroundColor = color;
return !!el.style.backgroundColor;
};
var headerContent = headerColorElement.innerHTML;
var colorBorder = '', colorBtn = '', i = 0;
while (headerContent[i] !== '|' && i < headerContent.length) {
colorBorder += headerContent[i++];
}
i++;
while (i < headerContent.length) {
colorBtn += headerContent[i++];
}
if (isValidColor(colorBorder) && isValidColor(colorBtn)) {
var headerRender = function (colorBorder, colorBtn) {
var headers = document.querySelectorAll('h1, h2, h3, h4, h5');
for (var j = 0; j < headers.length; j++) {
var header = headers[j];
if (header.className === 'citizen-section-heading') {
var indicator = header.querySelector('.citizen-sections-enabled, .citizen-section-indicator');
var headline = header.querySelector('.mw-headline');
if (indicator) {
indicator.style.background = colorBtn;
indicator.style.boxShadow = '0 0 20px 0px ' + colorBtn + 'cc';
}
if (headline) {
headline.style.borderImage = 'linear-gradient(to right top, ' + colorBorder + ', black)';
headline.style.borderImageSlice = '1';
}
} else if (header.className === 'citizen-section-heading citizen-section-heading--collapsed') {
var collapsedIndicator = header.querySelector('.citizen-sections-enabled, .citizen-section-heading--collapsed, .citizen-section-indicator');
if (collapsedIndicator) {
collapsedIndicator.style.background = 'black';
collapsedIndicator.style.boxShadow = 'unset';
}
}
}
};
headerRender(colorBorder, colorBtn);
document.body.addEventListener('click', function () {
headerRender(colorBorder, colorBtn);
});
}
}
/* Sidebar для ролей */
var jobsContainer = document.getElementsByClassName('JobsTableContainer')[0];
if (jobsContainer) {
var bodyContent = document.getElementById('bodyContent');
if (bodyContent) {
bodyContent.insertAdjacentHTML('beforebegin', jobsContainer.innerHTML);
}
var jobTable = document.getElementById('IdJobsTableContainer1');
if (jobTable) {
jobTable.id = 'IdJobsTableContainer2';
}
}
/* Главное меню лора */
document.querySelectorAll('.custom-item').forEach(function (item) {
item.addEventListener('click', function () {
var link = item.querySelector('a');
if (link) {
window.location.href = link.getAttribute('href');
}
});
});
/* Хронология */
if (typeof $ === 'function') {
$(document).ready(function () {
$('.timeline-header').click(function () {
var content = $(this).next('.timeline-content');
if (content.is(':visible')) {
content.slideUp();
} else {
content.slideDown();
}
});
$('.timeline-content').hide();
});
}