Module:Sandbox/User:Als Toy Barn/ShopLocLine
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Template:Module sandbox/doc. [edit] [history] [purge]
Module:Sandbox/User:Als Toy Barn/ShopLocLine requires Module:Edit button.
Module:Sandbox/User:Als Toy Barn/ShopLocLine requires Module:Map.
Module:Sandbox/User:Als Toy Barn/ShopLocLine requires Module:NA.
Module:Sandbox/User:Als Toy Barn/ShopLocLine requires Module:Paramtest.
This module is a sandbox for Als Toy Barn. It can be used to test changes to existing modules, prototype new modules, or just experimenting with lua features.
Invocations of this sandbox should be kept in userspace; if the module is intended for use in other namespaces, it should be moved out of the sandbox into a normal module and template.
This default documentation can be overridden by creating the /doc subpage of this module, as normal.
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