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

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

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