Module:Flagg/Altvar data explained

local p =

function p.alttable(age)

local alt_map =

local alt_aliases =

return alt_map, alt_aliases

end

function p.list_all(frame)

--Load data local alt_map, alt_aliases = p.alttable("

age")

--Add aliases to map table for k,v in pairs(alt_map) do alt_map[k].aliases = end local wrong_aliases = table.sort(alt_aliases) for k,v in pairs(alt_aliases) do if alt_map[v] then table.insert(alt_map[v].aliases,k) else table.insert(wrong_aliases,k) end end

--Create html table & header row local list = mw.html.create("table") list:addClass("wikitable sortable collapsible") local head = list:tag("tr") head:tag("th"):wikitext("Code") head:tag("th"):wikitext("Aliases") head:tag("th"):wikitext("Altlink (suffix)") head:tag("th"):wikitext("Altvar") head:tag("th"):wikitext("Template")

--Append rows to create table body table.sort(alt_map) for k,v in pairs(alt_map) do local row = list:tag("tr") local temp = alt_map[k].template or k row:tag("td"):wikitext(""..k.."") row:tag("td"):wikitext(""..table.concat(alt_map[k].aliases,"
").."") row:tag("td"):wikitext(alt_map[k].altlink) row:tag("td"):wikitext(alt_map[k].altvar) row:tag("td"):wikitext(""..temp.."") end if #wrong_aliases > 0 then local wrong_list = "These aliases point to non-existing data: "..table.concat(wrong_aliases," ").."" list:tag("tr"):tag("td"):attr("colspan","4"):css("color","red"):wikitext(wrong_list) end

return list

end

return p