Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
||
| Строка 1: | Строка 1: | ||
/* Подгрузка внешних css js */ | /*Подгрузка внешних css js*/ | ||
mw.loader.using('mediawiki.util', function() { | mw.loader.using('mediawiki.util', function () { | ||
var | 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; | |||
} | |||
} | |||
}); | |||
}); | |||
/* Лого сайта */ | /* Лого сайта */ | ||
( | 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 */ | /* Перенос page-info в конец footer-places */ | ||
var footerPlaces = document.getElementById('footer-places'); | var footerPlaces = document.getElementById('footer-places'); | ||
var pageInfo = document. | var pageInfo = document.getElementsByClassName('page-info')[0]; | ||
if (footerPlaces && pageInfo) { | if (footerPlaces && pageInfo) { | ||
footerPlaces. | footerPlaces.insertAdjacentHTML('afterEnd', pageInfo.innerHTML); | ||
pageInfo. | pageInfo.innerHTML = ''; | ||
} | } | ||
/* Логика цвета через headerColor */ | /* Логика цвета через headerColor */ | ||
var headerColorElement = document. | var headerColorElement = document.getElementsByClassName('headerColor')[0]; | ||
if (headerColorElement) { | if (headerColorElement) { | ||
var isValidColor = function(color) { | var isValidColor = function (color) { | ||
var | var el = document.createElement('div'); | ||
el.style.backgroundColor = color; | |||
return | return !!el.style.backgroundColor; | ||
}; | }; | ||
var | 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 (header. | 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) { | if (indicator) { | ||
indicator.style. | 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', | document.body.addEventListener('click', function () { | ||
headerRender(colorBorder, colorBtn); | |||
}); | |||
} | } | ||
} | } | ||
/* Sidebar для ролей */ | /* Sidebar для ролей */ | ||
var jobsContainer = document. | var jobsContainer = document.getElementsByClassName('JobsTableContainer')[0]; | ||
if (jobsContainer) { | if (jobsContainer) { | ||
var bodyContent = document.getElementById('bodyContent'); | var bodyContent = document.getElementById('bodyContent'); | ||
if (bodyContent) { | if (bodyContent) { | ||
var | 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'); | |||
var link = | if (link) { | ||
if (link) window.location = link.href; | window.location.href = link.getAttribute('href'); | ||
}; | } | ||
} | }); | ||
}); | |||
/* Хронология */ | /* Хронология */ | ||
if ( | if (typeof $ === 'function') { | ||
$(document).ready(function () { | |||
$('.timeline-header'). | $('.timeline-header').click(function () { | ||
$(this).next('.timeline-content'). | var content = $(this).next('.timeline-content'); | ||
}) | if (content.is(':visible')) { | ||
content.slideUp(); | |||
} else { | |||
content.slideDown(); | |||
} | |||
}); | |||
$('.timeline-content').hide(); | |||
}); | }); | ||
} | } | ||
Версия от 18:59, 2 марта 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;
}
}
});
});
/* Лого сайта */
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();
});
}