Anonymous

Module:Equipment/Recommended: Difference between revisions

From Melvor Idle
Allow for multiple headers with custom header names
m (Allow for a custom header title)
(Allow for multiple headers with custom header names)
Line 39: Line 39:


function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
local args = frame:getParent().args
-- Dynamic colspan and N/A generation value
-- Dynamic colspan and N/A generation value
local greatest_row_size = 0
local greatest_row_size = 0
Line 116: Line 116:
local check = args[v.name .. i]
local check = args[v.name .. i]
if check and Params.has_content(check) then
if check and Params.has_content(check) then
grs = grs + 1
grs = grs + 1
end
end
end
end
Line 139: Line 139:
if args.noheader == nil then
if args.noheader == nil then
local itemHeader = nil
local itemHeader = nil
if args.header ~= nil then
local colsize = args.header2 ~= nil and 1 or greatest_row_size
itemHeader = args.header
if args.header1 ~= nil then
itemHeader = args.header1
else
else
itemHeader = (greatest_row_size > 1 and 'Item (most effective → least effective)') or 'Item'
itemHeader = (greatest_row_size > 1 and 'Item (most effective → least effective)') or 'Item'
Line 147: Line 148:
parent:addClass('wikitable stickyHeader')
parent:addClass('wikitable stickyHeader')
local trHead = parent:tag('tr')
local trHead = parent:tag('tr')
local lastHeader = nil
trHead:addClass('headerRow-0')
trHead:addClass('headerRow-0')
:tag('th'):wikitext('Slot'):done()
:tag('th'):wikitext('Slot'):done()
:tag('th'):attr('colspan', greatest_row_size):wikitext(itemHeader):done()
:tag('th'):attr('colspan', colsize):wikitext(itemHeader):done()
-- Add any additional header options
for i = 2, number_of_possible_choices, 1 do
local check = args['header' .. i]
if check and Params.has_content(check) and i <= greatest_row_size then
local header = trHead:tag('th')
header:wikitext(check):done()
lastHeader = header
else
if lastHeader ~= nil then
lastHeader:attr('colspan', i - 1)
end
break
end
end
if showDR then
if showDR then
trHead:tag('th'):wikitext('DR%'):done()
trHead:tag('th'):wikitext('DR%'):done()