Module:MOS modes: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
force-collapse, following nick vucis recommendation on not sponsoring mode names |
||
| (31 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | |||
local mos = require("Module:MOS") | local mos = require("Module:MOS") | ||
local rat = require("Module:Rational") | local rat = require("Module:Rational") | ||
local tamnams = require("Module:TAMNAMS") | |||
local tip = require("Module:Template input parse") | |||
local utils = require("Module:Utils") | local utils = require("Module:Utils") | ||
local yesno = require("Module:Yesno") | local yesno = require("Module:Yesno") | ||
-- TODO: | -- TODO: | ||
| Line 13: | Line 14: | ||
-- To be called by wrapper | -- To be called by wrapper | ||
function p._mos_modes(input_mos, mode_names, headers, entries, is_collapsed) | function p._mos_modes(input_mos, mode_names, headers, entries, is_collapsed) | ||
local is_collapsed | local is_collapsed = true | ||
local input_mos = input_mos or mos.new(5,2) | local input_mos = input_mos or mos.new(5,2) | ||
local mode_names = mode_names or {} | local mode_names = mode_names or {} | ||
| Line 59: | Line 60: | ||
if add_columns then | if add_columns then | ||
for i = 1, #headers do | for i = 1, #headers do | ||
result = result .. " !! class=\"unsortable\" | " | result = result .. string.format(" !! class=\"unsortable\" | %s", headers[i]) | ||
end | end | ||
end | end | ||
| Line 70: | Line 71: | ||
-- Add the UDP, brightness order, and the mode's step pattern | -- Add the UDP, brightness order, and the mode's step pattern | ||
result = result .. "| " | result = result .. string.format("| %s || %s || %s", | ||
udps[i], cpos[i], mos_modes[i]) | |||
-- Add the mode's name, if given | -- Add the mode's name, if given | ||
if add_mode_names then | if add_mode_names then | ||
result = result .. " || " | result = result .. string.format(" || %s", mode_names[i]) | ||
end | end | ||
| Line 81: | Line 83: | ||
for j = 1, #headers do | for j = 1, #headers do | ||
local index = (i - 1) * #headers + j | local index = (i - 1) * #headers + j | ||
result = result .. " || " | result = result .. string.format(" || %s", entries[index]) | ||
end | end | ||
end | end | ||
| Line 115: | Line 117: | ||
-- Get mode names entered | -- Get mode names entered | ||
if #frame.args["Mode Names"] ~= 0 then | if #frame.args["Mode Names"] ~= 0 then | ||
mode_names = tip.parse_entries(frame.args["Mode Names"]) | mode_names = tip.parse_entries(frame.args["Mode Names"], "$") | ||
end | end | ||
-- Get supplementary info | -- Get supplementary info | ||
local headers_unparsed = frame.args["Table Headers"] | local headers_unparsed = frame.args["Table Headers"] | ||
local headers = tip.parse_entries(headers_unparsed) | local headers = tip.parse_entries(headers_unparsed, "$") | ||
local entries_unparsed = frame.args["Table Entries"] | |||
local entries = tip.parse_entries(entries_unparsed, "$") | |||
local is_collapsed = yesno(frame.args["Collapsed"], false) | |||
local debugg = yesno(frame.args["debug"]) | |||
local result = p._mos_modes(input_mos, mode_names, headers, entries, is_collapsed) | |||
-- Current means of adding entries is unmaintainable; to be deprecated. | |||
if headers_unparsed ~= "" and entries_unparsed ~= "" then | |||
result = result .. "[[Category:Pages with deprecated template parameters]]" | |||
end | |||
-- Debugger option | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||