Module:CareerList: Difference between revisions
Jump to navigation
Jump to search
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 17: | Line 17: | ||
-- Функция для создания ячейки таблицы |
-- Функция для создания ячейки таблицы |
||
function p.makeCell(cellType, |
function p.makeCell(cellType, args) |
||
local function getColor(index) |
local function getColor(index) |
||
return (index % 2 == 0) and '#F3F3F3' or '#FFFFFF' |
return (index % 2 == 0) and '#F3F3F3' or '#FFFFFF' |
||
Line 44: | Line 44: | ||
end |
end |
||
local site = args.site or mw.title.getCurrentTitle().text |
|||
local id = args.id or '' |
|||
local alias = args.alias or '' |
|||
local notes = args.notes or '' |
|||
local background = getBackground(site) |
local background = getBackground(site) |
||
Line 55: | Line 59: | ||
:css('background-color', background) |
:css('background-color', background) |
||
:css('padding', '8px') |
:css('padding', '8px') |
||
:wikitext(id |
:wikitext(id) |
||
:done() |
:done() |
||
Line 85: | Line 89: | ||
if config[site] then |
if config[site] then |
||
local url = config[site].url |
local url = config[site].url |
||
local id = mw.text.encode(site) |
local id = mw.text.encode(site.id) |
||
return string.format('[%s %s]', url:gsub('$1', id), site) |
return string.format('[%s %s]', url:gsub('$1', id), site) |
||
else |
else |
Revision as of 03:08, 13 March 2023
Documentation for this module may be created at Module:CareerList/doc
local p = {} -- Функция для создания таблицы function p.makeTableTop() local headerRow = mw.html.create('tr') :node(mw.html.create('th'):wikitext('Site')) :node(mw.html.create('th'):wikitext('ID')) :node(mw.html.create('th'):wikitext('Alias')) :node(mw.html.create('th'):wikitext('Notes')) :done() return mw.html.create('table') :css('width', '100%') :node(headerRow) :done() end -- Функция для создания ячейки таблицы function p.makeCell(cellType, args) local function getColor(index) return (index % 2 == 0) and '#F3F3F3' or '#FFFFFF' end local function getBackground(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 function getAlias(alias, title) if not alias or alias == '' then return title else return alias end end local function getNotes(notes) if not notes or notes == '' then return 'N/A' else return notes end end local site = args.site or mw.title.getCurrentTitle().text local id = args.id or '' local alias = args.alias or '' local notes = args.notes or '' local background = getBackground(site) local cell = mw.html.create('td') :css('background-color', background) :css('padding', '8px') :wikitext(p.getSiteLink(site)) :done() local idCell = mw.html.create('td') :css('background-color', background) :css('padding', '8px') :wikitext(id) :done() local aliasCell = mw.html.create('td') :css('background-color', background) :css('padding', '8px') :wikitext(getAlias(alias, mw.title.getCurrentTitle().text)) :done() local notesCell = mw.html.create('td') :css('background-color', background) :css('padding', '8px') :wikitext(getNotes(notes)) :done() return mw.html.create('tr') :css('background-color', getColor()) :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 return p