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

Страница интерфейса MediaWiki
Нет описания правки
Нет описания правки
 
(не показаны 122 промежуточные версии этого же участника)
Строка 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';
        inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'],
canvas.style.zIndex='9999';
        output: 'Маннитол [3]',
document.documentElement.appendChild(canvas);
        effects: ['Эффективно устраняет повреждения мозга.'],
var ctx=canvas.getContext('2d');
        appearance: 'Непрозрачное'
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;}
        name: 'Хлор',
function initFlakes(){
        inputs: ['Столовая соль [2]'],
flakes=[];
        output: ['Натрий [1]', 'Хлор [1]'],
var count=Math.max(30,Math.floor(w/30));
        effects: ['Poison (0.5 ед/сек)', 'Наносит 4 Poison за единицу.'],
for(var i=0;i<count;i++){
        appearance: 'Жёлто-зелёный газ, токсичный для человека. Газообразное'
flakes.push({
      },
x:rand(0,w),
      {
y:rand(-h, h),
        name: 'Фтор',
r:rand(0.8,2.6),
        inputs: [],
vx:rand(-0.3,0.3),
        output: null,
vy:rand(0.4,1.2),
        effects: ['Poison (0.5 ед/сек)', 'Наносит 1 Caustic и 1 Poison за единицу.'],
o:rand(0.3,0.9)
        appearance: 'Высокотоксичный бледно-жёлтый газ. Чрезвычайно реактивный. Газообразное'
      },
      {
        name: 'Железо',
        inputs: ['Кровь [20]', 'Вода [11]', 'Сахар [2]', 'Диоксид углерода [3]'],
        output: ['Железо [0.5]', 'Протеины [4]'],
        effects: [
          'Medicine (0.5 ед/сек)',
          'Poison (0.1 ед/сек)',
          'Наносит 1 Poison за единицу при метаболизме Arachnid органами.'
        ],
        appearance: 'Серебристо-серый металл. Металлическое'
      }
    ];
 
    function createRecipeElement(recipe) {
      var div = document.createElement('div');
      div.className = 'chem-recipe';
 
      var title = document.createElement('h3');
      title.textContent = recipe.name;
      div.appendChild(title);
 
      if (recipe.inputs.length) {
        var inList = document.createElement('ul');
        for (var i = 0; i < recipe.inputs.length; i++) {
          var li = document.createElement('li');
          li.textContent = recipe.inputs[i];
          inList.appendChild(li);
        }
        div.appendChild(document.createTextNode('Рецепт:'));
        div.appendChild(inList);
      }
 
      if (recipe.output) {
        var out = document.createElement('p');
        out.textContent = 'Выход: ' + (typeof recipe.output === 'string' ? recipe.output : recipe.output.join(', '));
        div.appendChild(out);
      }
 
      if (recipe.effects.length) {
        var effectList = document.createElement('ul');
        for (var j = 0; j < recipe.effects.length; j++) {
          var ef = document.createElement('li');
          ef.textContent = recipe.effects[j];
          effectList.appendChild(ef);
        }
        div.appendChild(document.createTextNode('Эффекты:'));
        div.appendChild(effectList);
      }
 
      if (recipe.appearance) {
        var ap = document.createElement('p');
        ap.textContent = 'На вид: ' + recipe.appearance;
        div.appendChild(ap);
      }
 
      return div;
    }
 
    for (var k = 0; k < recipes.length; k++) {
      container.appendChild(createRecipeElement(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();
})();