Module:Progression rainbow: Difference between revisions

Content deleted Content added
add spans so we can nuke this text off the screen
? :D maybe integrated project
Line 26:
return nil
end
end
 
local function category_count(class, project)
return frame:callParserFunction(
'PAGESINCATEGORY',
class .. project .. 'articles',
'R'
)
end
 
function p.main(frame)
local args = getArgs(frame)
localreturn main_frame =p._main(args, frame)
return frame:extensionTag{ name = 'templatestyles',
args = { src = 'Progression rainbow/styles.css'} }
.. '\n' .. tostring(p._main(args, main_frame))
-- pretty sure that this call to extensionTag should be in _main
-- since a caller from a module should get the associated styles also
end
 
 
-- we should implement this more accessibly,
function p._main(args, main_frameframe)
-- like providing the values for blind people and then hiding with CSS
-- is there a way that I can avoid passing a reference to the parent frame?
-- HTML <meter> could implement this? not sure
-- I need to be able to access extensionTag and callParserFunction in p._main
function p._main(args, main_frame)
-- these are defined on frame
local divisor = args['9'] or 100
if args['project'] and args['project'] ~= '' then
local project = args['project']
else
local project = nil
end
local classes = {
{0, 'List', 'List-Class'},
{0, 'Stub', 'Stub-Class'},
{0, 'Start', 'Start-Class'},
{0, 'C', 'C-Class'},
{0, 'B', 'B-Class'},
{0, 'GA', 'GA-Class'},
{0, 'A', 'A-Class'},
{0, 'FA', 'FA-Class'}
}
local project_classes = {
{0, 'FL', 'FL-Class'},
{0, 'Unassessed', 'Unassessed'}
}
-- set the value from arguments in classes, first column
local sum_classes = 0
for i, class in pairs(classes) do
if args[i]project then
class[1] = category_count(class[3], project)
if class[2] == 'FA' then
class[1] = class[1] + category_count(
project_classes[1][3],
project
)
end
elseif args[i] then
class[1] = tonumber(args[i])
sum_classes = sum_classes + class[1]
end
sum_classes = sum_classes + class[1]
end
 
if project then
local divisor = sum_classes + category_count(
project_classes[2][3],
project
)
else
local divisor = args['9'] or 100
end
Line 64 ⟶ 100:
root:addClass('progression-rainbow')
:attr('role', 'presentation')
 
for i, class in pairs(classes) do
if class[1] ~= 0 then
Line 70 ⟶ 106:
root:newline()
:tag('td')
:css('background', main_frameframe:expandTemplate{
title = 'class/colour', args = { class[2] }})
)
:css('width', percentage)
:tag('span')
:wikitext(percentage .. " " .. class[23] .. "-class")
:done()
:done()
Line 92 ⟶ 129:
:newline()
end
-- not sure if I should be stringifying p._main return instead of returning
return root
-- a table
return frame:extensionTag{ name = 'templatestyles',
name = 'templatestyles',
args = { src = 'Progression rainbow/styles.css'} }
} .. '\n' .. tostring(p._main(args, main_frame)root)
end