Module:ReceptionTable: Difference between revisions

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 9: Line 9:
local showVolume = frame.args.showVolume ~= 'false'
local showVolume = frame.args.showVolume ~= 'false'


local header = '{| class="wikitable receptionTable diamonds" style="width:' .. width .. '; border: 2px groove ' .. borderColor .. '\n'
local header = '{| class="wikitable receptionTable diamonds" style="border-collapse: inherit; width:' .. width .. '; border: 2px groove ' .. borderColor .. '\n'
if showVolume then
if showVolume then
header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Volume\n'
header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Volume\n'
Line 31: Line 31:
-- Create the row with the necessary cells and rowspan
-- Create the row with the necessary cells and rowspan
local row = '|-'
local row = '|-'
if volume ~= '' then
if volume ~= '' then
row = row .. ' class="receptionTableSection"'
row = row .. 'class="receptionTableSection" style="border-top: 2px solid var(--' .. string.lower(part) .. '2);"\n! class="receptionTableImage ' .. part .. '4 diamonds"' .. 'style="width:12%;" rowspan="' .. rowspan .. '" | ' .. volume .. '\n'
row = row .. '\n! class="receptionTableImage ' .. part .. '4 diamonds" style="width:12%; border-top: 2px solid var(--' .. string.lower(part) .. '2);" rowspan="' .. rowspan .. '" | ' .. volume
end
end
row = row .. '\n| ' .. date .. '\n| ' .. rank .. '\n| ' .. copiesSold .. '\n| ' .. total
return row
local borderStyle = ' style="border-top: 2px solid var(--' .. string.lower(part) .. '2);"'
if volume ~= '' then
row = row .. '\n|' .. borderStyle .. ' | ' .. date
row = row .. '\n|' .. borderStyle .. ' | ' .. rank
row = row .. '\n|' .. borderStyle .. ' | ' .. copiesSold
row = row .. '\n|' .. borderStyle .. ' | ' .. total
else
row = row .. '\n| ' .. date
row = row .. '\n| ' .. rank
row = row .. '\n| ' .. copiesSold
row = row .. '\n| ' .. total
end
return row
end
end



Latest revision as of 17:44, 26 April 2024

Documentation for this module may be created at Module:ReceptionTable/doc

local p = {}

-- Function to create the header of the table
function p.header(frame)
    local part = frame.args.part or 'pb'
    local headerColor = frame.args.headerColor or '#ffffff'
    local width = frame.args.width or '80%'
    local borderColor = frame.args.borderColor or 'var(--' .. string.lower(part) .. '2)'
    local showVolume = frame.args.showVolume ~= 'false'

    local header = '{| class="wikitable receptionTable diamonds" style="border-collapse: inherit; width:' .. width .. '; border: 2px groove ' .. borderColor .. '\n'
    if showVolume then
    	header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Volume\n'
    end
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="min-width:150px; color:' .. headerColor .. ';" | Date\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Rank\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Physical Copies Sold\n'
    header = header .. '! class="receptionTableHeader ' .. part .. '" style="color:' .. headerColor .. ';" | Total\n'
    return header
end

-- Function to create a row in the table
function p.row(frame)
	local part = frame.args.part or 'pb'
    local volume = frame.args.volume or ''
    local date = frame.args.date or ''
    local rank = frame.args.rank or ''
    local copiesSold = frame.args.copiesSold or ''
    local total = frame.args.total or ''
    local rowspan = frame.args.rowspan or 1
    
    -- Create the row with the necessary cells and rowspan
	local row = '|-'
	if volume ~= '' then
	    row = row .. ' class="receptionTableSection"'
	    row = row .. '\n! class="receptionTableImage ' .. part .. '4 diamonds" style="width:12%; border-top: 2px solid var(--' .. string.lower(part) .. '2);" rowspan="' .. rowspan .. '" | ' .. volume
	end
	
	local borderStyle = ' style="border-top: 2px solid var(--' .. string.lower(part) .. '2);"'
	if volume ~= '' then
	    row = row .. '\n|' .. borderStyle .. ' | ' .. date
	    row = row .. '\n|' .. borderStyle .. ' | ' .. rank
	    row = row .. '\n|' .. borderStyle .. ' | ' .. copiesSold
	    row = row .. '\n|' .. borderStyle .. ' | ' .. total
	else
	    row = row .. '\n| ' .. date
	    row = row .. '\n| ' .. rank
	    row = row .. '\n| ' .. copiesSold
	    row = row .. '\n| ' .. total
	end
	
	return row
end

-- Function to close the table
function p.footer(frame)
    return '|}\n'
end

return p