Dantes (обсуждение | вклад) (Отмена правки 16284, сделанной Dantes (обсуждение)) Метка: отмена |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
/*Подгрузка внешних css js*/ | /* Подгрузка внешних 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'), | ||
userName = mw.config.get('wgUserName') || '', | userName = mw.config.get('wgUserName') || '', | ||
FileRE = new RegExp('^(?:MediaWiki:|User:' + mw.util.escapeRegExp(userName) + '/)?[^&<>=%#]*\\.(js|css)$'), | 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/'; | path = mw.config.get('wgServer').replace(/^http:/, 'https:') + mw.config.get('wgScript') + '?action=raw&ctype=text/', | ||
i, fileParts; | |||
if (!files) return; | if (!files) return; | ||
files = files.split('|'); | |||
var file = | for (i = 0; i < files.length; i++) { | ||
var file = files[i].trim(), | |||
match = FileRE.exec(file); | |||
if (match) { | if (match) { | ||
var url = path + (match[1] === 'js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(file); | |||
mw.loader.load(url, 'text/' + match[1]); | |||
} | } | ||
} | } | ||
}); | }); | ||
/* Лого сайта */ | /* Лого сайта */ | ||
var | var logoElements = document.getElementsByClassName('citizen-header__logo'); | ||
if ( | if (logoElements.length) { | ||
logoElements[0].innerHTML = [ | |||
'<div class="logo1">', | |||
'<a href="/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="/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>' | |||
].join(''); | |||
} | } | ||
/* Перенос page-info в | /* Перенос page-info в footer-places */ | ||
var footerPlaces = document.getElementById('footer-places'); | var footerPlaces = document.getElementById('footer-places'); | ||
var pageInfo = document. | var pageInfo = document.querySelector('.page-info'); | ||
if (footerPlaces && pageInfo) { | if (footerPlaces && pageInfo) { | ||
footerPlaces. | footerPlaces.insertAdjacentElement('afterend', pageInfo.cloneNode(true)); | ||
pageInfo. | pageInfo.parentNode.removeChild(pageInfo); | ||
} | } | ||
/* Логика цвета через headerColor */ | /* Логика цвета через headerColor */ | ||
var headerColorElement = document. | var headerColorElement = document.querySelector('.headerColor'); | ||
if (headerColorElement) { | if (headerColorElement) { | ||
var isValidColor = function (color) { | var isValidColor = function(color) { | ||
var | var s = new Option().style; | ||
s.color = color; | |||
return ! | return s.color !== ''; | ||
}; | }; | ||
var | var content = headerColorElement.textContent.split('|'); | ||
var | if (content.length === 2 && isValidColor(content[0]) && isValidColor(content[1])) { | ||
var applyStyles = function() { | |||
var headers = document.querySelectorAll('.citizen-section-heading, .citizen-section-heading--collapsed'); | |||
for (var i = 0; i < headers.length; i++) { | |||
var header = headers[i], | |||
indicator = header.querySelector('.citizen-section-indicator'), | |||
headline = header.querySelector('.mw-headline'); | |||
if (header.classList.contains('citizen-section-heading--collapsed')) { | |||
if (indicator) { | if (indicator) { | ||
indicator.style. | indicator.style.cssText = 'background: black; box-shadow: unset;'; | ||
} | } | ||
} else if (indicator && headline) { | |||
indicator.style.cssText = 'background: ' + content[1] + '; box-shadow: 0 0 20px 0px ' + content[1] + 'cc;'; | |||
headline.style.cssText = 'border-image: linear-gradient(to right top, ' + content[0] + ', black); border-image-slice: 1;'; | |||
} | } | ||
} | } | ||
}; | }; | ||
applyStyles(); | |||
document.body.addEventListener('click', | document.body.addEventListener('click', applyStyles, false); | ||
} | } | ||
} | } | ||
/* Sidebar для ролей */ | /* Sidebar для ролей */ | ||
var jobsContainer = document. | var jobsContainer = document.querySelector('.JobsTableContainer'); | ||
if (jobsContainer) { | if (jobsContainer) { | ||
var bodyContent = document.getElementById('bodyContent'); | var bodyContent = document.getElementById('bodyContent'); | ||
if (bodyContent) { | if (bodyContent) { | ||
var clone = jobsContainer.cloneNode(true); | |||
clone.id = 'IdJobsTableContainer2'; | |||
bodyContent.parentNode.insertBefore(clone, bodyContent); | |||
} | } | ||
} | } | ||
/* Главное меню лора */ | /* Главное меню лора */ | ||
document. | var customItems = document.getElementsByClassName('custom-item'); | ||
for (var i = 0; i < customItems.length; i++) { | |||
var link = | customItems[i].onclick = function() { | ||
if (link) | var link = this.querySelector('a'); | ||
if (link) window.location = link.href; | |||
}; | |||
} | } | ||
} | |||
/* Хронология */ | /* Хронология */ | ||
if ( | if (window.jQuery) { | ||
jQuery(function($) { | |||
$('.timeline-header').click | $('.timeline-header').on('click', function() { | ||
$(this).next('.timeline-content').slideToggle(); | |||
}).trigger('click'); | |||
}) | |||
}); | }); | ||
} | } | ||
Версия от 09:18, 2 марта 2025
/* Подгрузка внешних css js */
mw.loader.using('mediawiki.util', function() {
var files = mw.util.getParamValue('use'),
userName = mw.config.get('wgUserName') || '',
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/',
i, fileParts;
if (!files) return;
files = files.split('|');
for (i = 0; i < files.length; i++) {
var file = files[i].trim(),
match = FileRE.exec(file);
if (match) {
var url = path + (match[1] === 'js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(file);
mw.loader.load(url, 'text/' + match[1]);
}
}
});
/* Лого сайта */
var logoElements = document.getElementsByClassName('citizen-header__logo');
if (logoElements.length) {
logoElements[0].innerHTML = [
'<div class="logo1">',
'<a href="/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="/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>'
].join('');
}
/* Перенос page-info в footer-places */
var footerPlaces = document.getElementById('footer-places');
var pageInfo = document.querySelector('.page-info');
if (footerPlaces && pageInfo) {
footerPlaces.insertAdjacentElement('afterend', pageInfo.cloneNode(true));
pageInfo.parentNode.removeChild(pageInfo);
}
/* Логика цвета через headerColor */
var headerColorElement = document.querySelector('.headerColor');
if (headerColorElement) {
var isValidColor = function(color) {
var s = new Option().style;
s.color = color;
return s.color !== '';
};
var content = headerColorElement.textContent.split('|');
if (content.length === 2 && isValidColor(content[0]) && isValidColor(content[1])) {
var applyStyles = function() {
var headers = document.querySelectorAll('.citizen-section-heading, .citizen-section-heading--collapsed');
for (var i = 0; i < headers.length; i++) {
var header = headers[i],
indicator = header.querySelector('.citizen-section-indicator'),
headline = header.querySelector('.mw-headline');
if (header.classList.contains('citizen-section-heading--collapsed')) {
if (indicator) {
indicator.style.cssText = 'background: black; box-shadow: unset;';
}
} else if (indicator && headline) {
indicator.style.cssText = 'background: ' + content[1] + '; box-shadow: 0 0 20px 0px ' + content[1] + 'cc;';
headline.style.cssText = 'border-image: linear-gradient(to right top, ' + content[0] + ', black); border-image-slice: 1;';
}
}
};
applyStyles();
document.body.addEventListener('click', applyStyles, false);
}
}
/* Sidebar для ролей */
var jobsContainer = document.querySelector('.JobsTableContainer');
if (jobsContainer) {
var bodyContent = document.getElementById('bodyContent');
if (bodyContent) {
var clone = jobsContainer.cloneNode(true);
clone.id = 'IdJobsTableContainer2';
bodyContent.parentNode.insertBefore(clone, bodyContent);
}
}
/* Главное меню лора */
var customItems = document.getElementsByClassName('custom-item');
for (var i = 0; i < customItems.length; i++) {
customItems[i].onclick = function() {
var link = this.querySelector('a');
if (link) window.location = link.href;
};
}
/* Хронология */
if (window.jQuery) {
jQuery(function($) {
$('.timeline-header').on('click', function() {
$(this).next('.timeline-content').slideToggle();
}).trigger('click');
});
}