Module:Tt

From BlazBlue Wiki
Revision as of 00:47, 6 August 2019 by Chao (talk | contribs) (nest spans instead)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}
local cargo = mw.ext.cargo

function p.Main( frame )
	text = frame.args[1] or ''
	tooltip = frame.args[2] or ''
	line = frame.args['line'] or ''
	align = frame.args['align'] or 'default'
	
	if line == 'false' then
		tooltip_style = 'border-bottom: 0;'
	else
		tooltip_style = ''
	end
	
	parts = {
		'<span class="tooltip" style="',tooltip_style,'">',
		text,
		'<span class="tooltiptext" style="text-align:',align,'">',
		tooltip,
		'</span></span>'
	}
	mw.log(concatvalues(parts,""))
	return concatvalues(parts,"")
end

-- concat all the strings in table s together with the given delimiter
function concatvalues(s,delimiter)
    local t = { }
    for k,v in ipairs(s) do
        t[#t+1] = tostring(v)
    end
    return table.concat(t,delimiter)
end

return p