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

Страница интерфейса MediaWiki
Нет описания правки
Метка: ручная отмена
Нет описания правки
 
(не показаны 2 промежуточные версии этого же участника)
Строка 1: Строка 1:
(function() {
(function(){
    var today = new Date();
var canvas=document.createElement('canvas');
    var month = today.getMonth() + 1;
canvas.style.position='fixed';
    if (month !== 10 && month !== 11) return;
canvas.style.left='0';
 
canvas.style.top='0';
    mw.loader.load('/w/index.php?title=MediaWiki:Test.css&action=raw&ctype=text/css');
canvas.style.width='100%';
 
canvas.style.height='100%';
    mw.hook('wikipage.content').add(function($content) {
canvas.style.pointerEvents='none';
 
canvas.style.zIndex='9999';
        var config = {
document.documentElement.appendChild(canvas);
            leavesCount: 50,
var ctx=canvas.getContext('2d');
            batsCount: 8,
var w=0,h=0,flakes=[];
            websCount: 5,
function resize(){w=canvas.width=window.innerWidth;h=canvas.height=window.innerHeight;initFlakes();}
            pumpkinsCount: 3,
function rand(a,b){return Math.random()*(b-a)+a;}
            leafIcons: ['🍂','🍁','🦇','🕸️'],
function initFlakes(){
            pumpkinIcon: '🎃',
flakes=[];
            leafMinSize: 14,
var count=Math.max(30,Math.floor(w/30));
            leafMaxSize: 42,
for(var i=0;i<count;i++){
            pumpkinMinSize: 24,
flakes.push({
            pumpkinMaxSize: 36
x:rand(0,w),
        };
y:rand(-h, h),
 
r:rand(0.8,2.6),
        var body = document.body;
vx:rand(-0.3,0.3),
 
vy:rand(0.4,1.2),
        function createFragmentElements(count, createFn) {
o:rand(0.3,0.9)
            var frag = document.createDocumentFragment();
});
            for (var i = 0; i < count; i++) {
}
                frag.appendChild(createFn(i));
}
            }
var raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){setTimeout(fn,16);};
            return frag;
function loop(){
        }
ctx.clearRect(0,0,w,h);
 
ctx.beginPath();
        function initLeaves() {
for(var i=0;i<flakes.length;i++){
            var leaves = document.createElement('div');
var f=flakes[i];
            leaves.className = 'halloween-leaves';
f.x+=f.vx;
            var frag = createFragmentElements(config.leavesCount, function() {
f.y+=f.vy;
                var leaf = document.createElement('span');
f.vx+=Math.sin((Date.now()+i*100)%6000/6000*Math.PI*2)*0.005;
                leaf.className = 'halloween-leaf';
if(f.y>h+10||f.x<-50||f.x>w+50){
                leaf.innerHTML = config.leafIcons[Math.floor(Math.random() * config.leafIcons.length)];
f.x=rand(0,w);
                leaf.style.left = (Math.random() * 100) + '%';
f.y=-10;
                leaf.style.animationDelay = (Math.random() * 10) + 's';
f.vx=rand(-0.3,0.3);
                leaf.style.fontSize = (config.leafMinSize + Math.random() * (config.leafMaxSize - config.leafMinSize)) + 'px';
f.vy=rand(0.4,1.2);
                leaf.style.opacity = Math.random() * 0.7 + 0.3;
}
                leaf.style.transform = 'rotate(' + (Math.random() * 360) + 'deg)';
ctx.moveTo(f.x,f.y);
                return leaf;
ctx.arc(f.x,f.y,f.r,0,Math.PI*2);
            });
}
            leaves.appendChild(frag);
ctx.fillStyle='rgba(255,255,255,0.9)';
            body.appendChild(leaves);
ctx.fill();
        }
raf(loop);
 
}
        function initPumpkins() {
window.addEventListener('resize',resize);
            var heading = document.getElementById('firstHeading');
resize();
            if (!heading) return;
loop();
 
            for (var i = 0; i < config.pumpkinsCount; i++) {
                var pumpkin = document.createElement('span');
                pumpkin.className = 'halloween-pumpkin';
                pumpkin.innerHTML = config.pumpkinIcon;
                pumpkin.style.margin = '0 2px';
                pumpkin.style.fontSize = (config.pumpkinMinSize + Math.random() * (config.pumpkinMaxSize - config.pumpkinMinSize)) + 'px';
                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);
    });
})();
})();

Текущая версия от 23:41, 22 ноября 2025

(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=[];
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(30,Math.floor(w/30));
for(var i=0;i<count;i++){
flakes.push({
x:rand(0,w),
y:rand(-h, h),
r:rand(0.8,2.6),
vx:rand(-0.3,0.3),
vy:rand(0.4,1.2),
o:rand(0.3,0.9)
});
}
}
var raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){setTimeout(fn,16);};
function loop(){
ctx.clearRect(0,0,w,h);
ctx.beginPath();
for(var i=0;i<flakes.length;i++){
var f=flakes[i];
f.x+=f.vx;
f.y+=f.vy;
f.vx+=Math.sin((Date.now()+i*100)%6000/6000*Math.PI*2)*0.005;
if(f.y>h+10||f.x<-50||f.x>w+50){
f.x=rand(0,w);
f.y=-10;
f.vx=rand(-0.3,0.3);
f.vy=rand(0.4,1.2);
}
ctx.moveTo(f.x,f.y);
ctx.arc(f.x,f.y,f.r,0,Math.PI*2);
}
ctx.fillStyle='rgba(255,255,255,0.9)';
ctx.fill();
raf(loop);
}
window.addEventListener('resize',resize);
resize();
loop();
})();