Module:KnownRecordings: Difference between revisions
(Created page with "local p = {} -- Define the color map based on the status local statusColors = { released = "#aaffaa", unreleased = "#ffaaaa", ["partially released"] = "#ffffaa", duplicate = "#cccccc", unknown = nil } -- Main function to render the table function p.renderTable(frame) local args = frame:getParent().args local rows = {} -- Iterate over provided rows for i = 1, tonumber(args.rowcount or 0) do local title = args["title" .. i...") |
No edit summary Tag: Reverted |
||
Line 3: | Line 3: | ||
-- Define the color map based on the status | -- Define the color map based on the status | ||
local statusColors = { | local statusColors = { | ||
released = "# | released = "#d4edda", | ||
unreleased = "# | unreleased = "#f8d7da", | ||
["partially released"] = "# | ["partially released"] = "#fff3cd", | ||
duplicate = "# | duplicate = "#e2e3e5", | ||
unknown = nil | unknown = nil | ||
} | } |
Revision as of 13:04, 25 November 2024
Documentation for this module may be created at Module:KnownRecordings/doc
local p = {}
-- Define the color map based on the status
local statusColors = {
released = "#d4edda",
unreleased = "#f8d7da",
["partially released"] = "#fff3cd",
duplicate = "#e2e3e5",
unknown = nil
}
-- Main function to render the table
function p.renderTable(frame)
local args = frame:getParent().args
local rows = {}
-- Iterate over provided rows
for i = 1, tonumber(args.rowcount or 0) do
local title = args["title" .. i] or ""
local artist = args["artist" .. i] or ""
local status = args["status" .. i] or "unknown"
local color = statusColors[status:lower()] or statusColors["unknown"]
-- Create table row with background color
local row = string.format(
'<tr%s><td>%s</td><td>%s</td><td>%s</td></tr>',
color and (' style="background-color:' .. color .. ';"') or "",
title, artist, status
)
table.insert(rows, row)
end
-- Combine all rows into a table
return string.format('<table class="wikitable">%s</table>', table.concat(rows))
end
return p