PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Statistics

From PC Gaming Shelter

Documentation for this module may be created at Module:Statistics/doc

local p = {}

function p.item(frame)
	local args = frame:getParent().args
	local itemName = args[1] or 'Shelter'
	local itemValue = args[2] or '100%'
	local itemTarget = args['target'] or nil
	local itemClass = args['class'] or ''
	local itemImage = args['image'] or 'Shelter.png'
	local itemImageUrl = frame:preprocess(
		string.format('{{filepath:{{PAGENAME:%s}}}}', itemImage)
	)
	
	local itemString = ''
	if itemTarget ~= nil then
		itemString = string.format('[[%s|%s]]', itemTarget, itemName)
	else
		itemString = string.format('%s', itemName)
	end
	
	local html = mw.html.create()
	html:tag('div'):addClass(string.format('shelter-stats-item %s', itemClass))
		:tag('div'):addClass('shelter-stats-item-icon'):attr('data-bg', itemImageUrl):done()
		:tag('div'):addClass('shelter-stats-item-name'):wikitext(itemString):done()
		:tag('div'):addClass('shelter-stats-item-value'):wikitext(itemValue):done()
	:done()
	return html
end	

return p