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

Нет описания правки
Нет описания правки
Строка 42: Строка 42:
     local borderColor = darkenColor(color)
     local borderColor = darkenColor(color)


     -- Создание HTML с помощью mw.html.create
     -- Создание HTML
     local div = mw.html.create('div')
     local div = mw.html.create('div')
     div:addClass(divClass)
     div:addClass(divClass)


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


     div:wikitext(tableContent)
    -- Добавление ячеек в строку
    row
        :tag('th')
        :attr('style', 'background-color: ' .. color .. ';border-top: 1px solid ' .. borderColor .. ';border-bottom: 1px solid ' .. borderColor .. ';border-left: 2px solid ' .. borderColor .. ';')
        :wikitext(anchor .. imageTooltip .. '<br>' .. itemName)
 
    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 tostring(div)