Documentation for this module may be created at Module:PageLocations/doc
local cargo = mw.ext.cargo local Flags = require('Module:Flags') local PageLocations = {} function PageLocations.main(frame) local currentTitle = mw.title.getCurrentTitle().text local empty = true -- Check if there are any interviews for this page local tables = 'Locations' local fields = '_pageName, franchise, country, city, closed' local cargoArgs = { where = 'franchise="' .. currentTitle .. '"', orderBy = 'country, closed' } local results = cargo.query(tables, fields, cargoArgs) local list = mw.html.create('table') :addClass('striped-table') local container = mw.html.create() if #results > 0 then empty = false container:node(mw.html.create('h2'):wikitext('Locations')) local titleRow = mw.html.create('tr') :addClass('headerRow') local nameCell = mw.html.create('th') :wikitext('Name') local locationCell = mw.html.create('th') :wikitext('Location') local statusCell = mw.html.create('th') :wikitext('Status') list:node(titleRow:node(nameCell):node(locationCell):node(statusCell)) for r = 1, #results do local result = results[r] local eventRow = mw.html.create('tr'):addClass('bodyRow') local name = mw.html.create('td'):wikitext('[[' .. result._pageName .. ']]') local flagDiv = mw.html.create('div'):addClass('flag') local location = mw.html.create('td') -- :addClass('linkID') :node(flagDiv) local flag = Flags.icon(result.country) flagDiv:wikitext(flag) -- flagDiv:wikitext('<span>[[' .. values.id .. ']]</span>') flagDiv:wikitext(result.city) local status = mw.html.create('td'):wikitext(result.closed == '1' and 'Closed' or 'Open') list:node(eventRow:node(name):node(location):node(status)) end container:node(list) end if empty then return '<span class="d-none"></span>' else return container end end return PageLocations