Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local | local function makeCard(recipe) | ||
local title = recipe["Название"] or "Без названия" | |||
function | local ingredients = recipe["Ингредиенты"] or "" | ||
local result = recipe["Результат"] or "" | |||
local title = | local effects = recipe["Эффекты"] or "" | ||
local ingredients = | local effectsDesc = recipe["ОписаниеЭффектов"] or "" | ||
local result = | local borderColor = recipe["ЦветРамки"] or "#338833" | ||
local effects = | local backgroundColor = recipe["ЦветФона"] or "#1a2a1a" | ||
local effectsDesc = | |||
local borderColor = | |||
local backgroundColor = | |||
local html = {} | local html = {} | ||
table.insert(html, string.format( | |||
'<div class="alchemy-card" style="border-color: %s; background-color: %s;">', | |||
borderColor, backgroundColor | |||
)) | |||
-- | -- Добавляем строку с иконкой и названием рядом | ||
table.insert(html, '<div class="alchemy- | table.insert(html, '<div class="alchemy-title-row">') | ||
table.insert(html, '<img class="alchemy-icon" src="/images/thumb/8/8c/Beaker.png/32px-Beaker.png" alt="Колба">') | |||
table.insert(html, '<h3 | table.insert(html, '<h3 class="alchemy-title">' .. mw.text.encode(title) .. '</h3>') | ||
table.insert(html, '</div>') | |||
table.insert(html, '<div class="alchemy-main-row">') | |||
table.insert(html, '<div | |||
table.insert(html, '<div | table.insert(html, '<div class="alchemy-ingredients">') | ||
table.insert(html, '<div class="alchemy-label">Рецепт:</div>') | |||
table.insert(html, listBlock(ingredients)) | table.insert(html, listBlock(ingredients)) | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
table.insert(html, '<div | table.insert(html, '<div class="alchemy-plus">СМЕШАТЬ</div>') | ||
table.insert(html, '<div | table.insert(html, '<div class="alchemy-result">') | ||
table.insert(html, listBlock(result)) | table.insert(html, listBlock(result)) | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
| Строка 50: | Строка 35: | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
if effects ~= "" then | if effects ~= "" then | ||
table.insert(html, ' | table.insert(html, '<b>Эффекты:</b><ul class="alchemy-effects">') | ||
table.insert(html, listUL(effects)) | table.insert(html, listUL(effects)) | ||
table.insert(html, '</ul>') | table.insert(html, '</ul>') | ||
if effectsDesc ~= "" then | |||
table.insert(html, '<div class="alchemy-effects-desc">' .. mw.text.encode(effectsDesc) .. '</div>') | |||
end | |||
end | end | ||
table.insert(html, '</div>') | table.insert(html, '</div>') | ||
return table.concat(html, "\n") | return table.concat(html, "\n") | ||
end | end | ||
Версия от 18:11, 16 мая 2025
Для документации этого модуля может быть создана страница Модуль:AlchemyRecipe/doc
local function makeCard(recipe)
local title = recipe["Название"] or "Без названия"
local ingredients = recipe["Ингредиенты"] or ""
local result = recipe["Результат"] or ""
local effects = recipe["Эффекты"] or ""
local effectsDesc = recipe["ОписаниеЭффектов"] or ""
local borderColor = recipe["ЦветРамки"] or "#338833"
local backgroundColor = recipe["ЦветФона"] or "#1a2a1a"
local html = {}
table.insert(html, string.format(
'<div class="alchemy-card" style="border-color: %s; background-color: %s;">',
borderColor, backgroundColor
))
-- Добавляем строку с иконкой и названием рядом
table.insert(html, '<div class="alchemy-title-row">')
table.insert(html, '<img class="alchemy-icon" src="/images/thumb/8/8c/Beaker.png/32px-Beaker.png" alt="Колба">')
table.insert(html, '<h3 class="alchemy-title">' .. mw.text.encode(title) .. '</h3>')
table.insert(html, '</div>')
table.insert(html, '<div class="alchemy-main-row">')
table.insert(html, '<div class="alchemy-ingredients">')
table.insert(html, '<div class="alchemy-label">Рецепт:</div>')
table.insert(html, listBlock(ingredients))
table.insert(html, '</div>')
table.insert(html, '<div class="alchemy-plus">СМЕШАТЬ</div>')
table.insert(html, '<div class="alchemy-result">')
table.insert(html, listBlock(result))
table.insert(html, '</div>')
table.insert(html, '</div>')
if effects ~= "" then
table.insert(html, '<b>Эффекты:</b><ul class="alchemy-effects">')
table.insert(html, listUL(effects))
table.insert(html, '</ul>')
if effectsDesc ~= "" then
table.insert(html, '<div class="alchemy-effects-desc">' .. mw.text.encode(effectsDesc) .. '</div>')
end
end
table.insert(html, '</div>')
return table.concat(html, "\n")
end