Module:CareerList: Difference between revisions
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary |
PeaceDeadC (talk | contribs) No edit summary |
||
Line 1:
local p = {}
--
local
--
local function
return config[site] and config[site][key]
end
-- helper function to format the alias or notes field
local function formatText(text)
return text ~= '' and text or 'N/A'
-- helper function to
local function generateTableRow(site, id, alias, notes, rowColor)
local row = string.format(▼
local siteColor = getConfigValue(site, 'color')
local cellColor = site == 'Website' and '#E7E7E7' or '#DADADA'
color,▼
local
local siteStyle = string.format('background-color: %s;', siteColor or cellColor)
local siteName =
local url =
alias == '' and mw.title.getCurrentTitle().text or alias,▼
<td style="%s">%s</td>
<td style="%s"><a href="%s">%s</a></td>
<td style="%s">%s</td>
<td style="%s">%s</td>
]], rowStyle, siteStyle, siteName, cellColor, url, site, cellColor, alias, cellColor, formatText(notes))
end
--
function p.main(frame)
local args = frame.args
local
for row in mw.text.gsplit(list, '%{%{CareerList') do
local
rowColor = rowColor == '#FFFFFF' and '#F3F3F3' or '#FFFFFF'
▲ local params = mw.text.split(row, '%s*|%s*')
▲ local site = params[1]
▲ local id = params[2]
▲ local notes = params[4] or ''
▲ tableContent = tableContent .. buildRow(site, id, alias, notes, index)
end
local tableStyle = 'background-color: #F2F2F2; width: 100%;'
return string.format('<table style="%s">%s</table>', tableStyle, rows)
▲ local tableHtml = string.format(cfg.tableTemplate, tableContent)
end
| |||