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

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

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