Fandom

Fire Emblem Wiki

Module:Nav

5,321pages on
this wiki
Add New Page
Talk0
--This module is invoked by Template:Nav
 
local p = {}
local getArgs = require('Module:Arguments').getArgs
local common = require('Module:Common')
 
function p.main(frame)
    args = getArgs(frame)
    if(pcall(p._main, args)) then
        return p._main(args)
    else
        return '<span style="color: red">Error. See [[Template:Nav]] for more info.</span>'
    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, 15  -- number of Headers and Subheaders for iteration
 
    -- Initialize args
    border =    common.setDefault(args.border, '#999')
    templink =  common.setDefault(args.templink, 'Nav')
    class =     common.setDefault(args.class)
    style =     common.setDefault(args.style)
    styleFE =   common.setDefault(args.styleFE)
    header =    common.setDefault(args.header, 'Header')
    style1 =    common.setDefault(args.style1)
 
    -- Top row
    if(args.headerFE ~= nil) then 
        rows = rows..'<div class="top-row '..class..'" style="'..styleFE..'">'..args.headerFE..'</div>'
    end
 
    -- Sections
    for i = 1, nHead do
        if(args['header'..i] ~= nil) then
            --------------------- Section Head ------------------------
            rows = rows..
            '<div class="section mw-collapsible mw-collapsed">'..
            '<div class="mw-collapsible-toggle '..class..'"> </div>'..
            '<div style="padding-left: 3em; '..common.setDefault(args['style'..i], style1)..'">'..
            '<b>'..args['header'..i]..'</b>'..
            '</div>'..
            '<div class="mw-collapsible-content">'
 
            --------------------- Section Content ------------------------
            if(args['content'..i] ~= nil) then
                rows = rows..'<div>'..args['content'..i]..'</div>'
            else
                rows = rows..'\n{|width=100% cellpadding=0 cellspacing=0'
                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..common.setDefault(args['substyle'..i..'-'..j], style1)..
                        '"| '..args['subheader'..i..'-'..j]..
                        '\n|style="padding: 3px; border-top: 1px solid '..border..'; text-align: left"|\n'
                        ..common.setDefault(args['subcontent'..i..'-'..j])
                    end
                end
                rows = rows..'\n|}'
            end
 
            if(args['note'..i] ~= nil) then
                rows = rows..
                '<div style="font-style: italic; border-top: 1px solid '..
                border..'">'.. args['note'..i]..'</div>'
            end
            rows = rows..'</div></div>'
        end
    end
 
    -- Final output
    out = 
    '\n<div class="navbox mw-collapsible mw-collapsed" '..
    'style="border:2px solid '..border..'">'..
    '<div class="mw-collapsible-toggle '..class..'"> </div>'..
    '<div class="navhead" style="'..style..'">'..
    frame:expandTemplate{ title = 'Tnav', args = { 'Template:'..templink, fontcolor = '' } }..
    '<b>'..header..'</b>'..
    '</div>'..
    '<div class="mw-collapsible-content">'..
 
    rows..
 
    '</div></div>'
    return out
end
 
return p
--[[Category:Modules]]

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki