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

local p = {}

function p.createCareerListTop(frame)
    local args = frame.args
    local list = args.list or ""
    local bgColor = args.bgColor or "#F2F2F2"
    local html = mw.html.create()

    html:tag("div")
        :css("background-color", bgColor)
        :wikitext("{| class=\"wikitable career-list\"")
        :wikitext("\n|-" .. "\n!")
        :wikitext(list)
        :wikitext("\n|}")

    return tostring(html)
end

function p.createCareerList(frame)
    local args = frame.args
    local site = args.site or ""
    local id = args.id or ""
    local alias = args.alias or mw.title.getCurrentTitle().text
    local notes = args.notes or "N/A"
    local html = mw.html.create()

    local config = mw.loadData("Module:CareerList/config")

    local url = config[site].url or ""
    url = url:gsub("%$1", id)

    local bgColor = "#FFFFFF"
    if config[site].type == "Studio" then
        bgColor = "#DADADA"
    elseif config[site].type == "Website" then
        bgColor = "#E7E7E7"
    end

    html:tag("tr")
        :css("background-color", bgColor)
        :tag("td")
            :wikitext(config[site].name or "")
            :wikitext(": ")
            :tag("a")
                :attr("href", url)
                :wikitext(alias)
        :done()
        :tag("td")
            :wikitext(notes)
        :done()

    return tostring(html)
end

return p