Module:Sandbox

--This module is invoked by Template:Nav

local p = {} local getArgs = require('Module:Arguments').getArgs

function setDefault(arg, value) if(arg == nil) then arg = value end return arg end

function p.main(frame) args = getArgs(frame) if(pcall(p._main, args)) then return p._main(args) else return ' Error. See Template:Nav for more info. '   end end

function p._main(args) local out, border, templink, class, style, styleFE, headerFE, header, style1 local frame = mw.getCurrentFrame local rows = '' local nHead, nSub = 15, 10 -- number of Headers and Subheaders for iteration -- Initialize args border =   setDefault(args.border, '#999') templink = setDefault(args.templink, 'Nav') class =    setDefault(args.class, '') style =    setDefault(args.style, '') styleFE =  setDefault(args.styleFE, '') header =   setDefault(args.header, 'Header') style1 =   setDefault(args.style1, '')

-- Top row if(args.headerFE ~= nil) then rows = rows..'\n!class="'..class..'" style="'..styleFE..'"|'..args.headerFE..'\n|-' end local collapse for i = 1, nHead do           if(args['content'..i] ~= nil) then if(string.match(args['content'..i], mw.title.getCurrentTitle.text) ~= nil) then collapse = '' else collapse = 'collapsed' end end end -- Sections for i = 1, nHead do       if(args['header'..i] ~= nil) then rows = rows.. '\n|-\n|'.. '\n{|class="collapsible '..collapse..'" width=100% cellspacing=0 cellpadding=0'.. '\n!colspan=2 style="'..setDefault(args['style'..i], args.style1)..'"'.. '| '..args['header'..i]..' ' if(args['content'..i] ~= nil) then rows = rows..'\n|-\n| '..args['content'..i]           else for j = 1, nSub do                   if(args['subheader'..i..'-'..j] ~= nil) then if(j == 1) then rows = rows..'\n|-\n!style="width:15%; '                       else                            rows = rows..'\n|-\n!style="width:15%; border-top: 1px solid #001866; ' end rows = rows..setDefault(args['substyle'..i..'-'..j], args.style1).. '"| '..args['subheader'..i..'-'..j]..                       '\n|style="padding: 3px; border-top: 1px solid '..border..'; text-align: left"| '                        ..args['subcontent'..i..'-'..j]                    end                end            end            rows = rows..'\n|}'        end    end    -- Final output    out =     '{|class="collapsible collapsed" cellspacing=2 cellpadding=0 '..    'style="width: 100%; text-align:center; font-family: times; border:2px solid '..border..'"'..    '\n!style="'..style..'"| '..    frame:expandTemplate{ title = 'Tnav', args = { 'Template:'..templink, fontcolor = '' } }..    ' '..header..' '..    '\n|-'..    rows..    '\n|}'    return out end

return p --