Module:Sound

From Downtime Wiki
Revision as of 19:15, 17 August 2024 by MC>TreeIsLife
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

function p.main(f)
	local args = f:getParent().args
	
	local result = {}
	
	local title = args[1] or ''
	
	table.insert(result, '<span class="sound"><span class="sound-title">' .. title .. '</span>')
	
	if args.nofallback and args.nofallback ~= '' then
		table.insert(result, '<span style="display:none">[[File:' .. args[2] .. '|class=sound-audio]]</span>')
	else
		table.insert(result, '<span>[[File:' .. args[2] .. '|class=sound-audio]]</span>')
	end
	
	table.insert(result, '</span>')
	
	for i in ipairs(args) do
		if args[i+2] and args[i+2] ~= '' then
			table.insert(result, '<span class="sound"><span class="sound-title"></span><span style="display:none">[[File:' .. args[i+2] ..'|class=sound-audio]]</span></span>')
		end
	end
	
	return table.concat(result)
end

return p