Module:MOS modes: Difference between revisions

Ganaram inukshuk (talk | contribs)
add function to process individual entries for cells, entered as individual template params; work-in-progress
Ganaram inukshuk (talk | contribs)
force-collapse, following nick vucis recommendation on not sponsoring mode names
 
(15 intermediate revisions by the same user not shown)
Line 10: Line 10:
-- TODO:
-- TODO:
-- - Add ability to autocollapse on large mos pages (say, more than 12 modes)
-- - Add ability to autocollapse on large mos pages (say, more than 12 modes)
-- - Drop/replace delimiter-based mode name input; it's harder to maintain
-- Extract column info
-- Mode numbering is by BRIGHT GENS DOWN PER PERIOD
-- Nothing is returned; instead, args is modified
function p.preprocess_entries(num_modes, args, col_name)
local col_name = col_name or ""
local col_data = {}
local is_col_empty = true
for i = 1, num_modes do
-- Put together key, then use it to get data from args
local bright_gens_down = i - 1
local key = string.format("%sD", bright_gens_down) .. (col_name ~= "" and string.format(" %s", col_name) or "")
local cell = args[key] or ""
cell = utils.trim(cell)
-- Then transfer data to col_data
table.insert(col_data, cell)
-- Then remove data from args
args[key] = nil
-- Check whether data was present; absence of data is expressed as an
-- empty string.
is_col_empty = is_col_empty and cell == ""
end
if not is_col_empty then
args[string.format("%s Entries", col_name)] = col_data
end
end


-- "Main" function
-- "Main" function
-- 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 = is_collapsed == true
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 = {}
local mode_names = mode_names or {}
local headers = {}
local headers = headers or {}
local entries = {}
local entries = entries or {}
-- Get UDPs and CPOs
-- Get UDPs and CPOs
Line 172: Line 140:
return frame:preprocess(result)
return frame:preprocess(result)
end
-- Tester
function p.tester()
local args = {
["0D Name"] = "AAA",
["1D Name"] = "BBB",
["2D Name"] = "CCC",
["3D Name"] = "DDD"
}
p.preprocess_entries(5, args, "Name")
return args
end
end


return p
return p