Content deleted Content added
No edit summary
No edit summary
 
(19 intermediate revisions by 2 users not shown)
Line 1:
local p = {}
 
-- Функция для создания таблицы
function p.createCareerListTop(frame)
function p.makeTableTop()
local args = frame.args
local listheaderRow = argsmw.list or ""html.create('tr')
:node(mw.html.create('th'):wikitext('site'))
local bgColor = args.bgColor or "#F2F2F2"
local html = :node(mw.html.create('th'):wikitext('id'))
:node(mw.html.create('th'):wikitext('alias'))
 
:node(mw.html.create('th'):tagwikitext("div"'notes'))
:cssdone("background-color", bgColor)
:wikitext("{| class=\"wikitable career-list\"")
:wikitext("\n|-" .. "\n!")
:wikitext(list)
:wikitext("\n|}")
 
return tostring(mw.html.create('table')
:css('width', '100%')
:node(headerRow)
:done()
end
 
-- Функция для создания ячейки таблицы
function p.createCareerList(frame)
function p.makeCell(cellType, args)
local args = frame.args
local sitefunction = args.site or ""getColor(index)
return ((index or 0) % 2 == 0) and '#F3F3F3' or '#FFFFFF'
local id = args.id or ""
end
local alias = args.alias or mw.title.getCurrentTitle().text
local notes = args.notes or "N/A"
local html = mw.html.create()
 
local configfunction = mw.loadDatagetBackground("Module:CareerList/Config"site)
local config = mw.loadData('Module:CareerList/config')
local color = (cellType == 'Studio') and '#DADADA' or '#E7E7E7'
return config[site] and color or '#FFFFFF'
end
 
local urlfunction =getAlias(alias, config[site].url or ""title)
if not alias or alias == '' then
url = url:gsub("%$1", id)
return 'N/A'
else
return alias
end
end
 
local bgColorfunction = "#FFFFFF"getNotes(notes)
if config[site].typenot notes or notes == "Studio"'' then
bgColorreturn = "#DADADA"'N/A'
else
elseif config[site].type == "Website" then
bgColorreturn = "#E7E7E7"notes
end
end
 
if not args.site then
html:tag("tr")
return mw.html.create('tr')
:css("background-color", bgColor)
:css('background-color', getColor(args.rowIndex))
:tag("td")
:node(mw.html.create('td'):attr('colspan', '4'):wikitext('Invalid arguments. Please see documentation for correct usage.'))
:wikitext(config[site].name or "")
:wikitextdone(": ")
end
:tag("a")
 
:attr("href", url)
local site = args.site or mw.title.getCurrentTitle().text
:wikitext(alias)
local id = args.id or ''
local alias = getAlias(args.alias, site)
local notes = getNotes(args.notes)
local background = getBackground(site)
 
local cell = mw.html.create('td')
:css('background-color', background)
:css('padding', '8px')
:wikitext(p.getSiteLink(site))
:done()
 
:tag("td")
local idCell = :wikitextmw.html.create(notes'td')
:css('background-color', background)
:css('padding', '8px')
:wikitext(id)
:done()
 
returnlocal tostring(aliasCell = mw.html.create('td')
:css('background-color', background)
:css('padding', '8px')
:wikitext(aliasCell)
:done()
 
local notesCell = mw.html.create('td')
:css('background-color', background)
:css('padding', '8px')
:wikitext(notesCell)
:done()
 
return mw.html.create('tr')
:css('background-color', getColor(args.rowIndex))
:node(cell)
:node(idCell)
:node(aliasCell)
:node(notesCell)
:done()
end
-- Функция для определения ссылки на сайт
function p.getSiteLink(site)
local config = mw.loadData('Module:CareerList/config')
site = site:lower()
if config[site] then
local url = config[site].url
local id = mw.text.encode(site.id)
return string.format('[%s %s]', url:gsub('$1', id), site)
else
return site
end
end
 
-- Функция для обработки аргументов
function p.processArgs(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:CareerList'
})
local site = args[1] or ''
local id = args[2] or ''
local alias = args[3] or ''
local notes = args[4] or ''
 
if site == '' then
return '<strong class="error">Error: </strong>Site parameter is required'
else
site = site:lower()
if not mw.loadData('Module:CareerList/config')[site] then
return '<strong class="error">Error: </strong>Invalid site specified'
else
return p.makeCell(site, id, alias, notes)
end
end
end
 
-- Главная функция модуля
function p.main(frame)
local tableTop = p.makeTableTop()
local tableRows = ''
for i = 1, 999 do
local result = p.processArgs(frame:getParent())
if type(result) == 'string' then
return result
elseif not result then
break
else
tableRows = tableRows .. tostring(result)
end
end
return tostring(tableTop) .. tableRows .. '</table>'
end