Module:Navbox

From TerraFirmaCraft Wiki
Revision as of 22:14, 8 September 2013 by Kittychanley (Talk | contribs) (Created page with "local p = {} function p.box( f ) local args = f:getParent().args local navbox = {} if args.title and args.title ~= '' then local class...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

local p = {} function p.box( f )

       local args = f:getParent().args
       local navbox = {}
       if args.title and args.title ~=  then
               local class = args.class or 'collapsible'
               local bodyStyle = args.bodystyle or 
               if bodyStyle ~=  then
                       bodyStyle = 'style="' .. bodyStyle .. '"'
               end
               table.insert( navbox, '{| class="navbox hlist ' .. class .. '" ' .. bodyStyle )
               
               local titleStyle = args.titlestyle or 
               if titleStyle ~=  then
                       titleStyle = 'style="' .. titleStyle .. '"'
               end
               local navbar = args[1] or 
               if navbar ~=  then
                       local mini = 
                       if navbar:match( 'navbar%-mini' ) then
                               mini = '1'
                       end
navbar = ''
               end
               table.insert( navbox, '! class="navbox-top" colspan="2" ' .. titleStyle .. ' | ' .. navbar .. '' .. args.title .. '' )
       else
               table.insert( navbox, '{| class="navbox-child"' )
       end
       
       local groupNums = {}
       for i in pairs( args ) do
               local groupNum = tostring( i ):match( 'group(%d+)' )
               table.insert( groupNums, tonumber( groupNum ) )
       end
       table.sort( groupNums )
       for i, v in ipairs( groupNums ) do
               local list = args['list' .. v] or 
               if list ~=  then
                       local groupStyle = args.groupstyle or 
                       if groupStyle ~=  then
                               groupStyle = 'style="' .. groupStyle .. '"'
                       end
                       local listStyle = args.liststyle or 
                       if listStyle ~=  then
                               listStyle = 'style="' .. listStyle .. '"'
                       end
                       
                       table.insert( navbox, '|-\n! class="navbox-group" ' .. groupStyle .. ' | ' .. args['group' .. v] )
                       table.insert( navbox, '| class="navbox-list" ' .. listStyle .. ' | ' .. '\n' .. list )
               end
       end
       
       table.insert( navbox, '|}' )
       
       return table.concat( navbox, '\n' )

end return p