Jump to content

Module:WikiProject banner/auxiliary

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MSGJ (talk | contribs) at 14:19, 30 June 2023 (create). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

require('strict')
local p = {}
local sandbox-- = '/sandbox'
local cfg = mw.loadData('Module:WikiProject banner/config' .. (sandbox or ''))

p.b_checklist = function(args, raw_args)
---------------------------
-- B-class checklist ------
---------------------------
local show_checklist, parameters_used = false, nil
parameters_used = args.b1 or args.b2 or args.b3 or args.b4 or args.b5 or args.b6
if class=='B' or class=='C' then
	show_checklist = true
elseif class=='Start' and yesno(args.DISPLAY_ON_START) then
	show_checklist = true
elseif (class=='Start' or class=='Stub') and parameters_used then
	show_checklist = true
end
if show_checklist then
	local scale = args.QUALITY_CRITERIA=='custom' and assessment_link and assessment_link..'#'..lang:ucfirst(cfg.quality.name)
		or cfg.b_checklist.default_scale
	local text = string.format(
		cfg.b_checklist.text,
		parameters_used and cfg.b_checklist.checked or cfg.b_checklist.not_checked,
		scale
	)
	local criteria = mw.html.create('ol')
	for i = 1, 6 do
		local b = raw_args['b'..i]
		if b and b~='unused' then -- crtierion in use
			b = cfg.b_checklist.mask[string.lower(b)] or cfg.b_checklist.mask.default
			local image = '[[File:' .. cfg.b_checklist.icon[b] .. '.svg|16x16px|link=|alt=]]'
			criteria:tag('li')
				:wikitext(image .. ' ' .. cfg.b_checklist.criteria[i] .. ': ')
				:tag('span')
					:css('font-style', 'italic')
					:wikitext(cfg.b_checklist.status[b])
			:allDone()
		end
	end
	local checklist = mw.html.create('tr')
		:tag('td')
			:addClass('assess-b')
			:css('background', cfg.b_checklist.background):css('padding-bottom', '5px')
			:wikitext(cfg.b_checklist.image)
		:done()
		:tag('td')
			:addClass('wpb-collapsed-notes')
			:tag('table')
				:addClass('plainlinks mw-collapsible mw-collapsed')
				:tag('tr')
					:tag('th')
						:addClass('wpb-collapsed-head mbox-text')
						:attr('colspan', '3')
						:css('font-weight', 'normal')
						:wikitext(text)
					:done()
					:tag('td'):css('min-width', '3em'):done() -- empty cell for show/hide toggle
				:done()
				:tag('tr')
					:tag('td')
						:css('font-size', '90%')
						:node(criteria)
					:done()
					:tag('td')
						:css('font-size', '88%')
					:done()
					:tag('td'):addClass('empty-cell'):done()
				:done()
			:done()
		:done()
	:done()
	return checklist
end

end