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

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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показано 17 промежуточных версий этого же участника)
Строка 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) {
    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 leaves = document.createElement('div');
                 if (node.getAttribute('data-chem-attached')) return;  
            leaves.className = 'halloween-leaves';
                 node.setAttribute('data-chem-attached', '1');  
            document.body.appendChild(leaves);
                 node.style.cursor = 'pointer';  
 
                 node.addEventListener('click', function() {
            var leafIcons = ['🍂','🍁','🦇','🕸️'];
                    var kind = node.getAttribute('data-kind') || '';  
            for (var i = 0; i < 50; i++) {
                    var wrapper = findWrapper(node, kind);  
                 var leaf = document.createElement('span');
                    if (!wrapper) return;  
                 leaf.className = 'halloween-leaf';
                    var btn = node.querySelector('.collapse-btn');  
                leaf.innerHTML = leafIcons[Math.floor(Math.random()*leafIcons.length)];
                   
                 leaf.style.left = (Math.random()*100)+'%';
                    if (wrapper.classList.contains('collapsed')) {  
                 leaf.style.animationDelay = (Math.random()*10)+'s';
                        wrapper.classList.remove('collapsed');  
                leaf.style.fontSize = (14+Math.random()*28)+'px';
                        wrapper.classList.add('expanded');  
                leaf.style.opacity = Math.random() * 0.7 + 0.3;
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px';  
                leaves.appendChild(leaf);
                        if (btn) btn.textContent = 'свернуть';  
            }
                        var cleanup = function() {
 
                            wrapper.style.maxHeight = '';  
            var firstHeading = document.getElementById('firstHeading');
                            wrapper.removeEventListener('transitionend', cleanup);  
            if (firstHeading) {
                        };
                for (var j = 0; j < 3; j++) {
                        wrapper.addEventListener('transitionend', cleanup);  
                    var pumpkin = document.createElement('span');
                    } else {
                    pumpkin.className = 'halloween-pumpkin';
                        var currentHeight = wrapper.scrollHeight;  
                    pumpkin.innerHTML = '🎃';
                        wrapper.style.maxHeight = currentHeight + 'px';
                    pumpkin.style.margin = '0 2px';
                        wrapper.offsetHeight;  
                    pumpkin.style.fontSize = (24 + Math.random()*12) + 'px';
                        wrapper.classList.remove('expanded');
                    firstHeading.appendChild(pumpkin);
                        wrapper.classList.add('collapsed');  
                }
                        wrapper.style.maxHeight = '0px';  
            }
                        if (btn) btn.textContent = 'развернуть';  
 
                     }
            var links = document.getElementsByTagName('a');
                 });  
            for (var k = 0; k < links.length; k++) {
             })(headings[hi]);
                links[k].style.transition = 'color 0.3s ease, text-shadow 0.3s ease';
        }  
                links[k].onmouseover = function() {
    }
                    this.style.color = '#ffa500';
   
                    this.style.textShadow = '0 0 8px #ffa500, 0 0 15px #ff7518';
    function findWrapper(node, kind) {  
                };
        var parent = node.parentNode;  
                links[k].onmouseout = function() {
        if (!parent) return null;  
                    this.style.color = '';
        var wrappers = parent.querySelectorAll('.collapsible');  
                     this.style.textShadow = '';
        var wi = 0;  
                 };
        var wlen = wrappers.length;  
             }
        for (; wi < wlen; wi++) {  
 
            if (wrappers[wi].getAttribute('data-kind') === kind) {
            var batsCount = 8;
                 return wrappers[wi];  
            for (var b = 0; b < batsCount; b++) {
            }
                var bat = document.createElement('div');
        }
                bat.className = 'halloween-bat';
        return null;  
                bat.style.top = Math.random()*50+'vh';
    }
                bat.style.left = -50 + Math.random()*100+'px';
   
                bat.style.animationDuration = (8 + Math.random()*6) + 's';
    if (document.readyState === 'complete' || document.readyState === 'interactive') {
                document.body.appendChild(bat);
        initCollapse();  
            }
    } else {
 
         document.addEventListener('DOMContentLoaded', initCollapse);  
            var websCount = 5;
     }  
            for (var w = 0; w < websCount; w++) {
                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)';
                document.body.appendChild(web);
            }
         });
     }
})();
})();

Текущая версия от 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); 
    } 
})();