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

Страница интерфейса MediaWiki
Нет описания правки
Метка: отменено
Нет описания правки
 
(не показана 41 промежуточная версия этого же участника)
Строка 1: Строка 1:
$(function() {
(function(){
  var btn = $('<div>▲ Наверх</div>').css({
var canvas=document.createElement('canvas');
    position:'fixed', bottom:'20px', right:'20px',
canvas.style.position='fixed';
    padding:'5px 10px', background:'#333', color:'#fff',
canvas.style.left='0';
    cursor:'pointer', borderRadius:'5px', zIndex:9999,
canvas.style.top='0';
    boxShadow:'0 2px 5px rgba(0,0,0,0.4)'
canvas.style.width='100%';
  }).appendTo('body');
canvas.style.height='100%';
 
canvas.style.pointerEvents='none';
  var menu = $('<div></div>').css({
canvas.style.zIndex='9999';
    position:'fixed', bottom:'60px', right:'20px',
document.documentElement.appendChild(canvas);
    maxHeight:'300px', overflow:'auto',
var ctx=canvas.getContext('2d');
    padding:'5px 0', background:'#333', border:'1px solid #222',
var w=0,h=0,flakes=[];
    borderRadius:'5px', display:'none', zIndex:9999,
function resize(){w=canvas.width=window.innerWidth;h=canvas.height=window.innerHeight;initFlakes();}
    boxShadow:'0 2px 8px rgba(0,0,0,0.5)'
function rand(a,b){return Math.random()*(b-a)+a;}
  }).appendTo('body');
function initFlakes(){
 
flakes=[];
  $('h1, h2, h3').each(function() {
var count=Math.max(30,Math.floor(w/30));
    var id = $(this).attr('id');
for(var i=0;i<count;i++){
    if (!id) {
flakes.push({
      id = 'hdr-' + Math.random().toString(36).substr(2,5);
x:rand(0,w),
      $(this).attr('id', id);
y:rand(-h, h),
    }
r:rand(0.8,2.6),
    var link = $('<div>'+$(this).text()+'</div>').css({
vx:rand(-0.3,0.3),
      cursor:'pointer', padding:'4px 8px',
vy:rand(0.4,1.2),
      background:'#fff', color:'#000',
o:rand(0.3,0.9)
      margin:'2px 5px', borderRadius:'3px'
    }).hover(
      function(){ $(this).css('background','#eee'); },
      function(){ $(this).css('background','#fff'); }
    ).appendTo(menu);
    link.click(function() {
      $('html, body').animate({scrollTop:$('#'+id).offset().top}, 500);
      menu.hide();
    });
  });
 
  btn.click(function() {
    menu.toggle();
  });
});
});
}
}
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();
})();

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