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

Страница интерфейса MediaWiki
Нет описания правки
Метка: отменено
Нет описания правки
 
(не показано 10 промежуточных версий этого же участника)
Строка 1: Строка 1:
(function() {
(function(){
    if (window.halloweenScriptLoaded) return;
var canvas=document.createElement('canvas');
    window.halloweenScriptLoaded = true;
canvas.style.position='fixed';
 
canvas.style.left='0';
    var body = document.body;
canvas.style.top='0';
 
canvas.style.width='100%';
    function createLeaf() {
canvas.style.height='100%';
        var leaf = document.createElement('span');
canvas.style.pointerEvents='none';
        leaf.className = 'halloween-leaf';
canvas.style.zIndex='9999';
        leaf.innerHTML = '🍂';
document.documentElement.appendChild(canvas);
        leaf.style.left = Math.random() * window.innerWidth + 'px';
var ctx=canvas.getContext('2d');
        leaf.style.fontSize = (10 + Math.random() * 20) + 'px';
var w=0,h=0,flakes=[];
        leaf.style.opacity = Math.random();
function resize(){w=canvas.width=window.innerWidth;h=canvas.height=window.innerHeight;initFlakes();}
        leaf.style.animationDuration = (5 + Math.random() * 5) + 's';
function rand(a,b){return Math.random()*(b-a)+a;}
        body.appendChild(leaf);
function initFlakes(){
        setTimeout(function() {
flakes=[];
            body.removeChild(leaf);
var count=Math.max(30,Math.floor(w/30));
        }, 10000);
for(var i=0;i<count;i++){
    }
flakes.push({
 
x:rand(0,w),
    function createPumpkin() {
y:rand(-h, h),
        var pumpkin = document.createElement('span');
r:rand(0.8,2.6),
        pumpkin.className = 'halloween-pumpkin';
vx:rand(-0.3,0.3),
        pumpkin.innerHTML = '🎃';
vy:rand(0.4,1.2),
        pumpkin.style.position = 'fixed';
o:rand(0.3,0.9)
        pumpkin.style.left = Math.random() * window.innerWidth + 'px';
});
        pumpkin.style.top = (window.innerHeight - 50) * Math.random() + 'px';
}
        pumpkin.style.fontSize = (20 + Math.random() * 30) + 'px';
}
        pumpkin.style.opacity = 0.8;
var raf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(fn){setTimeout(fn,16);};
        body.appendChild(pumpkin);
function loop(){
        setTimeout(function() {
ctx.clearRect(0,0,w,h);
            body.removeChild(pumpkin);
ctx.beginPath();
        }, 10000);
for(var i=0;i<flakes.length;i++){
    }
var f=flakes[i];
 
f.x+=f.vx;
    setInterval(createLeaf, 500);     // каждые 0.5 секунды падает лист
f.y+=f.vy;
    setInterval(createPumpkin, 2000); // каждые 2 секунды летает тыква
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();
})();
})();

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