MediaWiki:Common.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Метка: ручная отмена
Нет описания правки
Метка: ручная отмена
 
(не показана 41 промежуточная версия этого же участника)
Строка 1: Строка 1:
(function() {
/* Снег */
     if (window.innerWidth < 1024 || /Mobi|Android|iPhone|iPad|iPod|Tablet/i.test(navigator.userAgent)) return;
(function(){
     var canvas = document.createElement('canvas');
    canvas.style.position = 'fixed';
    canvas.style.left = '0';
    canvas.style.top = '0';
    canvas.style.width = '100%';
    canvas.style.height = '100%';
    canvas.style.pointerEvents = 'none';
    canvas.style.zIndex = '9999';
    document.documentElement.appendChild(canvas);


     if (localStorage.getItem('halloweenThemeDisabled') === 'true') return;
     var ctx = canvas.getContext('2d');
    var w = 0, h = 0, flakes = [], t = 0;


     var today = new Date();
     function resize(){
    var month = today.getMonth() + 1;
        w = canvas.width = window.innerWidth;
    if (month !== 10 && month !== 11) return;
         h = canvas.height = window.innerHeight;
 
        initFlakes();
    mw.loader.load('/w/index.php?title=MediaWiki:Test.css&action=raw&ctype=text/css');
    }
 
    mw.hook('wikipage.content').add(function($content) {
 
        var config = {
            leavesCount: 50,
            batsCount: 8,
            websCount: 5,
            pumpkinsCount: 3,
            leafIcons: ['🍂','🍁','🦇','🕸️'],
            pumpkinIcon: '🎃',
            leafMinSize: 14,
            leafMaxSize: 42,
            pumpkinMinSize: 24,
            pumpkinMaxSize: 36
        };
 
         var body = document.body;
 
        function createFragmentElements(count, createFn) {
            var frag = document.createDocumentFragment();
            for (var i = 0; i < count; i++) frag.appendChild(createFn(i));
            return frag;
        }


        function initLeaves() {
    function rand(a,b){ return Math.random()*(b-a)+a; }
            var leaves = document.createElement('div');
            leaves.className = 'halloween-leaves';
            leaves.appendChild(createFragmentElements(config.leavesCount, function() {
                var leaf = document.createElement('span');
                leaf.className = 'halloween-leaf';
                leaf.innerHTML = config.leafIcons[Math.floor(Math.random() * config.leafIcons.length)];
                leaf.style.left = (Math.random() * 100) + '%';
                leaf.style.animationDelay = (Math.random() * 10) + 's';
                leaf.style.fontSize = (config.leafMinSize + Math.random() * (config.leafMaxSize - config.leafMinSize)) + 'px';
                leaf.style.opacity = Math.random() * 0.7 + 0.3;
                leaf.style.transform = 'rotate(' + (Math.random() * 360) + 'deg)';
                return leaf;
            }));
            body.appendChild(leaves);
        }


        function initPumpkins() {
    function initFlakes(){
            var heading = document.getElementById('firstHeading');
        flakes = [];
            if (!heading) return;
        var count = Math.max(40, Math.floor(w/25));
            for (var i = 0; i < config.pumpkinsCount; i++) {
        for(var i=0;i<count;i++){
                var pumpkin = document.createElement('span');
            flakes.push({
                 pumpkin.className = 'halloween-pumpkin';
                 x: rand(0,w),
                pumpkin.innerHTML = config.pumpkinIcon;
                 y: rand(-h,h),
                pumpkin.style.margin = '0 2px';
                 r: rand(0.7,2.4),
                 pumpkin.style.fontSize = (config.pumpkinMinSize + Math.random() * (config.pumpkinMaxSize - config.pumpkinMinSize)) + 'px';
                 vx: rand(-0.15,0.15),
                 heading.appendChild(pumpkin);
                 vy: rand(0.25,0.9),
                (function(el){
                 s: rand(0.5,1.5)
                    var pos = 0, dir = 1;
                    setInterval(function() {
                        pos += dir*0.3;
                        if(pos>5||pos<0) dir*=-1;
                        el.style.transform = 'translateY(' + pos + 'px)';
                    },30);
                 })(pumpkin);
            }
        }
 
        function initLinksEffect() {
            body.addEventListener('mouseover', function(e){
                 if(e.target.tagName.toLowerCase()==='a'){
                    e.target.style.color='#ffa500';
                    e.target.style.textShadow='0 0 8px #ffa500, 0 0 15px #ff7518';
                }
            });
            body.addEventListener('mouseout', function(e){
                 if(e.target.tagName.toLowerCase()==='a'){
                    e.target.style.color='';
                    e.target.style.textShadow='';
                }
             });
             });
         }
         }
    }


        function initBats() {
    var raf = window.requestAnimationFrame || function(fn){ setTimeout(fn,16); };
            body.appendChild(createFragmentElements(config.batsCount, function(){
                var bat=document.createElement('div');
                bat.className='halloween-bat';
                bat.style.top=(Math.random()*50)+'vh';
                bat.style.left=(-50+Math.random()*100)+'px';
                bat.style.animationDuration=(8+Math.random()*6)+'s';
                return bat;
            }));
        }


        function initWebs() {
    function loop(){
            body.appendChild(createFragmentElements(config.websCount, function(){
        t += 0.003;
                var web=document.createElement('div');
        ctx.clearRect(0,0,w,h);
                web.className='spider-web';
        ctx.beginPath();
                web.style.top=(Math.random()*80)+'vh';
        for(var i=0;i<flakes.length;i++){
                web.style.left=(Math.random()*90)+'vw';
            var f = flakes[i];
                web.style.transform='rotate('+(Math.random()*360)+'deg)';
            f.x += f.vx + Math.cos(t+f.s)*0.2;
                return web;
            f.y += f.vy + Math.sin(t+f.s)*0.1;
             }));
            if(f.y > h+10){ f.y = -10; f.x = rand(0,w); }
        }
             if(f.x < -20 || f.x > w+20){ f.x = rand(0,w); f.y = -10; }


        function addDisableButton() {
             ctx.moveTo(f.x,f.y);
             var btn=document.createElement('div');
             ctx.arc(f.x,f.y,f.r,0,6.283);
            btn.innerText='Отключить хэллоуинскую тему';
            btn.style.position='fixed';
            btn.style.bottom='10px';
            btn.style.right='10px';
            btn.style.padding='6px 12px';
            btn.style.background='var(--pumpkin-orange)';
             btn.style.color='var(--ghost-white)';
            btn.style.cursor='pointer';
            btn.style.borderRadius='6px';
            btn.style.zIndex=9999;
            btn.style.boxShadow='0 0 8px var(--pumpkin-orange)';
            btn.addEventListener('click', function(){
                localStorage.setItem('halloweenThemeDisabled','true');
                location.reload();
            });
            body.appendChild(btn);
         }
         }
        ctx.fillStyle = 'rgba(255,255,255,0.85)';
        ctx.fill();
        raf(loop);
    }


        function init() {
    window.addEventListener('resize', resize);
            initLeaves();
    resize();
            initPumpkins();
    loop();
            initLinksEffect();
            initBats();
            initWebs();
            addDisableButton();
        }
 
        setTimeout(init, 500);
    });
})();
})();


 
/* Аудиоплееры */
/*31*/
(function(){
 
 
 
 
 
 
 
 
 
 
/*Загрузка АУДИО*/
$(function () {
     var players = document.getElementsByClassName('audio-player');
     var players = document.getElementsByClassName('audio-player');
     for (var i = 0; i < players.length; i++) {
     for(var i=0;i<players.length;i++){
         var src = players[i].getAttribute('data-src');
         (function(p){
        if (src) {
            var src = p.getAttribute('data-src');
            var audio = document.createElement('audio');
            if(src){
            audio.setAttribute('controls', 'controls');
                var audio = document.createElement('audio');
            audio.setAttribute('preload', 'none');
                audio.setAttribute('controls','controls');
            var source = document.createElement('source');
                audio.setAttribute('preload','none');
            source.setAttribute('src', src);
                var source = document.createElement('source');
            source.setAttribute('type', 'audio/mpeg');
                source.setAttribute('src',src);
            audio.appendChild(source);
                source.setAttribute('type','audio/mpeg');
            players[i].appendChild(audio);
                audio.appendChild(source);
         }
                p.appendChild(audio);
            }
         })(players[i]);
     }
     }
});
})();
 


