Module:IPA/overview

require('strict') local p = {}

local lects = mw.loadData('Module:IPA/data/export')

local function addNote(cell, note) cell:wikitext(string.format(' (%s) ', note)) end

function p.main local t = mw.html.create('table'):addClass('wikitable sortable mw-collapsible') :tag('caption'):addClass('nowrap'):wikitext('Data overview'):done :tag('tr') :tag('th'):attr('colspan', 4):wikitext('Language'):done :tag('th'):attr('colspan', 4):wikitext('Dialect'):done :done :tag('tr') :tag('th'):wikitext('Code'):done :tag('th'):wikitext('Name'):done :tag('th'):wikitext('Link'):done :tag('th'):wikitext('Key'):done :tag('th'):wikitext('Code'):done :tag('th'):wikitext('Name'):done :tag('th'):wikitext('Link'):done :tag('th'):wikitext('Key'):done :done local langRow, langCells, dialectCount for i, lect in ipairs(lects) do		local row local cells = {} if lect.parent then dialectCount = dialectCount + 1 if dialectCount == 1 then row = langRow else row = t:tag('tr') for _, cell in ipairs(langCells) do					cell:attr('rowspan', dialectCount) end end else row = t:tag('tr') langRow = row langCells = cells dialectCount = 0 end for _ = 1, 4 do			table.insert(cells, row:tag('td')) end if not lect.parent and not (lects[i + 1] and lects[i + 1].parent) then for _ = 1, 4 do				row:tag('td'):css('background', '#ececec') end end cells[1]:wikitext(' ') if lect.aliases then local aliases = {} for _, alias in ipairs(lect.aliases) do				table.insert(aliases, alias) end addNote(cells[1], string.format( 'also ', table.concat(aliases, ', ') for _, lect in ipairs(keyLects) do			if lect ~= lang then local subRow = t:tag('tr') if prev.name == lect.name then prev.count = prev.count + 1 prev.cell:attr('rowspan', prev.count) else prev = { name = lect.name, count = 1, cell = subRow:tag('td'):wikitext(							string.format('%s', lect.link, lect.name)						) }				end subRow:tag('td'):wikitext(' ') end end end return tostring(t) end

return p