Модуль:ArmorStats: различия между версиями

Нет описания правки
Нет описания правки
Метка: ручная отмена
Строка 12: Строка 12:


function p.templateCells(frame)
function p.templateCells(frame)
    local color = frame.args.color or ""  -- Цвет фона первой ячейки
     local anchorName = frame.args.anchorName or ""  -- Название якоря
     local anchorName = frame.args.anchorName or ""  -- Название якоря
     local image = frame.args.image or ""  -- Путь к изображению предмета
     local image = frame.args.image or ""  -- Путь к изображению предмета
     local itemId = frame.args.itemId or ""  -- ID предмета
     local itemId = frame.args.itemId or ""  -- ID предмета
     local color = frame.args.color or ""  -- Цвет фона первой ячейки
      
    local backgroundColor = frame.args.backgroundColor or "" -- Цвет фона для всех ячеек, кроме первой
    local class = frame.args.class or "" -- Класс
 
     local protBlunt = frame.args.protBlunt or "-" -- Ударный
     local protBlunt = frame.args.protBlunt or "-" -- Ударный
     local protSlash = frame.args.protSlash or "-" -- Режущий
     local protSlash = frame.args.protSlash or "-" -- Режущий
Строка 26: Строка 24:
     local protCaustic = frame.args.protCaustic or "-" -- Радиационный
     local protCaustic = frame.args.protCaustic or "-" -- Радиационный
     local protExplosion = frame.args.protExplosion or "-" -- Взрывной
     local protExplosion = frame.args.protExplosion or "-" -- Взрывной
 
   
     local description = frame.args.description or "" -- Описание
     local description = frame.args.description or "" -- Описание
     local location = frame.args.location or "" -- Местонахождение
     local location = frame.args.location or "" -- Местонахождение
    local backgroundColor = frame.args.backgroundColor or "" -- Цвет фона для всех ячеек, кроме первой


     -- Вызов функции из модуля Entity Lookup для создания image tooltip
     -- Вызов функции из модуля Entity Lookup для создания image tooltip
Строка 42: Строка 41:
     local borderColor = darkenColor(color)
     local borderColor = darkenColor(color)


     -- Создание HTML
     -- Формирование строк для ячеек таблицы
     local div = mw.html.create('div')
     local out = ""
     div:addClass(divClass)
     out = out .. '!style="background-color: ' .. color .. ';border-top: 1px solid ' .. borderColor .. ';border-bottom: 1px solid ' .. borderColor .. ';border-left: 2px solid ' .. borderColor .. ';"|' .. anchor
 
    out = out .. imageTooltip
    -- Создание таблицы
    out = out .. '<br>' .. itemName .. '\n'
    local table = mw.html.create('table')
    out = out .. '|style="font-weight:bold;color: crimson;background-color: ' .. backgroundColor .. '"|' .. protBlunt .. '\n'
    local row = table:tag('tr')
    out = out .. '|style="font-weight:bold;color: indianred;background-color: ' .. backgroundColor .. '"|' .. protSlash .. '\n'
 
    out = out .. '|style="font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor .. '"|' .. protPiercing .. '\n'
    -- Добавление ячеек в строку
    out = out .. '|style="font-weight:bold;color: orange;background-color: ' .. backgroundColor .. '"|' .. protHeat .. '\n'
    row
    out = out .. '|style="font-weight:bold;color: plum;background-color: ' .. backgroundColor .. '"|' .. protRadiation .. '\n'
        :tag('th')
    out = out .. '|style="font-weight:bold;color: limegreen;background-color: ' .. backgroundColor .. '"|' .. protCaustic .. '\n'
        :attr('style', 'background-color: ' .. color .. ';border-top: 1px solid ' .. borderColor .. ';border-bottom: 1px solid ' .. borderColor .. ';border-left: 2px solid ' .. borderColor .. ';')
    out = out .. '|style="font-weight:bold;color: tan;background-color: ' .. backgroundColor .. '"|' .. protExplosion .. '\n'
        :wikitext(anchor .. imageTooltip .. '<br>' .. itemName)
    out = out .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. description .. '\n'
 
    out = out .. '|style="background-color: ' .. backgroundColor .. '"|\n' .. location .. '\n|-'
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: crimson;background-color: ' .. backgroundColor)
        :wikitext(protBlunt)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: indianred;background-color: ' .. backgroundColor)
        :wikitext(protSlash)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: darksalmon;background-color: ' .. backgroundColor)
        :wikitext(protPiercing)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: orange;background-color: ' .. backgroundColor)
        :wikitext(protHeat)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: plum;background-color: ' .. backgroundColor)
        :wikitext(protRadiation)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: limegreen;background-color: ' .. backgroundColor)
        :wikitext(protCaustic)
 
    row
        :tag('td')
        :attr('style', 'font-weight:bold;color: tan;background-color: ' .. backgroundColor)
        :wikitext(protExplosion)
 
    row
        :tag('td')
        :attr('style', 'background-color: ' .. backgroundColor)
        :wikitext(description)
 
    row
        :tag('td')
        :attr('style', 'background-color: ' .. backgroundColor)
        :wikitext(location)
 
    -- Вставка таблицы в div
    div:node(table)


     return tostring(div)
     return out
end
end


return p
return p