Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показано 10 промежуточных версий этого же участника)
Строка 1: Строка 1:
(function() {
(function() {  
     if (window.innerWidth < 1024 || /Mobi|Android|iPhone|iPad|iPod|Tablet/i.test(navigator.userAgent)) return;
     if (typeof mw === 'undefined' || !window.document) return;  
 
   
    if (localStorage.getItem('halloweenThemeDisabled') === 'true') return;
     function initCollapse() {
 
        var headings = document.querySelectorAll('.chem-heading');  
     var today = new Date();
         var hi = 0;  
    var month = today.getMonth() + 1;
         var len = headings.length;  
    if (month !== 10 && month !== 11) return;
         for (; hi < len; hi++) {  
 
             (function(node) {  
    mw.loader.load('/w/index.php?title=MediaWiki:Test.css&action=raw&ctype=text/css');
                 if (node.getAttribute('data-chem-attached')) return;  
 
                 node.setAttribute('data-chem-attached', '1');  
    mw.hook('wikipage.content').add(function($content) {
                 node.style.cursor = 'pointer';  
 
                 node.addEventListener('click', function() {
         var config = {
                    var kind = node.getAttribute('data-kind') || '';  
            leavesCount: 50,
                    var wrapper = findWrapper(node, kind);  
            batsCount: 8,
                    if (!wrapper) return;  
            websCount: 5,
                    var btn = node.querySelector('.collapse-btn');  
            pumpkinsCount: 3,
                   
            leafIcons: ['🍂','🍁','🦇','🕸️'],
                    if (wrapper.classList.contains('collapsed')) {
            pumpkinIcon: '🎃',
                        wrapper.classList.remove('collapsed');  
            leafMinSize: 14,
                         wrapper.classList.add('expanded');  
            leafMaxSize: 42,
                         wrapper.style.maxHeight = wrapper.scrollHeight + 'px';  
            pumpkinMinSize: 24,
                        if (btn) btn.textContent = 'свернуть';
            pumpkinMaxSize: 36
                        var cleanup = function() {  
        };
                            wrapper.style.maxHeight = '';  
 
                            wrapper.removeEventListener('transitionend', cleanup);  
         var body = document.body;
                        };  
 
                        wrapper.addEventListener('transitionend', cleanup);  
         function createFragmentElements(count, createFn) {
                     } else {  
            var frag = document.createDocumentFragment();
                        var currentHeight = wrapper.scrollHeight;  
            for (var i = 0; i < count; i++) frag.appendChild(createFn(i));
                        wrapper.style.maxHeight = currentHeight + 'px';  
            return frag;
                        wrapper.offsetHeight;  
        }
                        wrapper.classList.remove('expanded');  
 
                        wrapper.classList.add('collapsed');  
        function initLeaves() {
                        wrapper.style.maxHeight = '0px';  
             var leaves = document.createElement('div');
                        if (btn) btn.textContent = 'развернуть';  
            leaves.className = 'halloween-leaves';
                    }
            leaves.appendChild(createFragmentElements(config.leavesCount, function() {
                 });  
                 var leaf = document.createElement('span');
             })(headings[hi]);  
                 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';
    function findWrapper(node, kind) {  
                leaf.style.fontSize = (config.leafMinSize + Math.random() * (config.leafMaxSize - config.leafMinSize)) + 'px';
        var parent = node.parentNode;
                leaf.style.opacity = Math.random() * 0.7 + 0.3;
        if (!parent) return null;  
                leaf.style.transform = 'rotate(' + (Math.random() * 360) + 'deg)';
        var wrappers = parent.querySelectorAll('.collapsible');  
                return leaf;
        var wi = 0;  
            }));
        var wlen = wrappers.length;  
            body.appendChild(leaves);
        for (; wi < wlen; wi++) {
        }
             if (wrappers[wi].getAttribute('data-kind') === kind) {  
 
                 return wrappers[wi];  
        function initPumpkins() {
             }  
            var heading = document.getElementById('firstHeading');
         }  
            if (!heading) return;
         return null;  
            for (var i = 0; i < config.pumpkinsCount; i++) {
    }
                var pumpkin = document.createElement('span');
   
                pumpkin.className = 'halloween-pumpkin';
    if (document.readyState === 'complete' || document.readyState === 'interactive') {
                pumpkin.innerHTML = config.pumpkinIcon;
        initCollapse();  
                pumpkin.style.margin = '0 2px';
    } else {
                pumpkin.style.fontSize = (config.pumpkinMinSize + Math.random() * (config.pumpkinMaxSize - config.pumpkinMinSize)) + 'px';
         document.addEventListener('DOMContentLoaded', initCollapse);  
                heading.appendChild(pumpkin);
     }  
                (function(el){
                    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() {
            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() {
            body.appendChild(createFragmentElements(config.websCount, function(){
                var web=document.createElement('div');
                web.className='spider-web';
                web.style.top=(Math.random()*80)+'vh';
                web.style.left=(Math.random()*90)+'vw';
                web.style.transform='rotate('+(Math.random()*360)+'deg)';
                 return web;
             }));
         }
 
        function addDisableButton() {
            var btn=document.createElement('div');
            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);
         }
 
         function init() {
            initLeaves();
            initPumpkins();
            initLinksEffect();
            initBats();
            initWebs();
            addDisableButton();
        }
 
         setTimeout(init, 500);
     });
})();
})();

Текущая версия от 13:10, 4 апреля 2026

(function() { 
    if (typeof mw === 'undefined' || !window.document) return; 
    
    function initCollapse() { 
        var headings = document.querySelectorAll('.chem-heading'); 
        var hi = 0; 
        var len = headings.length; 
        for (; hi < len; 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) return; 
                    var btn = node.querySelector('.collapse-btn'); 
                    
                    if (wrapper.classList.contains('collapsed')) { 
                        wrapper.classList.remove('collapsed'); 
                        wrapper.classList.add('expanded'); 
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px'; 
                        if (btn) btn.textContent = 'свернуть'; 
                        var cleanup = function() { 
                            wrapper.style.maxHeight = ''; 
                            wrapper.removeEventListener('transitionend', cleanup); 
                        }; 
                        wrapper.addEventListener('transitionend', cleanup); 
                    } else { 
                        var currentHeight = wrapper.scrollHeight; 
                        wrapper.style.maxHeight = currentHeight + 'px'; 
                        wrapper.offsetHeight; 
                        wrapper.classList.remove('expanded'); 
                        wrapper.classList.add('collapsed'); 
                        wrapper.style.maxHeight = '0px'; 
                        if (btn) btn.textContent = 'развернуть'; 
                    } 
                }); 
            })(headings[hi]); 
        } 
    } 
    
    function findWrapper(node, kind) { 
        var parent = node.parentNode; 
        if (!parent) return null; 
        var wrappers = parent.querySelectorAll('.collapsible'); 
        var wi = 0; 
        var wlen = wrappers.length; 
        for (; wi < wlen; 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); 
    } 
})();