Модуль:BotanyStats: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 34: | Строка 34: | ||
local location = default(frame.args.location, "") -- Местонахождение | local location = default(frame.args.location, "") -- Местонахождение | ||
local mutationId = default(frame.args.mutationId, "") -- Мутации | local mutationId = default(frame.args.mutationId, "") -- Мутации | ||
-- Разделение параметра mutationId на слова | |||
local function splitWords(text) | |||
local words = {} | |||
for word in text:gmatch("%S+") do | |||
table.insert(words, word) | |||
end | |||
return words | |||
end | |||
local words = splitWords(mutationId) | |||
local mutationCells = "" | |||
-- Генерация HTML-кода для каждого ID | |||
for _, word in ipairs(words) do | |||
mutationCells = mutationCells .. '<div class="maturation-cell">{{#invoke:Entity Lookup|createimagetooltip|Файл:' .. word .. '.png|' .. word .. '|Мета=32x32px,link=}} [[#{{#invoke:Entity Lookup|getname|' .. word .. '}}|{{#invoke:Entity Lookup|getname|' .. word .. '}}]]</div>' | |||
end | |||
-- Преобразование температуры из Кельвинов в Цельсии | -- Преобразование температуры из Кельвинов в Цельсии | ||
| Строка 55: | Строка 72: | ||
out = out .. '| ' .. description .. '\n' | out = out .. '| ' .. description .. '\n' | ||
out = out .. '| ' .. location .. '\n' | out = out .. '| ' .. location .. '\n' | ||
out = out .. frame:preprocess('! | out = out .. frame:preprocess('!' .. mutationCells .. '\n') | ||
out = out .. '|- \n' | out = out .. '|- \n' | ||
-- CSS код, который подгружается при первом вызове модуля на странице | |||
if firstRun then | if firstRun then | ||
firstRun = false | firstRun = false | ||
out = out .. '<div class="customCSS" style="display:none"> .maturation-cell { width: 100%; margin: 5px 0; box-sizing: border-box; text-align: left; background: #096d35; padding: 6px 10px; border-radius: 0.3em; border: 2px solid #0c4729; font-weight: bold; font-family:"Montserrat", sans-serif; transition: background 0.05s; } .maturation--box:hover { background: #097137; } </div>' | out = out .. '<div class="customCSS" style="display:none"> .maturation-cell { width: 100%; margin: 5px 0; box-sizing: border-box; text-align: left; background: #096d35; padding: 6px 10px; border-radius: 0.3em; border: 2px solid #0c4729; font-weight: bold; font-family:"Montserrat", sans-serif; transition: background 0.05s; } .maturation--box:hover { background: #097137; } </div>' | ||