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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показано 119 промежуточных версий этого же участника)
Строка 1: Строка 1:
mw.loader.using('mediawiki.util', function () {
(function(){
  $(function () {
var canvas=document.createElement('canvas');
    var container = document.getElementById('chemistry-recipes');
canvas.style.position='fixed';
    if (!container) return;
canvas.style.left='0';
 
canvas.style.top='0';
    var recipes = [
canvas.style.width='100%';
      {
canvas.style.height='100%';
        name: 'Зомби-кислота',
canvas.style.pointerEvents='none';
        class: 'zombieacid',
canvas.style.zIndex='9999';
        inputs: ['Диловен [1]', 'Аммиак [1]', 'Кровь зомби [2]'],
document.documentElement.appendChild(canvas);
        output: 'Зомби-кислота [3]',
var ctx=canvas.getContext('2d');
        effects: ['Вызывает мутации и оживление тканей.'],
var w=0,h=0,flakes=[];
        appearance: 'Ядовито-зелёная жидкость.'
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(){
        name: 'Маннитол',
flakes=[];
        class: 'mannitol',
var count=Math.max(30,Math.floor(w/30));
        inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'],
for(var i=0;i<count;i++){
        output: 'Маннитол [3]',
flakes.push({
        effects: ['Эффективно устраняет повреждения мозга.'],
x:rand(0,w),
        appearance: 'Непрозрачное.'
y:rand(-h, h),
      }
r:rand(0.8,2.6),
    ];
vx:rand(-0.3,0.3),
 
vy:rand(0.4,1.2),
    function createRecipeCard(recipe) {
o:rand(0.3,0.9)
      var card = document.createElement('div');
      card.className = 'chem-recipe chem-' + recipe.class;
 
      var header = document.createElement('div');
      header.className = 'chem-header';
      header.textContent = recipe.name;
      card.appendChild(header);
 
      var content = document.createElement('div');
      content.className = 'chem-content';
 
      // Ингредиенты
      if (recipe.inputs.length) {
        var inList = document.createElement('ul');
        inList.className = 'chem-inputs';
        for (var i = 0; i < recipe.inputs.length; i++) {
          var li = document.createElement('li');
          li.textContent = recipe.inputs[i];
          inList.appendChild(li);
        }
        content.appendChild(inList);
 
        // Стрелка + Beaker
        var arrow = document.createElement('div');
        arrow.className = 'chem-arrow';
        arrow.innerHTML = '<span>↓</span><img src="/images/thumb/4/4f/Beaker.png/32px-Beaker.png" alt="Beaker" />';
        content.appendChild(arrow);
      }
 
      // Результат
      if (recipe.output) {
        var out = document.createElement('p');
        out.className = 'chem-output';
        out.textContent = 'Получаем: ' + recipe.output;
        content.appendChild(out);
      }
 
      // Эффекты
      if (recipe.effects.length) {
        var effectList = document.createElement('ul');
        effectList.className = 'chem-effects';
        for (var j = 0; j < recipe.effects.length; j++) {
          var ef = document.createElement('li');
          ef.textContent = recipe.effects[j];
          effectList.appendChild(ef);
        }
        content.appendChild(document.createElement('hr'));
        content.appendChild(document.createTextNode('Эффекты:'));
        content.appendChild(effectList);
      }
 
      // Внешний вид
      if (recipe.appearance) {
        var ap = document.createElement('p');
        ap.textContent = 'На вид: ' + recipe.appearance;
        content.appendChild(ap);
      }
 
      // Скрытие по клику
      header.addEventListener('click', function () {
        content.style.display = content.style.display === 'none' ? 'block' : 'none';
      });
 
      content.style.display = 'none';
      card.appendChild(content);
      return card;
    }
 
    for (var k = 0; k < recipes.length; k++) {
      container.appendChild(createRecipeCard(recipes[k]));
    }
  });
});
});
}
}
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();
})();