Module:ShopLocLine
Module documentation
This documentation is transcluded from Template:No documentation/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:ShopLocLine/doc. [edit]
Module:ShopLocLine's function main is invoked by Template:ShopLocLine.
Module:ShopLocLine requires Module:Edit button.
Module:ShopLocLine requires Module:Map.
Module:ShopLocLine requires Module:NA.
Module:ShopLocLine requires Module:Paramtest.
local p = {}
local editBtn = '<small>' .. require('Module:Edit button')() .. '</small>'
local isEmpty = require('Module:Paramtest').is_empty
local hc = require('Module:Paramtest').has_content
local na = require('Module:NA')
local map = require('Module:Map')
function p.main(frame)
local args = frame:getParent().args
local locationRow = mw.html.create('tr')
locationRow:tag('td'):wikitext(args.name)
locationRow:tag('td'):wikitext(args.location)
if args.notes ~= nil then
locationRow:tag('td'):wikitext(tostring(args.notes))
end
local members = (args.members and args.members:lower() == 'yes' and 'yes') or 'no'
local membersIcon = mw.getCurrentFrame():expandTemplate({ title='members', args={ members }})
locationRow:tag('td'):wikitext(membersIcon)
local mapNode = getMap(args, members)
locationRow:node(mapNode)
return tostring(locationRow)
end
function getMap(args, members)
local mapNode = mw.html.create('td')
local mapOutput
if not args.mtype then
-- Get text from first wikilink
-- Allows for link renaming and subobject selection
local name = args.name:match('%[%[([^%|%]]+)')
local mapOpts = { type = 'maplink', text = 'Maplink' }
mapOutput = map.getMap(name, mapOpts)
else
local mapArgs = {}
for k, v in pairs(args) do
mapArgs[k] = v
end
mapArgs.type = 'maplink'
if args.name then
mapArgs.title = args.name
end
if members then
mapArgs.icon = 'redPin'
else
mapArgs.icon = 'bluePin'
end
mapOutput = map.buildMap(mapArgs)
end
if mapOutput then
mapNode:wikitext(mapOutput)
else
na.styleNode(mapNode, 'Unknown')
end
return mapNode
end
return p