Module:Infobox/Widget/Location

From TwogPedia
Revision as of 17:32, 2 October 2023 by Couchor (talk | contribs)

Documentation for this module may be created at Module:Infobox/Widget/Location/doc

local CountryData = mw.loadData('Module:Localisation/Data')
local Flags = require('Module:Flags')
local String = require('Module:StringUtils')

local Location = {}

function Location.make(countries, cities, category, state)
	local container = mw.html.create('div')
	local countryList = mw.text.split(countries, ',')
	
	for i, v in ipairs(countryList) do
		v = mw.text.trim(v)
mw.log('SEE ON V')
mw.log(v)
		local country = CountryData[string.upper(v)]
mw.log('COUNTRY')
mw.log(country)
		local currentTitle = mw.title.getCurrentTitle().text
		local gameCategory = mw.text.split(currentTitle, '/')[1]
		local flag = Flags.icon(country, category or gameCategory)
		local div = mw.html.create('div')
			:addClass('flag')
			:wikitext(flag)
		if cities then
			div:wikitext(mw.text.trim(mw.text.split(cities, ',')[i]))
		else
			div:wikitext(country)
		end
		if state then div:wikitext(', ' .. state) end
			
		container:node(div)
	end
	
	return container
end

return Location