Module:Csdcheck
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This is the Lua module called by {{csdcheck}}. Please see the main template page for documentation.
local p = {}
function p.check(frame)
local result = "Input values: ";
local test_criteria = {};
local input_values = {};
local all_criteria = {"G1","G2","G3","G4","G5","G6","G7","G8","G9","G10","G11","G12","A1","A2","A3","A5","A7","A9","A10","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","C1","C2","U1","U2","U3","R2","R3","T2","T3","P1","P2"};
local tag_criteria = {"G1","G2","G3","G4","G5","G6","G7","G8","G10","G11","G12","A1","A2","A3","A5","A7","A9","A10","F1","F2","F3","F7","F8","F9","F10","C1","U1","U2","U3","R2","R3","T2","P1","P2"};
local notice_criteria = {"G1","G2","G3","G4","G10","G11","G12","A1","A2","A3","A5","A7","A9","A10","F1","F2","F3","F7","F9","F10","C1","U3","R2","R3","T2","P1","P2"};
for k,v in pairs(frame.args) do
k = tostring(k);
v = mw.ustring.upper(v);
if mw.ustring.match(k,"^crit[1-9]%d*$") then -- insert critn parameter values into test_criteria
for a,b in ipairs(all_criteria) do
if b == v then
table.insert(test_criteria,v)
end
end
elseif mw.ustring.match(k,"^[1-9]%d*$") then -- insert positional parameter values into input_values
v = mw.ustring.gsub(v,"^%s*(%S*)%s*$","%1"); -- strip whitespace from positional parameters
for a,b in ipairs (all_criteria) do
if b == v then
table.insert(input_values,v)
end
end
end
end
for k,v in ipairs(input_values) do
result = result .. v .. ", ";
end
result = result .. "Checking criteria: ";
for k,v in ipairs(test_criteria) do
result = result .. k .. "=" .. v .. ", ";
end
return result
--[[
local result = nil
for i,v in ipairs(args) do
local crit = {"G1","G2","G3","G4"}
for x,y in ipairs(crit) do
if v == y then
result = "yes";
end
end
end
return result
--]]
end
return p