[checked revision] | [checked revision] |
No edit summary |
m (→top: Remove now-unused (true) from util_args.merge) |
||
(12 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 '', |
+ | Active = mw.text.split(args.active or '',sep), |
− | Inactive = mw.text.split(args.inactive or '', |
+ | Inactive = mw.text.split(args.inactive or '',sep), |
Active_markup = {}, |
Active_markup = {}, |
||
Inactive_markup = {}, |
Inactive_markup = {}, |
||
Line 19: | Line 17: | ||
allteams_markup = {} |
allteams_markup = {} |
||
} |
} |
||
− | |||
− | teamscopy = {} |
||
-- standardize input names & make markup tables |
-- standardize input names & make markup tables |
||
for _, list in pairs{"Active", "Inactive"} do |
for _, list in pairs{"Active", "Inactive"} do |
||
for i, team in ipairs(teams[list]) do |
for i, team in ipairs(teams[list]) do |
||
− | team = |
+ | if team ~= '' then |
− | teams[list][i] = |
+ | teams[list][i] = m_team.teamlinkname(team) |
− | teams[list .. '_markup'][i] = |
+ | teams[list .. '_markup'][i] = m_team.rightlonglinked(team, {size=45}) |
− | teams.allteams[#teams.allteams+1] = teams[list][i] |
+ | teams.allteams[#teams.allteams+1] = teams[list][i] |
− | teams.allteams_markup = teams[list .. '_markup'][i] |
+ | teams.allteams_markup[#teams.allteams_markup+1] = teams[list .. '_markup'][i] |
⚫ | |||
end |
end |
||
end |
end |
||
Line 37: | Line 34: | ||
for _, list in pairs{"Active", "Inactive"} do |
for _, list in pairs{"Active", "Inactive"} do |
||
for i, team in ipairs(teams[list]) do |
for i, team in ipairs(teams[list]) do |
||
+ | if team ~= '' then |
||
⚫ | |||
− | + | table.remove(teams[list],i) |
|
⚫ | |||
− | data = { |
||
− | + | 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,','), |
|
⚫ | |||
− | _table = ' |
+ | _table = 'SisterTeams' |
− | } |
+ | } |
− | frame:callParserFunction('#cargo_store:',data) |
||
+ | util_cargo.store(data) |
||
⚫ | |||
− | table.insert(teams[list |
+ | table.insert(teams[list],i,team) |
⚫ | |||
+ | 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') |
||
− | :wikitext(table.concat(teams.Inactive,' • ')) |
||
− | :done() |
||
− | :tag('td') |
||
− | :wikitext(table.concat(teams.Active_markup,' • ')) |
||
− | :done() |
||
− | :tag('td') |
||
⚫ | |||
− | :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