Dantes (обсуждение | вклад) (Отмена правки 22957, сделанной Dantes (обсуждение)) Метка: отмена |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 2: | Строка 2: | ||
var mwLoaded = false; | var mwLoaded = false; | ||
if (document.body && document.body.classList && document.body.classList.contains('halloween-theme')) return; | if (document.body && document.body.classList && document.body.classList.contains('halloween-theme')) return; | ||
function | function addEffects() { | ||
var body = document.body; | var body = document.body; | ||
body.className = body.className + ' halloween-theme halloween-glow'; | body.className = body.className + ' halloween-theme halloween-glow'; | ||
| Строка 63: | Строка 59: | ||
var f = document.createElement('div'); | var f = document.createElement('div'); | ||
f.className = 'halloween-footer-decoration'; | f.className = 'halloween-footer-decoration'; | ||
document.documentElement.appendChild(f); | document.documentElement.appendChild(f); | ||
} | } | ||
| Строка 69: | Строка 64: | ||
if (mwLoaded) return; | if (mwLoaded) return; | ||
mwLoaded = true; | mwLoaded = true; | ||
addEffects(); | |||
startRain(); | startRain(); | ||
addBat(); | addBat(); | ||
| Строка 82: | Строка 77: | ||
} | } | ||
})(); | })(); | ||
/*31*/ | /*31*/ | ||
Версия от 00:53, 23 октября 2025
(function () {
var mwLoaded = false;
if (document.body && document.body.classList && document.body.classList.contains('halloween-theme')) return;
function addEffects() {
var body = document.body;
body.className = body.className + ' halloween-theme halloween-glow';
var content = document.getElementById('content') || document.getElementById('mw-content-text') || document.querySelector('.mw-body');
if (content) {
content.className = content.className + ' halloween-page-shadow';
try { content.style.transition = 'box-shadow .3s ease'; } catch (e) {}
}
}
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function spawnEmoji(emoji, left, delay, duration, size) {
var el = document.createElement('div');
el.className = 'halloween-floating-emoji';
el.style.left = left + '%';
el.style.fontSize = size + 'px';
el.style.animationDuration = duration + 's';
el.style.animationDelay = delay + 's';
try { el.textContent = emoji; } catch (e) { el.innerText = emoji; }
document.documentElement.appendChild(el);
setTimeout(function () {
if (el && el.parentNode) el.parentNode.removeChild(el);
}, (duration + delay + 0.5) * 1000);
}
function startRain() {
var emojis = ['🎃', '👻', '🦇', '🍬', '🕯️'];
var i;
for (i = 0; i < 12; i++) {
(function (i) {
var left = randomInt(2, 96);
var delay = Math.random() * 6;
var duration = 6 + Math.random() * 6;
var size = 18 + Math.random() * 28;
var emoji = emojis[randomInt(0, emojis.length - 1)];
setTimeout(function () {
spawnEmoji(emoji, left, 0, duration, size);
}, delay * 1000);
})(i);
}
setInterval(function () {
var left = randomInt(2, 96);
var duration = 6 + Math.random() * 6;
var size = 18 + Math.random() * 28;
var emojis2 = ['🎃', '👻', '🦇', '🍬'];
spawnEmoji(emojis2[randomInt(0, emojis2.length - 1)], left, 0, duration, size);
}, 1600);
}
function addBat() {
var bat = document.createElement('div');
bat.className = 'halloween-bat';
try { bat.textContent = '🦇'; } catch (e) { bat.innerText = '🦇'; }
document.documentElement.appendChild(bat);
}
function addFooter() {
var f = document.createElement('div');
f.className = 'halloween-footer-decoration';
document.documentElement.appendChild(f);
}
function init() {
if (mwLoaded) return;
mwLoaded = true;
addEffects();
startRain();
addBat();
addFooter();
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
try { init(); } catch (e) {}
} else {
document.addEventListener('DOMContentLoaded', function () {
try { init(); } catch (e) {}
});
}
})();
/*31*/
/*Загрузка АУДИО*/
$(function () {
var players = document.getElementsByClassName('audio-player');
for (var i = 0; i < players.length; i++) {
var src = players[i].getAttribute('data-src');
if (src) {
var audio = document.createElement('audio');
audio.setAttribute('controls', 'controls');
audio.setAttribute('preload', 'none');
var source = document.createElement('source');
source.setAttribute('src', src);
source.setAttribute('type', 'audio/mpeg');
audio.appendChild(source);
players[i].appendChild(audio);
}
}
});
/* Подгрузка внешних css js */
mw.loader.using('mediawiki.util', function() {
function getFilesFromUrl(param) {
if (!param) return [];
return param.split('|').map(function(file) {
return file.trim();
});
}
function getBaseUrl() {
var server = mw.config.get('wgServer').replace(/^http:/, 'https:');
var script = mw.config.get('wgScript');
return server + script + '?action=raw&ctype=text/';
}
function isValidExtension(ext) {
return ext === 'js' || ext === 'css';
}
function getFileUrl(file) {
var prefix = file.indexOf('MediaWiki:') === 0 ? 'MediaWiki:' : 'User:' + (mw.config.get('wgUserName') || '') + '/';
var fullName = file.indexOf(':') > -1 ? file : prefix + file;
var ext = file.split('.').pop().toLowerCase();
if (!isValidExtension(ext)) {
console.error('Недопустимое расширение файла:', file);
return null;
}
var timestamp = new Date().getTime(); // Добавляем временную метку для удаления кэширования
return getBaseUrl() + (ext === 'js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(fullName) + '&_=' + timestamp;
}
function loadFiles(files) {
files.forEach(function(file) {
var url = getFileUrl(file);
if (url) {
var ext = file.split('.').pop().toLowerCase();
mw.loader.load(url, 'text/' + (ext === 'js' ? 'javascript' : 'css'));
}
});
}
var params = mw.util.getParamValue('use');
var files = getFilesFromUrl(params);
loadFiles(files);
});
/* Лого сайта */
(function() {
var createLogo = function(url, imgSrc, title) {
var container = document.createElement('div'),
link = document.createElement('a'),
img = document.createElement('img');
link.className = 'mw-logo citizen-header__button';
link.href = mw.util.getUrl(url);
link.title = title;
img.className = 'mw-logo-icon';
img.src = imgSrc;
img.alt = '';
img.setAttribute('aria-hidden', 'true');
img.width = 32;
img.height = 32;
link.appendChild(img);
container.appendChild(link);
return container;
};
var logoContainer = document.querySelector('.citizen-header__logo');
if (logoContainer) {
// Очистка существующего содержимого
while (logoContainer.firstChild) {
logoContainer.removeChild(logoContainer.firstChild);
}
var logo1 = createLogo(
'Заглавная_страница',
mw.config.get('wgScriptPath') + '/resources/assets/logo.png',
'Перейти на заглавную страницу'
);
logo1.className = 'logo1';
var logo2 = createLogo(
'Marine_Corps',
mw.config.get('wgScriptPath') + '/images/0/0d/CMlog.png',
'Перейти на CM'
);
logo2.className = 'logo2';
// Добавление в DOM
logoContainer.appendChild(logo1);
logoContainer.appendChild(logo2);
}
})();
/* Перенос 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 && jobsContainer.innerHTML.trim()) {
var bodyContent = document.getElementById('bodyContent');
if (bodyContent) {
bodyContent.insertAdjacentHTML('beforebegin', jobsContainer.innerHTML);
var jobTable = document.getElementById('IdJobsTableContainer1');
if (jobTable) {
jobTable.id = 'IdJobsTableContainer2';
}
}
}
/* Хронология */
if (window.jQuery) {
jQuery(function($) {
$('.timeline-header').on('click', function() {
$(this).next('.timeline-content').slideToggle();
}).trigger('click');
});
}
/*Галерея*/
(function(){
var root=document.getElementById('ss-art-gallery');
if(!root)return;
function q(a,b){return a.querySelector(b)}
function qa(a,b){return Array.prototype.slice.call(a.querySelectorAll(b))}
var chips=qa(root,'.ss-chip');
function setFilter(val){
chips.forEach(function(c){
c.classList.toggle('ss-chip-active',
c.getAttribute('data-filter')===val || (val==='all'&&c.getAttribute('data-filter')==='all')
);
});
qa(root,'.ss-section').forEach(function(section){
var cards=qa(section,'.ss-card');
var visibleCount=0;
cards.forEach(function(card){
var who=card.getAttribute('data-artist');
var show=(val==='all'||val===who);
card.classList.toggle('ss-hidden',!show);
if(show)visibleCount++;
});
// секция видна только если есть арты выбранного автора или выбран "все"
section.style.display=(val==='all' || visibleCount>0)?'block':'none';
});
}
chips.forEach(function(ch){
ch.addEventListener('click',function(){
setFilter(ch.getAttribute('data-filter'))
})
});
setFilter('all');
var modal=document.createElement('div');
modal.className='ss-modal';
modal.innerHTML='<div class="ss-modal-inner"><img class="ss-modal-img" alt=""/></div><div class="ss-modal-close" role="button">✖ Закрыть</div>';
root.appendChild(modal);
var modalImg=q(modal,'.ss-modal-img');
function originalFromThumb(u){
if(!u)return u;
if(u.indexOf('/thumb/')>-1){
var s=u.replace('/thumb/','/');
s=s.replace(/\/[^\/]*$/,'');
return s
}
return u
}
qa(root,'.ss-card img').forEach(function(img){
img.style.cursor='zoom-in';
img.addEventListener('click',function(e){
e.preventDefault();
var src=originalFromThumb(img.getAttribute('src'));
modalImg.setAttribute('src',src||img.getAttribute('src'));
modalImg.style.maxWidth='90vw';
modalImg.style.maxHeight='90vh';
modal.classList.add('open')
})
});
function closeModal(){modal.classList.remove('open')}
modal.addEventListener('click',function(e){
if(e.target===modal||e.target.classList.contains('ss-modal-close')){closeModal()}
});
document.addEventListener('keydown',function(e){if(e.key==='Escape'){closeModal()}})
})();
/*Галерея*/
/*Меню лора*/
(function() {
var items = document.querySelectorAll('.custom-item');
for (var i = 0; i < items.length; i++) {
(function(item) {
var icon = item.querySelector('.custom-icon');
var linkEl = item.querySelector('a');
if (!linkEl) return;
var href = linkEl.getAttribute('href');
item.style.cursor = 'pointer';
item.onclick = function() {
window.location.href = href;
};
item.onmousemove = function(e) {
var rect = item.getBoundingClientRect();
var x = e.clientX - rect.left;
var y = e.clientY - rect.top;
var moveX = (x - rect.width/2) * 0.02;
var moveY = (y - rect.height/2) * 0.02;
item.style.backgroundPosition = (50 + moveX) + '% ' + (50 + moveY) + '%';
if(icon){
icon.style.transform = 'translateY(-8px) scale(1.08)';
}
var hue = Math.round((x / rect.width) * 360);
// яркая цветная обводка + мягкий свет вокруг блока
item.style.boxShadow =
'0 0 15px hsla(' + hue + ', 100%, 60%, 0.7), ' +
'0 0 30px hsla(' + ((hue+30)%360) + ', 100%, 50%, 0.4), ' +
'0 8px 20px rgba(0,0,0,0.5)';
};
item.onmouseleave = function() {
item.style.backgroundPosition = '50% 50%';
if(icon){
icon.style.transform = 'translateY(0) scale(1)';
}
item.style.boxShadow = '0 4px 10px rgba(0,0,0,0.3)';
};
})(items[i]);
}
})();
/*Меню лора*/
/*Данте страница*/
mw.loader.using('mediawiki.util', function() {
var tabs = document.querySelectorAll('.nt-tab');
var contents = document.querySelectorAll('.nt-tab-content');
for (var i=0;i<tabs.length;i++){
tabs[i].onclick = function(){
for(var j=0;j<tabs.length;j++){
tabs[j].className = tabs[j].className.replace(' active','');
contents[j].className = contents[j].className.replace(' active','');
}
this.className += ' active';
var target = document.getElementById(this.getAttribute('data-target'));
if(target) target.className += ' active';
};
}
var rows = document.querySelectorAll('.scan-row');
for(var k=0;k<rows.length;k++){
(function(i){
setTimeout(function(){
rows[i].className += ' visible';
}, i*200);
})(k);
}
var dossier = document.querySelector('.nt-dossier');
if(dossier) setTimeout(function(){ dossier.style.opacity = 1; }, 200);
var tabsContainer = document.querySelector('.nt-tabs');
if(tabsContainer) setTimeout(function(){ tabsContainer.style.opacity = 1; }, 400);
});