/* Подгрузка внешних CSS/JS */
(function(){
    if(typeof mw === 'undefined') return;


/* Подгрузка внешних css js */
     function getFilesFromUrl(param){
mw.loader.using('mediawiki.util', function() {
         if(!param) return [];
     function getFilesFromUrl(param) {
         return param.split('|').map(function(file){ return file.trim(); });
         if (!param) return [];
         return param.split('|').map(function(file) {
            return file.trim();
        });
     }
     }


     function getBaseUrl() {
     function getBaseUrl(){
         var server = mw.config.get('wgServer').replace(/^http:/, 'https:');
         var server = mw.config.get('wgServer').replace(/^http:/,'https:');
         var script = mw.config.get('wgScript');
         var script = mw.config.get('wgScript');
         return server + script + '?action=raw&ctype=text/';
         return server + script + '?action=raw&ctype=text/';
     }
     }


     function isValidExtension(ext) {
     function isValidExtension(ext){ return ext === 'js' || ext === 'css'; }
        return ext === 'js' || ext === 'css';
    }


     function getFileUrl(file) {
     function getFileUrl(file){
         var prefix = file.indexOf('MediaWiki:') === 0 ? 'MediaWiki:' : 'User:' + (mw.config.get('wgUserName') || '') + '/';
         var prefix = file.indexOf('MediaWiki:') === 0 ? 'MediaWiki:' : 'User:' + (mw.config.get('wgUserName') || '') + '/';
         var fullName = file.indexOf(':') > -1 ? file : prefix + file;
         var fullName = file.indexOf(':') > -1 ? file : prefix + file;
         var ext = file.split('.').pop().toLowerCase();
         var ext = file.split('.').pop().toLowerCase();
         if (!isValidExtension(ext)) {
         if(!isValidExtension(ext)){
             console.error('Недопустимое расширение файла:', file);
             console.error('Недопустимое расширение файла:', file);
             return null;
             return null;
         }
         }
         var timestamp = new Date().getTime(); // Добавляем временную метку для удаления кэширования
         var timestamp = new Date().getTime();
         return getBaseUrl() + (ext === 'js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(fullName) + '&_=' + timestamp;
         return getBaseUrl() + (ext==='js' ? 'javascript' : 'css') + '&title=' + encodeURIComponent(fullName) + '&_=' + timestamp;
     }
     }


     function loadFiles(files) {
     function loadFiles(files){
         files.forEach(function(file) {
         for(var i=0;i<files.length;i++){
             var url = getFileUrl(file);
             var url = getFileUrl(files[i]);
             if (url) {
             if(url){
                 var ext = file.split('.').pop().toLowerCase();
                 var ext = files[i].split('.').pop().toLowerCase();
                 mw.loader.load(url, 'text/' + (ext === 'js' ? 'javascript' : 'css'));
                 mw.loader.load(url,'text/' + (ext==='js' ? 'javascript' : 'css'));
             }
             }
         });
         }
     }
     }


     var params = mw.util.getParamValue('use');
     mw.loader.using('mediawiki.util', function(){
    var files = getFilesFromUrl(params);
        var params = mw.util.getParamValue('use');
    loadFiles(files);
        var files = getFilesFromUrl(params);
});
        loadFiles(files);
    });
})();


 
/* Логотипы сайта */
 
(function(){
 
     function createLogo(url,imgSrc,title){
 
 
 
/* Лого сайта */
(function() {
     var createLogo = function(url, imgSrc, title) {
         var container = document.createElement('div'),
         var container = document.createElement('div'),
             link = document.createElement('a'),
             link = document.createElement('a'),
             img = document.createElement('img');
             img = document.createElement('img');
       
         link.className = 'mw-logo citizen-header__button';
         link.className = 'mw-logo citizen-header__button';
         link.href = mw.util.getUrl(url);
         link.href = mw.util.getUrl(url);
         link.title = title;
         link.title = title;
       
 
         img.className = 'mw-logo-icon';
         img.className = 'mw-logo-icon';
         img.src = imgSrc;
         img.src = imgSrc;
         img.alt = '';
         img.alt = '';
         img.setAttribute('aria-hidden', 'true');
         img.setAttribute('aria-hidden','true');
         img.width = 32;
         img.width = 32;
         img.height = 32;
         img.height = 32;
       
 
         link.appendChild(img);
         link.appendChild(img);
         container.appendChild(link);
         container.appendChild(link);
         return container;
         return container;
     };
     }


     var logoContainer = document.querySelector('.citizen-header__logo');
     var logoContainer = document.querySelector('.citizen-header__logo');
     if (logoContainer) {
     if(logoContainer){
        // Очистка существующего содержимого
         while(logoContainer.firstChild) logoContainer.removeChild(logoContainer.firstChild);
         while (logoContainer.firstChild) {
 
            logoContainer.removeChild(logoContainer.firstChild);
         var logo1 = createLogo('Заглавная_страница', mw.config.get('wgScriptPath') + '/resources/assets/logo.png', 'Перейти на заглавную страницу');
        }
         var logo2 = createLogo('Marine_Corps', mw.config.get('wgScriptPath') + '/images/0/0d/CMlog.png', 'Перейти на CM');
       
 
         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(logo1);
         logoContainer.appendChild(logo2);
         logoContainer.appendChild(logo2);
Строка 275: Строка 163:
})();
})();


/* Перенос page-info и цвет заголовков */
(function(){
    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);
    }


 
     var headerColorElement = document.querySelector('.headerColor');
 
    if(headerColorElement){
 
         var content = headerColorElement.textContent.split('|');
 
        if(content.length === 2){
/* Перенос 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');
             var headers = document.querySelectorAll('.citizen-section-heading, .citizen-section-heading--collapsed');
             for (var i = 0; i < headers.length; i++) {
             for(var hi=0; hi<headers.length; hi++){
                 var header = headers[i],
                 var header = headers[hi],
                     indicator = header.querySelector('.citizen-section-indicator'),
                     indicator = header.querySelector('.citizen-section-indicator'),
                     headline = header.querySelector('.mw-headline');
                     headline = header.querySelector('.mw-headline');
 
                if(!indicator || !headline) continue;
                 if (header.classList.contains('citizen-section-heading--collapsed')) {
                 if(header.classList.contains('citizen-section-heading--collapsed')){
                     if (indicator) {
                     indicator.style.cssText = 'background: black; box-shadow: unset;';
                        indicator.style.cssText = 'background: black; box-shadow: unset;';
                 } else {
                    }
                 } else if (indicator && headline) {
                     indicator.style.cssText = 'background: ' + content[1] + '; box-shadow: 0 0 20px 0px ' + content[1] + 'cc;';
                     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;';
                     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 для ролей */
/* Sidebar для ролей */
var jobsContainer = document.querySelector('.JobsTableContainer');
(function(){
if (jobsContainer && jobsContainer.innerHTML.trim()) {
    var jobsContainer = document.querySelector('.JobsTableContainer');
    var bodyContent = document.getElementById('bodyContent');
    if(jobsContainer && jobsContainer.innerHTML.trim()){
    if (bodyContent) {
        var bodyContent = document.getElementById('bodyContent');
        bodyContent.insertAdjacentHTML('beforebegin', jobsContainer.innerHTML);
        if(bodyContent){
        var jobTable = document.getElementById('IdJobsTableContainer1');
            bodyContent.insertAdjacentHTML('beforebegin', jobsContainer.innerHTML);
        if (jobTable) {
            var jobTable = document.getElementById('IdJobsTableContainer1');
            jobTable.id = 'IdJobsTableContainer2';
            if(jobTable) jobTable.id = 'IdJobsTableContainer2';
         }
         }
     }
     }
}
})();
 
 
 


/* Хронология */
/* Хронология */
if (window.jQuery) {
(function(){
     jQuery(function($) {
    if(!window.jQuery) return;
         $('.timeline-header').on('click', function() {
     jQuery(function($){
         $('.timeline-header').on('click', function(){
             $(this).next('.timeline-content').slideToggle();
             $(this).next('.timeline-content').slideToggle();
         }).trigger('click');
         }).trigger('click');
     });
     });
}
})();


/*Галерея*/
/* Галерея */
(function(){
(function(){
  var root=document.getElementById('ss-art-gallery');
    var root = document.getElementById('ss-art-gallery');
  if(!root)return;
    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){
     function q(a,b){ return a.querySelector(b); }
      var cards=qa(section,'.ss-card');
    function qa(a,b){ return Array.prototype.slice.call(a.querySelectorAll(b)); }
      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){
    var chips = qa(root,'.ss-chip');
    ch.addEventListener('click',function(){
      setFilter(ch.getAttribute('data-filter'))
    })
  });
  setFilter('all');


  var modal=document.createElement('div');
    function setFilter(val){
  modal.className='ss-modal';
        for(var ci=0; ci<chips.length; ci++){
  modal.innerHTML='<div class="ss-modal-inner"><img class="ss-modal-img" alt=""/></div><div class="ss-modal-close" role="button">✖ Закрыть</div>';
            var c = chips[ci];
  root.appendChild(modal);
            var active = (c.getAttribute('data-filter')===val || (val==='all' && c.getAttribute('data-filter')==='all'));
  var modalImg=q(modal,'.ss-modal-img');
            c.classList.toggle('ss-chip-active', active);
        }


  function originalFromThumb(u){
        var sections = qa(root,'.ss-section');
    if(!u)return u;
        for(var si=0; si<sections.length; si++){
    if(u.indexOf('/thumb/')>-1){
            var section = sections[si];
      var s=u.replace('/thumb/','/');
            var cards = qa(section,'.ss-card');
      s=s.replace(/\/[^\/]*$/,'');
            var visibleCount = 0;
      return s
            for(var cj=0; cj<cards.length; cj++){
                var card = cards[cj];
                var show = (val==='all' || val===card.getAttribute('data-artist'));
                card.classList.toggle('ss-hidden', !show);
                if(show) visibleCount++;
            }
            section.style.display = (val==='all' || visibleCount>0)?'block':'none';
        }
     }
     }
    return u
  }


  qa(root,'.ss-card img').forEach(function(img){
    for(var i=0;i<chips.length;i++){
    img.style.cursor='zoom-in';
        (function(ch){
    img.addEventListener('click',function(e){
            ch.addEventListener('click', function(){ setFilter(ch.getAttribute('data-filter')); });
      e.preventDefault();
        })(chips[i]);
      var src=originalFromThumb(img.getAttribute('src'));
    }
      modalImg.setAttribute('src',src||img.getAttribute('src'));
    setFilter('all');
      modalImg.style.maxWidth='90vw';
      modalImg.style.maxHeight='90vh';
      modal.classList.add('open')
    })
  });


  function closeModal(){modal.classList.remove('open')}
    var modal = document.createElement('div');
  modal.addEventListener('click',function(e){
    modal.className = 'ss-modal';
     if(e.target===modal||e.target.classList.contains('ss-modal-close')){closeModal()}
     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);
  document.addEventListener('keydown',function(e){if(e.key==='Escape'){closeModal()}})
})();
/*Галерея*/


    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;
    }


    var images = qa(root,'.ss-card img');
    for(var ii=0; ii<images.length; ii++){
        (function(img){
            img.style.cursor='zoom-in';
            img.addEventListener('click', function(e){
                e.preventDefault();
                var src = originalFromThumb(img.getAttribute('src')) || img.getAttribute('src');
                modalImg.setAttribute('src',src);
                modalImg.style.maxWidth='90vw';
                modalImg.style.maxHeight='90vh';
                modal.classList.add('open');
            });
        })(images[ii]);
    }


(function() {
    function closeModal(){ modal.classList.remove('open'); }
  var items = document.querySelectorAll('.custom-item');
    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(); });
})();


  for (var i = 0; i < items.length; i++) {
/* Меню лора */
    (function(item) {
(function(){
      var icon = item.querySelector('.custom-icon');
    var items = document.querySelectorAll('.custom-item');
      var linkEl = item.querySelector('a');
    for(var mi=0; mi<items.length; mi++){
     
        (function(item){
      if (!linkEl) return;
            var icon = item.querySelector('.custom-icon');
            var linkEl = item.querySelector('a');
            if(!linkEl) return;


      var href = linkEl.getAttribute('href');
            var href = linkEl.getAttribute('href');
      item.style.cursor = 'pointer';
            item.style.cursor='pointer';


      item.onclick = function() {
            item.onclick = function(){ window.location.href = href; };
        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[mi]);
    }
})();


      item.onmousemove = function(e) {
/* Химия */
         var rect = item.getBoundingClientRect();
(function(){
         var x = e.clientX - rect.left;
    if(typeof mw==='undefined'||!window.document) return;
        var y = e.clientY - rect.top;
    function initCollapse(){
        var moveX = (x - rect.width/2) * 0.02;
         var headings = document.querySelectorAll('.chem-heading');
        var moveY = (y - rect.height/2) * 0.02;
         for(var hi=0;hi<headings.length;hi++){
        item.style.backgroundPosition = (50 + moveX) + '% ' + (50 + moveY) + '%';
            (function(node){
        if(icon){
                if(node.getAttribute('data-chem-attached')) return;
          icon.style.transform = 'translateY(-8px) scale(1.08)';
                node.setAttribute('data-chem-attached','1');
                node.style.cursor='pointer';
                node.addEventListener('click', function(){
                    var kind = node.getAttribute('data-kind')||'';
                    var wrapper = findWrapper(node,kind);
                    if(wrapper){
                        if(wrapper.classList.contains('collapsed')){
                            wrapper.classList.remove('collapsed');
                            wrapper.classList.add('expanded');
                        } else {
                            wrapper.classList.remove('expanded');
                            wrapper.classList.add('collapsed');
                        }
                    }
                });
            })(headings[hi]);
         }
         }
        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() {
    function findWrapper(node,kind){
         item.style.backgroundPosition = '50% 50%';
         var parent = node.parentNode;
         if(icon){
         if(!parent) return null;
          icon.style.transform = 'translateY(0) scale(1)';
        var wrappers = parent.querySelectorAll('.collapsible');
        for(var wi=0;wi<wrappers.length;wi++){
            if(wrappers[wi].getAttribute('data-kind')===kind) return wrappers[wi];
         }
         }
         item.style.boxShadow = '0 4px 10px rgba(0,0,0,0.3)';
         return null;
      };
    })(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');
     if(document.readyState==='complete'||document.readyState==='interactive'){
    for(var k=0;k<rows.length;k++){
         initCollapse();
         (function(i){
    } else {
            setTimeout(function(){
        document.addEventListener('DOMContentLoaded', initCollapse);
                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);
});

Текущая версия от 12:20, 17 января 2026

/* Снег */
(function(){
    var canvas = document.createElement('canvas');
    canvas.style.position = 'fixed';
    canvas.style.left = '0';
    canvas.style.top = '0';
    canvas.style.width = '100%';
    canvas.style.height = '100%';
    canvas.style.pointerEvents = 'none';
    canvas.style.zIndex = '9999';
    document.documentElement.appendChild(canvas);

    var ctx = canvas.getContext('2d');
    var w = 0, h = 0, flakes = [], t = 0;

    function resize(){
        w = canvas.width = window.innerWidth;
        h = canvas.height = window.innerHeight;
        initFlakes();
    }

    function rand(a,b){ return Math.random()*(b-a)+a; }

    function initFlakes(){
        flakes = [];
        var count = Math.max(40, Math.floor(w/25));
        for(var i=0;i<count;i++){
            flakes.push({
                x: rand(0,w),
                y: rand(-h,h),
                r: rand(0.7,2.4),
                vx: rand(-0.15,0.15),
                vy: rand(0.25,0.9),
                s: rand(0.5,1.5)
            });
        }
    }

    var raf = window.requestAnimationFrame || function(fn){ setTimeout(fn,16); };

    function loop(){
        t += 0.003;
        ctx.clearRect(0,0,w,h);
        ctx.beginPath();
        for(var i=0;i<flakes.length;i++){
            var f = flakes[i];
            f.x += f.vx + Math.cos(t+f.s)*0.2;
            f.y += f.vy + Math.sin(t+f.s)*0.1;
            if(f.y > h+10){ f.y = -10; f.x = rand(0,w); }
            if(f.x < -20 || f.x > w+20){ f.x = rand(0,w); f.y = -10; }

            ctx.moveTo(f.x,f.y);
            ctx.arc(f.x,f.y,f.r,0,6.283);
        }
        ctx.fillStyle = 'rgba(255,255,255,0.85)';
        ctx.fill();
        raf(loop);
    }

    window.addEventListener('resize', resize);
    resize();
    loop();
})();

/* Аудиоплееры */
(function(){
    var players = document.getElementsByClassName('audio-player');
    for(var i=0;i<players.length;i++){
        (function(p){
            var src = p.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);
                p.appendChild(audio);
            }
        })(players[i]);
    }
})();

/* Подгрузка внешних CSS/JS */
(function(){
    if(typeof mw === 'undefined') return;

    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){
        for(var i=0;i<files.length;i++){
            var url = getFileUrl(files[i]);
            if(url){
                var ext = files[i].split('.').pop().toLowerCase();
                mw.loader.load(url,'text/' + (ext==='js' ? 'javascript' : 'css'));
            }
        }
    }

    mw.loader.using('mediawiki.util', function(){
        var params = mw.util.getParamValue('use');
        var files = getFilesFromUrl(params);
        loadFiles(files);
    });
})();

/* Логотипы сайта */
(function(){
    function createLogo(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', 'Перейти на заглавную страницу');
        var logo2 = createLogo('Marine_Corps', mw.config.get('wgScriptPath') + '/images/0/0d/CMlog.png', 'Перейти на CM');

        logoContainer.appendChild(logo1);
        logoContainer.appendChild(logo2);
    }
})();

/* Перенос page-info и цвет заголовков */
(function(){
    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);
    }

    var headerColorElement = document.querySelector('.headerColor');
    if(headerColorElement){
        var content = headerColorElement.textContent.split('|');
        if(content.length === 2){
            var headers = document.querySelectorAll('.citizen-section-heading, .citizen-section-heading--collapsed');
            for(var hi=0; hi<headers.length; hi++){
                var header = headers[hi],
                    indicator = header.querySelector('.citizen-section-indicator'),
                    headline = header.querySelector('.mw-headline');
                if(!indicator || !headline) continue;
                if(header.classList.contains('citizen-section-heading--collapsed')){
                    indicator.style.cssText = 'background: black; box-shadow: unset;';
                } else {
                    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;';
                }
            }
        }
    }
})();

/* Sidebar для ролей */
(function(){
    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';
        }
    }
})();

/* Хронология */
(function(){
    if(!window.jQuery) return;
    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){
        for(var ci=0; ci<chips.length; ci++){
            var c = chips[ci];
            var active = (c.getAttribute('data-filter')===val || (val==='all' && c.getAttribute('data-filter')==='all'));
            c.classList.toggle('ss-chip-active', active);
        }

        var sections = qa(root,'.ss-section');
        for(var si=0; si<sections.length; si++){
            var section = sections[si];
            var cards = qa(section,'.ss-card');
            var visibleCount = 0;
            for(var cj=0; cj<cards.length; cj++){
                var card = cards[cj];
                var show = (val==='all' || val===card.getAttribute('data-artist'));
                card.classList.toggle('ss-hidden', !show);
                if(show) visibleCount++;
            }
            section.style.display = (val==='all' || visibleCount>0)?'block':'none';
        }
    }

    for(var i=0;i<chips.length;i++){
        (function(ch){
            ch.addEventListener('click', function(){ setFilter(ch.getAttribute('data-filter')); });
        })(chips[i]);
    }
    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;
    }

    var images = qa(root,'.ss-card img');
    for(var ii=0; ii<images.length; ii++){
        (function(img){
            img.style.cursor='zoom-in';
            img.addEventListener('click', function(e){
                e.preventDefault();
                var src = originalFromThumb(img.getAttribute('src')) || img.getAttribute('src');
                modalImg.setAttribute('src',src);
                modalImg.style.maxWidth='90vw';
                modalImg.style.maxHeight='90vh';
                modal.classList.add('open');
            });
        })(images[ii]);
    }

    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 mi=0; mi<items.length; mi++){
        (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[mi]);
    }
})();

/* Химия */
(function(){
    if(typeof mw==='undefined'||!window.document) return;
    function initCollapse(){
        var headings = document.querySelectorAll('.chem-heading');
        for(var hi=0;hi<headings.length;hi++){
            (function(node){
                if(node.getAttribute('data-chem-attached')) return;
                node.setAttribute('data-chem-attached','1');
                node.style.cursor='pointer';
                node.addEventListener('click', function(){
                    var kind = node.getAttribute('data-kind')||'';
                    var wrapper = findWrapper(node,kind);
                    if(wrapper){
                        if(wrapper.classList.contains('collapsed')){
                            wrapper.classList.remove('collapsed');
                            wrapper.classList.add('expanded');
                        } else {
                            wrapper.classList.remove('expanded');
                            wrapper.classList.add('collapsed');
                        }
                    }
                });
            })(headings[hi]);
        }
    }

    function findWrapper(node,kind){
        var parent = node.parentNode;
        if(!parent) return null;
        var wrappers = parent.querySelectorAll('.collapsible');
        for(var wi=0;wi<wrappers.length;wi++){
            if(wrappers[wi].getAttribute('data-kind')===kind) return wrappers[wi];
        }
        return null;
    }

    if(document.readyState==='complete'||document.readyState==='interactive'){
        initCollapse();
    } else {
        document.addEventListener('DOMContentLoaded', initCollapse);
    }
})();