[checked revision] | [checked revision] |
((via Mediawiker ST3)) |
((via Mediawiker ST3)) |
||
Line 35: | Line 35: | ||
end |
end |
||
− | function p. |
+ | function p.mediumname(str, settings) |
if not settings then settings = {} end |
if not settings then settings = {} end |
||
h.getInfo(str, settings) |
h.getInfo(str, settings) |
Revision as of 08:48, 14 November 2018
Edit the documentation or categories for this module.
local util_args = require('Module:ArgsUtil')
local LOOKUP = mw.loadData('Module:Regionnames')
local h = {}
function h.getInfo(str, settings)
if not str then str = '' end
settings.vars = util_args.lookupVars(str, LOOKUP)
return
end
function h.makeImage(settings)
local div = mw.html.create('div')
:addClass('region-icon')
:cssText(('color:#%s'):format(settings.vars.hex))
:wikitext(settings.vars.short)
return div
end
local p = {}
function p.main(frame)
local args = util_args.merge(true)
if not args[1] and not args.sub then
return ''
end
local style = args[2] or 'rightlong'
return p[style](args[1], args)
end
function p.regionname(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
return settings.vars.long
end
function p.mediumname(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
return settings.vars.medium
end
function p.regionshortname(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
return settings.vars.short
end
function p.regionadjectivename(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
return settings.vars.adjective
end
function p.onlyimage(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
return tostring(h.makeImage(settings))
end
function p.rightshort(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
local tbl = mw.html.create('div')
:cssText('display:inline-block;')
tbl:node(h.makeImage(settings))
tbl:wikitext(' ' .. settings.vars.short)
return tostring(tbl)
end
function p.rightmedium(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
local tbl = mw.html.create('div')
:cssText('display:inline-block;')
tbl:node(h.makeImage(settings))
tbl:wikitext(' ' .. settings.vars.medium)
return tostring(tbl)
end
function p.rightlong(str, settings)
if not settings then settings = {} end
h.getInfo(str, settings)
local tbl = mw.html.create('div')
:cssText('display:inline-block;')
tbl:node(h.makeImage(settings))
tbl:wikitext(' ' .. settings.vars.long)
return tostring(tbl)
end
function p.region( frame )
local args = frame
if frame == mw.getCurrentFrame() then
args = require( 'Module:ProcessArgs' ).merge( true )
else
frame = mw.getCurrentFrame()
end
local Names = mw.loadData('Module:Regionnames')
local Styles = require('Module:Regionstyles')
local inputlc = mw.ustring.lower(args[1] or '')
local style = args[2] or 'rightmedium'
local namevars = Names[inputlc]
if not namevars then
namevars = {long = "Unrecognized Region", medium = "Unknown", short = "???", adjective = "Unknown", hex = "8A24CA" }
elseif type(namevars) == 'string' then
namevars = Names[namevars]
end
return Styles[style](namevars)
end
return p