Module:FeaturedLeagues

local SETTINGS = mw.loadData('Module:FeaturedLeagues/Settings')

local p = {}

function p.featuredLeagues(frame) local args = frame if frame == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) else frame = mw.getCurrentFrame end local activerounds = {} local j = 1 for region = 1, SETTINGS.maxregions do if args['r' .. region .. 'active'] == "Yes" then activerounds[j] = { region = args['r' .. region] } if args['r' .. region .. 'bottabs'] == "Yes" then activerounds[j].bottabs = {} k = 1 for tournament = 1, SETTINGS.maxtournaments do if args['r' .. region .. 't' .. tournament .. 'active'] == 'Yes' then activerounds[j].bottabs[k] = args['r' .. region .. 't' .. tournament] k = k + 1 end end else activerounds[j].bottabs = { false } end j = j + 1 end end -- now for each region, the row looks like { region = regionname, bottabs = {false or list of tournaments } } local currentregion = args['r' .. args['showregion'] or 1] local currenttournament = args['r' .. (args['showregion'] or 1) .. 't' .. (args['showtournament'] or 1) ] tbl = mw.html.create -- first loop through all regions & tournaments to make each tab (including ones that are display:none; until clicked on) for pageRegionI, pageRegionRow in ipairs(activerounds) do		for pageTournamentI, pageTournament in ipairs(pageRegionRow.bottabs) do			style = {} if pageRegionRow.region ~= currentregion or pageTournament ~= currenttournament then style.display = "none" end div = tbl:tag('div'):addClass("_toggle tab-" .. pageRegionI .. '-' .. pageTournamentI .." tabsF"):css(style) -- now we are inside a page so build up the page -- make the top row tabs, we need to iterate through all regions again as well as all tournaments of the current region local row1 = div:tag('div'):addClass("titletabs-tabs") for tabRegionI, tabRegionRow in ipairs(activerounds) do					tab = row1:tag('div'):addClass('titletabs-tab'):addClass('_toggler_hide-tabsF') -- if we are on this region, then toggle should show current event; otherwise it should show tournament 1 for other event -- also make it current if it's current if pageRegionI == tabRegionI then tab:addClass('_toggler_show-tab-' .. tabRegionI .. '-' .. pageTournamentI) :addClass('titletabs-active') else tab:addClass('_toggler_show-tab-' .. tabRegionI .. '-' .. '1') end tab:wikitext(tabRegionRow.region):done end -- make the 2nd row tabs based on this PAGE's bottabs local row2 = div:tag('div'):addClass("titletabs-tabs"):addClass('titletabs-row2') if pageRegionRow.bottabs[1] then for tabTournamentI, tabTournament in ipairs(pageRegionRow.bottabs) do						tab = row2:tag('div'):addClass('titletabs-tab') :addClass('_toggler_hide-tabsF') :addClass('_toggler_show-tab-' .. pageRegionI .. '-' .. tabTournamentI) if pageTournamentI == tabTournamentI then tab:addClass('titletabs-active') end tab:wikitext(tabTournament):done end end -- include the content titletable = { "Project:Featured Leagues", pageRegionRow.region } if pageRegionRow.bottabs[1] then titletable[#titletable+1] = pageTournament end title = table.concat(titletable,"/") div:tag('div'):css({ ["min-height"] = "446px", padding = "1%" }) :wikitext(frame:expandTemplate{ title = title, args = {} }) :done :done end end return tostring(tbl) end

return p