Module:FeaturedLeagues

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, 7 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, 9 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 ul = div:tag('div'):addClass("tabs-March2014") :tag('ul') for tabRegionI, tabRegionRow in ipairs(activerounds) do						span = ul:tag('li') :tag('span') :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 span:addClass('_toggler_show-tab-' .. tabRegionI .. '-' .. pageTournamentI) :attr('id','current') else span:addClass('_toggler_show-tab-' .. tabRegionI .. '-' .. '1') end span:wikitext(tabRegionRow.region):done end -- make the 2nd row tabs based on this PAGE's bottabs ul = div:tag('div'):addClass("tabs-March2014"):addClass("tabs2ndRow") :tag('ul') if pageRegionRow.bottabs[1] then for tabTournamentI, tabTournament in ipairs(pageRegionRow.bottabs) do							span = ul:tag('li') :tag('span') :addClass('_toggler_hide-tabsF') :addClass('_toggler_show-tab-' .. pageRegionI .. '-' .. tabTournamentI) if pageTournamentI == tabTournamentI then span:attr('id','current') end span: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'):addClass('tabs-background'):css('height','10px'):done :tag('div'):css({ ["min-height"] = "446px", padding = "1%" }) :wikitext(frame:expandTemplate{ title = title, args = {} }) :done :done end end return tostring(tbl) end

return p