Module:Infobox/Widget/Location

From TwogPedia
Revision as of 16:26, 30 August 2022 by Couchor (talk | contribs) (Created page with "local CountryData = mw.loadData('Module:Localisation/Data') local Flags = require('Module:Flags') local String = require('Module:StringUtils') local Location = {} function Location.make(args, key) local index = 1 local current = args[key] local currentLocation = args['city'] or args['location'] local container = mw.html.create('div') while not String.isEmpty(current) do local country = CountryData[args.country .. index] local currentTitle = mw.title.getCurr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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(args, key)
	local index = 1
	local current = args[key]
	local currentLocation = args['city'] or args['location']
	local container = mw.html.create('div')
	
	while not String.isEmpty(current) do 
		local country = CountryData[args.country .. index]
		local currentTitle = mw.title.getCurrentTitle().text
		local gameCategory = mw.text.split(currentTitle, '/')[1]
		local flag = Flags.icon(values.flag, gameCategory)
		local countryNode = mw.html.create('div')
			:wikitext(flag)
			:wikitext(country)
		container:node(country)
		
		index = index + 1
		current = args['country' .. index]
		currentLocation = args['city' .. index] or args['location' .. index]
	end
	
	return container
end

return Location