Module:Progression rainbow: Difference between revisions

Content deleted Content added
slight blip expected
clean
Line 5:
require('Module:No globals')
 
local getArgs = require('Module:Arguments').getArgs
local p = {}
 
Line 48 ⟶ 47:
 
function p.main(frame)
local args =return p._main(require('Module:Arguments').getArgs(frame))
return p._main(args, frame)
end
 
function p._main(args, frame)
-- frame needs to be available for extensionTag and expandTemplate
-- TODO: Digest what Johnuniq said on [[WT:Lua]] about the frame.
 
local classes = {
Line 109 ⟶ 105:
root:addClass('progression-rainbow')
 
-- Don't care which frame it is if all I want to do is expand templates
-- and extension tags
local current_frame = mw.getCurrentFrame()
for _, class in ipairs(classes) do
if class.count ~= 0 then
Line 114 ⟶ 113:
root:newline() -- sprinkled through to make the HTML easier to read
root:tag('li')
:css('background', framecurrent_frame:expandTemplate{
title = 'class/colour', args = { class.class }
})
:css('width', percentage)
:tag('span')
:addClass('sr-only')
-- wikitext accessibly-hidden by CSS
:wikitext(string.format('%s %s', percentage, class.category))
:done()
Line 133 ⟶ 132:
:css('width', remaining)
:tag('span')
:addClass('sr-only')
:wikitext(string.format('%s remaining', remaining))
:done()
Line 139:
end
root:allDone()
return framecurrent_frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Progression rainbow/styles.css'}
} .. current_frame:extensionTag{
name = 'templatestyles', args = { src = 'ProgressionScreen rainbowreader-only/styles.css'}
} .. '\n' .. tostring(root)
end