Modulo:Mscore resizable
La documentazione per questo modulo può essere creata in Modulo:Mscore resizable/man
function setdefaultcss( defaultwidth, size, step )
if defaultwidth >= size and defaultwidth < size + step then
return "block"
else
return "none"
end
end
function genscoreset( frame, parsedargs, defaultwidth, minwidth, maxwidth, step )
local div
local result = ''
for size = minwidth, maxwidth, step do
parsedargs['width'] = size
div = mw.html.create( 'div' )
div
:attr( "class", "score-resizable score-resizable-size-" .. tostring( 4 * size + 15 ) )
:css( "display", setdefaultcss( defaultwidth, size, step ) )
:wikitext( mscore.genscore( frame, parsedargs ) )
result = result .. tostring( div ) .. '\n'
end
return result
end
function genlist( frame )
local parsedargs = { }
local minwidth = 100
local maxwidth = 400
local defaultwidth = 180
local step = 20
local args = frame:getParent().args
for k, v in pairs( args ) do
if type( k ) == "number" then
return error('unnamed template parameter encountered; maybe | was used instead of {{!}}')
elseif type( k ) == "string" and k == "minwidth" and tonumber( args[k] ) > minwidth then
if tonumber( args[k] ) < maxwidth then
minwidth = tonumber( args[k] )
else
minwidth = maxwidth
end
elseif type( k ) == "string" and k == "maxwidth" and tonumber( args[k] ) > minwidth and tonumber( args[k] ) < maxwidth then
maxwidth = tonumber( args[k] )
else
parsedargs[k] = v
end
end
if (maxwidth - maxwidth) / 9 > 20 then
step = toInt((maxwidth - maxwidth) / 9)
end
if defaultwidth < minwidth then
defaultwidth = minwidth
elseif defaultwidth > maxwidth then
defaultwidth = maxwidth - step + 1
end
mscore = require( 'Module:Mscore' )
local div = mw.html.create( 'div' )
:attr( "class", "score-resizable-container" )
:wikitext( genscoreset( frame, parsedargs, defaultwidth, minwidth, maxwidth, step ) )
return tostring( div )
end
local p = {}
function p.genscorelist( frame )
return genlist( frame )
end
return p