Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
mw.loader.using('mediawiki.util', function () { | |||
$(function () { | |||
var container = document.getElementById('chemistry-recipes'); | |||
if (!container) return; | |||
var recipes = [ | |||
{ | |||
} | name: 'Зомби-кислота', | ||
class: 'zombieacid', | |||
inputs: ['Диловен [1]', 'Аммиак [1]', 'Кровь зомби [2]'], | |||
output: 'Зомби-кислота [3]', | |||
effects: ['Вызывает мутации и оживление тканей.'], | |||
appearance: 'Ядовито-зелёная жидкость.' | |||
}, | |||
{ | |||
name: 'Маннитол', | |||
class: 'mannitol', | |||
inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'], | |||
output: 'Маннитол [3]', | |||
effects: ['Эффективно устраняет повреждения мозга.'], | |||
appearance: 'Непрозрачное.' | |||
} | |||
]; | |||
function createRecipeCard(recipe) { | |||
var card = document.createElement('div'); | |||
card.className = 'chem-recipe chem-' + recipe.class; | |||
var header = document.createElement('div'); | |||
.chem-header | header.className = 'chem-header'; | ||
header.textContent = recipe.name; | |||
card.appendChild(header); | |||
var content = document.createElement('div'); | |||
.chem-content | content.className = 'chem-content'; | ||
.chem- | // Ингредиенты | ||
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); | |||
.chem-content | // Стрелка + 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); | |||
} | |||
/ | // Эффекты | ||
.chem- | 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])); | |||
} | |||
}); | |||
}); | |||
Версия от 23:54, 19 апреля 2025
mw.loader.using('mediawiki.util', function () {
$(function () {
var container = document.getElementById('chemistry-recipes');
if (!container) return;
var recipes = [
{
name: 'Зомби-кислота',
class: 'zombieacid',
inputs: ['Диловен [1]', 'Аммиак [1]', 'Кровь зомби [2]'],
output: 'Зомби-кислота [3]',
effects: ['Вызывает мутации и оживление тканей.'],
appearance: 'Ядовито-зелёная жидкость.'
},
{
name: 'Маннитол',
class: 'mannitol',
inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'],
output: 'Маннитол [3]',
effects: ['Эффективно устраняет повреждения мозга.'],
appearance: 'Непрозрачное.'
}
];
function createRecipeCard(recipe) {
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]));
}
});
});