Module:ShopLocLine

This is the current revision of this page, as edited by Alex (talk | contribs) at 16:18, 15 October 2024 (Created page with "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 ~= n..."). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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