Dantes (обсуждение | вклад) (Отмена правки 15161, сделанной Dantes (обсуждение)) Метка: отмена |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
/* | /*Подгрузка внешних css js*/ | ||
mw.loader.using('mediawiki.util', function () { | mw.loader.using('mediawiki.util', function () { | ||
var files = mw.util.getParamValue('use'), | var files = mw.util.getParamValue('use'), | ||
FileRE = new RegExp('^(?:MediaWiki:|User:' + mw.util.escapeRegExp(mw.config.get('wgUserName', '')) + '/)?[^&<>=%#]*\\.(js|css)$'), | FileRE = new RegExp('^(?:MediaWiki:|User:' + mw.util.escapeRegExp(mw.config.get('wgUserName', '')) + '/)?[^&<>=%#]*\\.(js|css)$'), | ||
path = mw.config.get('wgServer').replace( | path = mw.config.get('wgServer').replace(/^http:/, 'https:') + mw.config.get('wgScript') + '?action=raw&ctype=text/'; | ||
if (!files) | if (!files) return; | ||
$.each(files.split('|'), function (k, v) { | $.each(files.split('|'), function (k, v) { | ||
| Строка 15: | Строка 13: | ||
case 'js': | case 'js': | ||
mw.loader.load(path + 'javascript&title=' + encodeURIComponent(file), 'text/javascript'); | mw.loader.load(path + 'javascript&title=' + encodeURIComponent(file), 'text/javascript'); | ||
break; | break; | ||
case 'css': | case 'css': | ||
mw.loader.load(path + 'css&title=' + encodeURIComponent(file), 'text/css'); | mw.loader.load(path + 'css&title=' + encodeURIComponent(file), 'text/css'); | ||
break; | break; | ||
} | } | ||
| Строка 26: | Строка 22: | ||
}); | }); | ||
/* Лого сайта */ | |||
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'); | |||
} | |||
}); | |||
document.querySelectorAll('.custom-item').forEach(function(item) { | |||
}); | }); | ||
/* | /* Хронология */ | ||
$(document).ready(function() { | 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(); | |||
}); | }); | ||
} | |||
} | |||
Версия от 23:23, 17 января 2025
/*Подгрузка внешних css js*/
mw.loader.using('mediawiki.util', function () {
var files = mw.util.getParamValue('use'),
FileRE = new RegExp('^(?:MediaWiki:|User:' + mw.util.escapeRegExp(mw.config.get('wgUserName', '')) + '/)?[^&<>=%#]*\\.(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();
});
}