[checked revision] | [checked revision] |
No edit summary |
m (→top: Remove now-unused (true) from util_args.merge) |
||
(19 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
+ | local util_cargo = require('Module:CargoUtil') |
||
+ | local m_team = require('Module:Team') |
||
+ | local sep = '%s*,%s*' |
||
+ | |||
local p = {} |
local p = {} |
||
− | function p. |
+ | function p.main(frame) |
− | local args = |
+ | local args = util_args.merge() |
− | if frame == mw.getCurrentFrame() then |
||
− | args = require( 'Module:ProcessArgs' ).merge( true ) |
||
− | else |
||
− | frame = mw.getCurrentFrame() |
||
⚫ | |||
− | |||
⚫ | |||
teams = { |
teams = { |
||
− | + | Active = mw.text.split(args.active or '',sep), |
|
− | + | Inactive = mw.text.split(args.inactive or '',sep), |
|
− | + | Active_markup = {}, |
|
− | + | Inactive_markup = {}, |
|
+ | allteams = {}, |
||
+ | allteams_markup = {} |
||
} |
} |
||
-- standardize input names & make markup tables |
-- standardize input names & make markup tables |
||
− | for |
+ | for _, list in pairs{"Active", "Inactive"} do |
− | team |
+ | for i, team in ipairs(teams[list]) do |
+ | if team ~= '' then |
||
− | teams.activelist[i] = Team{team, "teamlinkname"} |
||
− | teams |
+ | teams[list][i] = m_team.teamlinkname(team) |
+ | teams[list .. '_markup'][i] = m_team.rightlonglinked(team, {size=45}) |
||
+ | teams.allteams[#teams.allteams+1] = teams[list][i] |
||
+ | teams.allteams_markup[#teams.allteams_markup+1] = teams[list .. '_markup'][i] |
||
+ | end |
||
⚫ | |||
end |
end |
||
− | |||
− | for i, team in ipairs(teams.inactivelist) do |
||
− | team = mw.text.trim(team) |
||
− | teams.inactivelist[i] = Team{team, "teamlinkname"} |
||
− | teams.inactivelist_markup[i] = Team{team} |
||
⚫ | |||
− | |||
− | teams.allteams = table.concat(teams.activelist,",") .. "," .. table.concat(teams.inactivelist) |
||
− | teams.allteams_markup = table.concat(teams.activelist_markup,",") .. "," .. table.concat(teams.inactivelist_markup) |
||
-- store cargo |
-- store cargo |
||
+ | other = { Active = "Inactive", Inactive = "Active" } |
||
− | for _, list in pairs{" |
+ | for _, list in pairs{"Active", "Inactive"} do |
− | list_markup = list .. "_markup" |
||
for i, team in ipairs(teams[list]) do |
for i, team in ipairs(teams[list]) do |
||
+ | if team ~= '' then |
||
⚫ | |||
− | teams[list] |
+ | table.remove(teams[list],i) |
⚫ | |||
− | teams[list_markup][i] = "" |
||
− | data = { |
+ | data = { |
− | Team = team, |
+ | Team = team, |
− | Team_Markup = team_markup, |
+ | Team_Markup = team_markup, |
− | Status = |
+ | Status = list, |
− | + | ActiveList = table.concat(teams.Active,','), |
|
− | + | InactiveList = table.concat(teams.Inactive,','), |
|
− | Active_Markup = table.concat |
+ | Active_Markup = table.concat(teams.Active_markup,','), |
− | Inactive_Markup = table.concat |
+ | Inactive_Markup = table.concat(teams.Inactive_markup,','), |
− | AllTeams = teams.allteams, |
+ | AllTeams = table.concat(teams.allteams,','), |
− | AllTeams_Markup = teams.allteams_markup, |
+ | AllTeams_Markup = table.concat(teams.allteams_markup,','), |
− | _table = ' |
+ | _table = 'SisterTeams' |
− | } |
+ | } |
+ | util_cargo.store(data) |
||
− | teams[list][i] = team |
||
− | teams[ |
+ | table.insert(teams[list],i,team) |
+ | table.insert(teams[list .. '_markup'],i,team_markup) |
||
− | frame:callParserFunction('#cargo_store:',data) |
||
+ | end |
||
end |
end |
||
end |
end |
||
− | tbl = mw.html.create() |
+ | local tbl = mw.html.create() |
− | tbl:tag('tr') |
+ | local tr = tbl:tag('tr') |
− | + | tr:tag('td') |
|
− | + | :wikitext(table.concat(teams.Active_markup,' • ')) |
|
− | + | tr:tag('td') |
|
⚫ | |||
− | :tag('td') |
||
⚫ | |||
− | :done() |
||
− | :tag('td') |
||
− | :wikitext(table.concat(teams.activelist_markup,' • ')) |
||
− | :done() |
||
− | :tag('td') |
||
− | :wikitext(table.concat(teams.inactivelist_markup,' • ')) |
||
− | :done() |
||
− | :done() |
||
− | return |
+ | return tbl |
end |
end |
||
return p |
return p |
Latest revision as of 09:14, 29 March 2020
Edit the documentation or categories for this module.
local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local m_team = require('Module:Team')
local sep = '%s*,%s*'
local p = {}
function p.main(frame)
local args = util_args.merge()
teams = {
Active = mw.text.split(args.active or '',sep),
Inactive = mw.text.split(args.inactive or '',sep),
Active_markup = {},
Inactive_markup = {},
allteams = {},
allteams_markup = {}
}
-- standardize input names & make markup tables
for _, list in pairs{"Active", "Inactive"} do
for i, team in ipairs(teams[list]) do
if team ~= '' then
teams[list][i] = m_team.teamlinkname(team)
teams[list .. '_markup'][i] = m_team.rightlonglinked(team, {size=45})
teams.allteams[#teams.allteams+1] = teams[list][i]
teams.allteams_markup[#teams.allteams_markup+1] = teams[list .. '_markup'][i]
end
end
end
-- store cargo
other = { Active = "Inactive", Inactive = "Active" }
for _, list in pairs{"Active", "Inactive"} do
for i, team in ipairs(teams[list]) do
if team ~= '' then
table.remove(teams[list],i)
team_markup = table.remove(teams[list .. '_markup'],i)
data = {
Team = team,
Team_Markup = team_markup,
Status = list,
ActiveList = table.concat(teams.Active,','),
InactiveList = table.concat(teams.Inactive,','),
Active_Markup = table.concat(teams.Active_markup,','),
Inactive_Markup = table.concat(teams.Inactive_markup,','),
AllTeams = table.concat(teams.allteams,','),
AllTeams_Markup = table.concat(teams.allteams_markup,','),
_table = 'SisterTeams'
}
util_cargo.store(data)
table.insert(teams[list],i,team)
table.insert(teams[list .. '_markup'],i,team_markup)
end
end
end
local tbl = mw.html.create()
local tr = tbl:tag('tr')
tr:tag('td')
:wikitext(table.concat(teams.Active_markup,' • '))
tr:tag('td')
:wikitext(table.concat(teams.Inactive_markup,' • '))
return tbl
end
return p