Module:Fótboltalið

Þessi skrifta setur upp lista yfir fótboltamenn í liði. Listanum er skipt jafnt í tvo lista hlið við hlið, óháð því hversu margir leikmenn eru tilgreindir.


local p = {}

local pos = {
	MF = "[[Miðjumaður|MF]]",
	DF = "[[Varnarmaður|DF]]",
	FW = "[[Framherji|FW]]",
	GK = "[[Markmaður|GK]]"
	}

function p.main(frame)
	local pframe = frame:getParent()
	local config = frame.args
	local arg = pframe.args
    
	local z = {}
	local y = mw.html.create("small")
	y
		:wikitext("Ath: Fánar eru tákn fyrir það þjóðerni sem skráð eru hjá [[FIFA]]. Leikmenn gætu haft fleiri en eitt ríkisfang.")
		:done()
	table.insert(z, [[<table style="border:0"><tr><td valign="top" bgcolor="#FFFFFF" style="width:48%">
	<table cellspacing="0" style="border:0; cellpadding:2"><tr bgcolor="#AAD0FF"><td style="width:1%"><b> Nú. </b></td>
	<td style="width:1%"></td><td style="width:1%"><b> Staða </b></td><td style="width:75%"><b> Leikmaður </b></td></tr>]])

	local i = 1
	while arg["pos" .. i] ~= nil and arg["pos" .. i] ~= "" do
		i = i + 1
	end
	local midpoint = math.floor(i / 2)
	
	local other = {}
	local c = 1
	while arg["pos" .. c] ~= nil and arg["pos" .. c] ~= "" do
		if arg["other" .. c] ~= nil then
			table.insert(other, c, "''(".. arg["other" .. c] .. ")''")
		end
		table.insert(z, '<tr class="vcard agent"><td style="text-align:right">' .. (arg["no" .. c] or "") ..
		'</td><td style="text-align:right">' .. frame:expandTemplate{ title = arg["nat" .. c] } .. '</td><td style="text-align:center">' .. 
		pos[arg["pos" .. c]] ..'</td><td><span class="fn">' .. (arg["name" .. c] or "") .. (arg["ref" .. c] or "") ..  
			'</span> ' .. (other[c] or "") .. '</td></tr>')
	
		if c == midpoint then
			table.insert(z, [[</table><td style="width:1%"></td></td><td valign="top" bgcolor="#FFFFFF" style="width:48%">
			<table cellspacing="0" style="border:0; cellpadding:2"><tr bgcolor="#AAD0FF"><td style="width:1%"><b>Nú. </b></td>
			<td style="width:1%"></td><td style="width:1%"><b> Staða </b></td><td style="width:75%"><b> Leikmaður </b></td></tr>]])
		end
		c = c + 1
	end
	table.insert(z, '</tr></table></table>')
	return table.concat(z) .. tostring(y)
end

return p