Module:MOS modes: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
force-collapse, following nick vucis recommendation on not sponsoring mode names |
||
| (38 intermediate revisions by 3 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 36: | Line 37: | ||
add_columns = add_columns and #mos_modes * #headers == #entries and #headers <= 3 | add_columns = add_columns and #mos_modes * #headers == #entries and #headers <= 3 | ||
end | end | ||
-- Table caption | -- Table caption | ||
local scale_sig = mos.as_string(input_mos) | local scale_sig = mos.as_string(input_mos) | ||
result = | |||
.. | -- Start of table | ||
local result = "{| class=\"wikitable sortable center-2 center-3 mw-collapsible" .. (is_collapsed and " mw-collapsed\"\n" or "\"\n") | |||
.. "|+ style=\"font-size: 105%; white-space: nowrap;\" | " .. string.format("Modes of %s\n", scale_sig) | |||
.. "|-\n" | .. "|-\n" | ||
-- Table headers | -- Table headers | ||
result = result | result = result | ||
.. "! [[UDP]]" | .. "! [[UDP]]" | ||
.. " !! | .. " !! Cyclic<br />order" | ||
.. " !! Step pattern" | .. " !! Step<br />pattern" | ||
-- Add header for mode names, if provided. | -- Add header for mode names, if provided. | ||
| Line 60: | 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 70: | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
-- Add the UDP | -- 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 86: | 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 120: | 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 | ||