FANDOM


local data = mw.loadData('Module:MediaTimeline/data')
 
local yesno = require('Module:Yesno')
 
local function makeInlineError(msg)
    return string.format(
        '\n<strong class="error">MediaTimeline error: %s.</strong>',
        msg
    )
end
 
local function makeRowError(msg)
    return string.format(
        '|-\n|colspan="4"|<strong class="error">MediaTimeline error: %s.</strong>',
        msg
    )
end
 
local TEMPLATE = [===[
|- class="%s"
|%s||style="background-color:#%s;text-align:center;"|%s||%s%s%s
|%s]===]
 
local p = {}
 
function p._main(type, name, date, note, author, unreleased, extraArgs)
    if not type then
        return makeRowError('the "type" parameter is required')
    elseif not data[type] then
        return makeRowError('unrecognized "type" argument')
    elseif not name then
        return makeRowError('the "name" parameter is required')
    end
    date = date or ' '
    note = note and string.format('\n*<small>%s</small>', note) or ''
    author = author or ''
    unreleased = yesno(unreleased)
    local datarecord = unreleased and data['!'] or data[type]
    local error = extraArgs and makeInlineError('unrecognized arguments') or ''
    return TEMPLATE:format(datarecord.class, date, datarecord.bgcolor,
                           type, name, note, error, author)
end
 
function p.main(frame)
    local type, name, date, note, author, unreleased
    local extraArgs = false
    for k, v in pairs(frame:getParent().args) do
        v = v:match('^%s*(.-)%s*$') -- trim whitespace
        if v ~= '' then
            if k == 'type' then type = v
            elseif k == 'name' then name = v
            elseif k == 'date' then date = v
            elseif k == 'note' then note = v
            elseif k == 'author' then author = v
            elseif k == 'unreleased' then unreleased = v
            else extraArgs = true
            end
        end
    end
    return p._main(type, name, date, note, author, unreleased, extraArgs)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.