Dantes (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
mw.loader.using('mediawiki.util', function () { | |||
$ | $(function () { | ||
var | var container = document.getElementById('chemistry-recipes'); | ||
if (!container) return; | |||
var name | var recipes = [ | ||
{ | |||
name: 'Маннитол', | |||
inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'], | |||
output: 'Маннитол [3]', | |||
effects: ['Эффективно устраняет повреждения мозга.'], | |||
appearance: 'Непрозрачное' | |||
}, | |||
{ | |||
name: 'Хлор', | |||
inputs: ['Столовая соль [2]'], | |||
output: ['Натрий [1]', 'Хлор [1]'], | |||
effects: ['Poison (0.5 ед/сек)', 'Наносит 4 Poison за единицу.'], | |||
appearance: 'Жёлто-зелёный газ, токсичный для человека. Газообразное' | |||
}, | |||
{ | |||
name: 'Фтор', | |||
inputs: [], | |||
output: null, | |||
effects: ['Poison (0.5 ед/сек)', 'Наносит 1 Caustic и 1 Poison за единицу.'], | |||
appearance: 'Высокотоксичный бледно-жёлтый газ. Чрезвычайно реактивный. Газообразное' | |||
}, | |||
{ | |||
name: 'Железо', | |||
inputs: ['Кровь [20]', 'Вода [11]', 'Сахар [2]', 'Диоксид углерода [3]'], | |||
output: ['Железо [0.5]', 'Протеины [4]'], | |||
effects: [ | |||
'Medicine (0.5 ед/сек)', | |||
'Poison (0.1 ед/сек)', | |||
'Наносит 1 Poison за единицу при метаболизме Arachnid органами.' | |||
], | |||
appearance: 'Серебристо-серый металл. Металлическое' | |||
} | |||
]; | |||
var | 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])); | |||
} | } | ||
}); | }); | ||
}); | }); | ||
Версия от 23:48, 19 апреля 2025
mw.loader.using('mediawiki.util', function () {
$(function () {
var container = document.getElementById('chemistry-recipes');
if (!container) return;
var recipes = [
{
name: 'Маннитол',
inputs: ['Водород [1]', 'Сахар [1]', 'Вода [1]'],
output: 'Маннитол [3]',
effects: ['Эффективно устраняет повреждения мозга.'],
appearance: 'Непрозрачное'
},
{
name: 'Хлор',
inputs: ['Столовая соль [2]'],
output: ['Натрий [1]', 'Хлор [1]'],
effects: ['Poison (0.5 ед/сек)', 'Наносит 4 Poison за единицу.'],
appearance: 'Жёлто-зелёный газ, токсичный для человека. Газообразное'
},
{
name: 'Фтор',
inputs: [],
output: null,
effects: ['Poison (0.5 ед/сек)', 'Наносит 1 Caustic и 1 Poison за единицу.'],
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]));
}
});
});