Module:Userbox: Difference between revisions

Content added Content deleted
m (1 revision imported: Importing Committed identity template)
No edit summary
Line 297: Line 297:
end
end


local legible = true
local contrast = require('Module:Color contrast')._ratio
local contrast = require('Module:Color contrast')._ratio


Line 310: Line 309:
wikitext = wikitext:gsub("%[%[%s*[Ff][Ii][Ll][Ee]%s*:[^|]-(|.-)]]", get_alt)
wikitext = wikitext:gsub("%[%[%s*[Ff][Ii][Ll][Ee]%s*:[^|]-(|.-)]]", get_alt)
return mw.text.trim(wikitext) ~= ""
return mw.text.trim(wikitext) ~= ""
end

if contrast { data.infoColor, data.backgroundColor, error = 0 } < 4.5 then
legible = false
end

if data.showId and contrast { data.idColor, data.idBackgroundColor, error = 0 } < 4.5 then
if has_text(data.id or "") then
legible = false
end
end

if data.showId2 and contrast { data.id2Color, data.id2BackgroundColor, error = 0 } < 4.5 then
if has_text(data.id2 or "") then
legible = false
end
end

if not legible then
root:wikitext('[[Category:Potentially illegible userboxes]]')
end
end