Difference between revisions of "Module:Display"

From Foundation - Wiki
Jump to navigation Jump to search
(re-enabling images following backend fix)
Tag: Undo
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
--<nowiki>
--<nowiki>
local p = {}
local p = {}
local com = require( 'Module:Common' )


function gridIconList(data)
function gridIconList(data, cols)
result = ''
result = ''
if data ~= nil and data ~= '' then
if com.exists(data) then
data = mw.text.split(data, '\n')
data = mw.text.split(data, '\n')
result = mw.html.create('div')
result = mw.html.create('div')
result:addClass('Icon-Text-Grid')
result:addClass('Icon-Text-Grid')
if cols ~= nil and cols ~= '' then
result:addClass('Icon-Grid-Cols-' .. cols)
end
innerResult = ''
innerResult = ''
for k, v in ipairs(data) do
for k, v in ipairs(data) do
innerData = mw.text.split(v, ',')
if v ~= nil and v ~= '' then
innerFrame = mw.html.create('span')
innerData = mw.text.split(v, ',')
innerFrame:wikitext('[[file:' .. innerData[1] .. '|50px|frameless]] - ') -- .. innerData[2])
innerFrame = mw.html.create('span')
innerResult = innerResult .. tostring(innerFrame)
innerFrame:wikitext('[[file:' .. innerData[1] ..  
'|50px|frameless]] - ' .. innerData[2])
innerResult = innerResult .. tostring(innerFrame)
end
end
end
result:wikitext(innerResult)
result:wikitext(innerResult)
Line 21: Line 28:


function p.gridIconList(frame)
function p.gridIconList(frame)
return gridIconList(frame.args[1])
return gridIconList(frame.args[1], frame.args['cols'])
end
end


return p
return p

Latest revision as of 20:07, 6 December 2021

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

--<nowiki>
local p = {}
local com = require( 'Module:Common' )

function gridIconList(data, cols)
	result = ''
	if com.exists(data) then
		data = mw.text.split(data, '\n')
		result = mw.html.create('div')
		result:addClass('Icon-Text-Grid')
		if cols ~= nil and cols ~= '' then
			result:addClass('Icon-Grid-Cols-' .. cols)
		end
		innerResult = ''
		for k, v in ipairs(data) do
			if v ~= nil and v ~= '' then
				innerData = mw.text.split(v, ',')
				innerFrame = mw.html.create('span')
				innerFrame:wikitext('[[file:' .. innerData[1] .. 
					'|50px|frameless]] - ' .. innerData[2])
				innerResult = innerResult .. tostring(innerFrame)
			end
		end
		result:wikitext(innerResult)
	end
	return result
end

function p.gridIconList(frame)
	return gridIconList(frame.args[1], frame.args['cols'])
end

return p