[checked revision] | [checked revision] |
(all = showall for ofl (via Mediawiker ST3)) |
(move disabled nil check (via Mediawiker ST3)) |
||
Line 72: | Line 72: | ||
function h.printDisabledText(caption, patchinfo) |
function h.printDisabledText(caption, patchinfo) |
||
− | if not patchinfo.disabled then return end |
+ | if not patchinfo.disabled or not next(disabled) then return end |
local span = caption:tag('span') |
local span = caption:tag('span') |
||
:addClass('matchlist-patch-disabled') |
:addClass('matchlist-patch-disabled') |
||
Line 80: | Line 80: | ||
function h.getDisabledText(disabled) |
function h.getDisabledText(disabled) |
||
− | if not next(disabled) then return nil end |
||
return util_table.concat(disabled, '', m_champion.onlyimagelinked) |
return util_table.concat(disabled, '', m_champion.onlyimagelinked) |
||
end |
end |
Revision as of 10:44, 9 August 2019
This module is NOT able to be synced with code from other esports wikis!
The code has been significantly customized in accordance with the needs of this particular wiki. DO NOT OVERWRITE IT!!! |
local util_args = require('Module:ArgsUtil')
local util_footnote = require('Module:FootnoteUtil')
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require('Module:ToggleUtil')
local i18n = require('Module:i18nUtil')
local m_champion = require('Module:Champion')
local h = {}
local p = {
players_per_team = 5,
side_names = {
'Blue', 'Red',
['1'] = 'Blue',
['2'] = 'Red'
},
years = { 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 },
store_player_league_history = true, -- do we store to PlayerLeagueHistory from InfoboxPlayer? will prevent needing to sync a normally-unneeded dependency
}
function p.linkPatch(str)
return util_text.intLink(('Patch %s'):format(str), str)
end
---------------------------------------------------------
------------------ MatchList hooks ---------------------
---------------------------------------------------------
local MATCHLIST_PATCH_TOGGLES = {
init = 'all',
order = { 'all', 'number', 'none' },
showall = 'all',
}
function p.onMatchListProcessTabRow(row, i, j, args, tab)
-- add patch as a table caption
util_table.initTable(tab, 'patchinfo', { patches = {}, hotfixes = {}, disabled = {}, footnotes = {} })
if not row.Patch then return true end
MATCH_LIST_HAS_PATCH = true
util_table.initDict(tab.patchinfo.patches, row.Patch)
if row.Hotfix then
util_table.initDict(tab.patchinfo.hotfixes, row.Hotfix)
end
if row.PatchFootnote then
util_table.initDict(tab.patchinfo.footnotes, row.PatchFootnote)
end
util_table.merge(tab.patchinfo.disabled, util_text.split(row.Disabled))
return true
end
function p.onMatchListPrintCaption(tbl, tab)
if not MATCH_LIST_HAS_PATCH then return true end
local caption = tbl:tag('caption')
h.printPatchNumber(caption, tab.patchinfo)
h.printDisabledText(caption, tab.patchinfo)
util_footnote.tagFootnotes(caption, tab.patchinfo.footnotes)
return true
end
function h.printPatchNumber(caption, patchinfo)
local span = caption:tag('span')
:addClass('matchlist-patch-number')
:wikitext(i18n.print('patchCaption', h.getPatchText(patchinfo.patches)))
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'number')
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'all')
end
function h.getPatchText(patches)
return util_table.concatNonempty(patches, ', ', p.linkPatch) or i18n.print('tbd')
end
function h.printDisabledText(caption, patchinfo)
if not patchinfo.disabled or not next(disabled) then return end
local span = caption:tag('span')
:addClass('matchlist-patch-disabled')
:wikitext(i18n.print('patchDisabled', h.getDisabledText(patchinfo.disabled)))
util_toggle.oflCellClasses(span, MATCHLIST_PATCH_TOGGLES, 'all')
end
function h.getDisabledText(disabled)
return util_table.concat(disabled, '', m_champion.onlyimagelinked)
end
function p.onMatchListPrintTogglesEnd(tbl)
div = tbl:tag('div'):addClass('toggle-button')
div:wikitext(i18n.print('patchToggle'))
util_toggle.printOptionFromListTogglers(div, MATCHLIST_PATCH_TOGGLES)
end
return p