Module:Variants: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(Format low➨high for items with a range of profession levels; Align levels to the right)
(Fix errors)
Line 59: Line 59:
return ':No variants found.'
return ':No variants found.'
end
end
local profession_b_flag = false
for _, entry in ipairs(smw_data) do
if entry['Profession B'] or entry['Profession Level B'] then
profession_b_flag = true
end
break
end
local table = mw.html.create('table')
local table = mw.html.create('table')
:addClass('sortable wikitable')
:addClass('sortable wikitable')
Line 68: Line 77:
:tag('th')
:tag('th')
:wikitext('Level')
:wikitext('Level')
:attrIf(smw_data[1]['Profession B'], 'colspan', 2)
:attrIf(profession_b_flag, 'colspan', 2)
:done()
:done()
:done()
:done()
Line 76: Line 85:
return nil
return nil
end
end
local level_text = tostring(level)
local level_text = tostring(level or '?')
if high then
if high then
level_text = ('%s➨%d'):format(level_text, high)
level_text = ('%s➨%d'):format(level_text, high)
Line 84: Line 93:


for _, entry in ipairs(smw_data) do
for _, entry in ipairs(smw_data) do
local profession_level_a = entry['Profession Level A'] or '?'
local profession_level_b = entry['Profession Level B'] or '?'
local profession_a = entry['Profession A'] or ''
local profession_b = entry['Profession B'] or ''
table
table
:tag('tr')
:tag('tr')
Line 97: Line 110:
:css{ ['text-align'] = 'right' }
:css{ ['text-align'] = 'right' }
:wikitext(formatProfessionLevel(entry['Profession A'], entry['Profession Level A'], entry['Profession Level A High']))
:wikitext(formatProfessionLevel(entry['Profession A'], entry['Profession Level A'], entry['Profession Level A High']))
:done()
:IF(profession_b_flag)
:IF(entry['Profession B'])
:tag('td')
:tag('td')
:IF(entry['Profession B'])
:css{ ['text-align'] = 'right' }
:css{ ['text-align'] = 'right' }
:wikitext(formatProfessionLevel(entry['Profession B'], entry['Profession Level B'], entry['Profession Level B High']))
:wikitext(formatProfessionLevel(entry['Profession B'], entry['Profession Level B'], entry['Profession Level B High']))