Modul:Platemeldingar
Utsjånad
Dokumentasjon for modulen kan opprettast på Modul:Platemeldingar/dok
-- This module implements [[Mal:Platemeldingar]].
local mTableTools = require('Module:TableTools')
local yesno = require('Module:Yesno')
local p = {}
local function makeCell(html, s)
html
:tag('td')
:css('text-align', 'center')
:css('vertical-align', 'middle')
:wikitext(s)
end
local function makeRow(review, score)
local row = mw.html.create('tr')
makeCell(row, review)
makeCell(row, score)
return row
end
local function makeHeaderRow(header, background, scope)
local row = mw.html.create('tr')
row
:tag('th')
:attr('scope', scope ~= false and 'col' or nil)
:attr('colspan', 2)
:css('text-align', 'center')
:css('background', background ~= false and '#d1dbdf' or nil)
:css('font-size', '120%')
:css('color', 'black')
:wikitext(header)
return row
end
local function makeRatingHeaderRow()
local row = mw.html.create('tr')
row
:tag('th')
:attr('scope', 'col')
:wikitext('Kjelde')
:done()
:tag('th')
:attr('scope', 'col')
:wikitext('Karakter')
return row
end
function p._main(args)
local reviewNums = mTableTools.affixNums(args, 'kritikk')
local root = mw.html.create()
local tableRoot = root:tag('table')
local duplicatescores = 0
-- Table base
tableRoot
:addClass('wikitable infobox')
:css('float', args.align or 'right')
:css('width', args.width or '24.2em')
:css('font-size', '80%')
:css('text-align', 'center')
:css('margin', '0.5em 0 0.5em 1em')
:css('padding', 0)
:css('border-spacing', 0)
:tag('tr')
:tag('th')
:attr('scope', 'col')
:attr('colspan', 2)
:css('font-size', '120%')
:wikitext(args.title or 'Meldingar')
-- Subtitle
if args.undertittel then
tableRoot:node(makeHeaderRow(args.undertittel, false, false))
end
-- Metacritic
if args.MC then
tableRoot:node(makeHeaderRow('Samla karakter', true, true))
tableRoot:node(makeRatingHeaderRow())
tableRoot:node(makeRow('[[Metacritic]]', args.MC))
end
-- Review rows
tableRoot:node(makeHeaderRow('Karakter', true, true))
tableRoot:node(makeRatingHeaderRow())
for i, num in ipairs(reviewNums) do
tableRoot:node(makeRow(
args['kritikk' .. num],
args['kritikk' .. num .. 'Karakter'] or
args['Kritikk' .. num .. 'Karakter'] or
args['kritikk' .. num .. 'karakter'] or
args['Kritikk' .. num .. 'karakter']
))
local scorecount = 0
scorecount = scorecount + (args['kritikk' .. num .. 'Karakter'] and 1 or 0)
scorecount = scorecount + (args['Kritikk' .. num .. 'Karakter'] and 1 or 0)
scorecount = scorecount + (args['kritikk' .. num .. 'Karakter'] and 1 or 0)
scorecount = scorecount + (args['Kritikk' .. num .. 'Karakter'] and 1 or 0)
if scorecount > 1 then duplicatescores = duplicatescores + 1 end
end
return tostring(root)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Mal:Platemeldingar'
})
return p._main(args)
end
return p