Content deleted Content added
for s&g, make this th Tag: Reverted |
use require('strict') instead of require('Module:No globals') |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 3:
]]
require('
local getArgs = require('Module:Arguments').getArgs▼
local p = {}
Line 13 ⟶ 12:
end
local function
-- These suck for i18n because the % is forced to the right without spacing,
-- both in a required context (CSS) and unrequired (to-be-displayed text).
-- I.e., there should be a separate version of this
return tostring(round(100 * param / total)) .. '%'
end
Line 24 ⟶ 22:
local remaining = total - sum
if remaining > 0 then
return
else
return nil
Line 47 ⟶ 45:
end
function p.
end▼
function p._main(args, frame)▼
local classes = {
Line 88 ⟶ 79:
else
for i, class in ipairs(classes) do
-- 'or class.count' to keep us safe from
class.count = tonumber(args[i]) or class.count
sum_classes = sum_classes + class.count
Line 106 ⟶ 97:
end
local
local root = mw.html.create('ul')
root:addClass('progression-rainbow')
if height then
root:
end
local current_frame = mw.getCurrentFrame()
for _, class in ipairs(classes) do
if class.count ~= 0 then
local percentage =
root:newline() -- sprinkled through to make the HTML easier to read
root:tag('
:css('background',
title = 'class/colour', args = { class.class }
})
:css('width', percentage)
:attr('title', string.format('%s %s', percentage, class.category))
:tag('span')
:addClass('sr-only')
:wikitext(string.format('%s %s', percentage, class.category)) :done()
:done()
end
end
Line 136 ⟶ 127:
local remaining = percent_remaining(sum_classes, total)
if remaining then
root:tag('
:addClass('remaining')
:css('width', remaining)
:tag('span')
▲ :wikitext(string.format('%s remaining', remaining))
:
:wikitext(string.format('%s remaining', remaining))
:done()▼
:done()
▲ :done()
:newline()
end
root:allDone()
return
name = 'templatestyles', args = { src = 'Module:Progression rainbow/styles.css'}
} .. current_frame:extensionTag{
name = 'templatestyles', args = { src = 'Screen reader-only/styles.css'}
} .. '\n' .. tostring(root)
▲end
end
|