Module:Military navigation

local p = { }

local Navbox = require('Module:Navbox')
local Styles = require('Module:WPMILHIST Infobox style')

local function isblank(s)
	return (not s) or s == ''
end
local function ifnotblank(s,p,t)
	return (s and s ~= '') and (p..s) or t
end

function p.main(frame)
    local args = { }
    local pargs = frame:getParent().args
	local fargs = frame.args
    local sargs = {}
    local tcats = ''

	-- process bodystyle and titlestyle
	local style = fargs['style'] or pargs['style'] or ''
	if style == 'wide' then
		args['titlestyle'] = Styles['nav_box_wide_header']
		args['bodystyle'] = Styles['nav_box_wide']
	else
		args['titlestyle'] = Styles['nav_box_header']
		local border = fargs['border'] or pargs['border'] or ''
		if border == 'child' or border == 'subgroup' then
			args['bodystyle'] = Styles['nav_box_child']
			tcats = tcats .. '[[Category:Pages using military navigation subgroups without wide style]]'
		else
			args['bodystyle'] = Styles['nav_box']
		end
	end
	sargs['titlestyle'] = 1
	sargs['bodystyle'] = 1

	-- process groupstyle, abovestyle, belowstyle
	args['groupstyle'] = Styles['nav_box_label'] .. (fargs['groupstyle'] or pargs['groupstyle'] or '')
	sargs['groupstyle'] = 1
	args['abovestyle'] = Styles['nav_box_label'] .. (fargs['abovestyle'] or pargs['abovestyle'] or '')
	sargs['abovestyle'] = 1
	args['belowstyle'] = Styles['nav_box_label'] .. (fargs['belowstyle'] or pargs['belowstyle'] or '')
	sargs['belowstyle'] = 1
	-- process oddstyle, evenstyle
	args['oddstyle'] = ifnotblank((fargs['odd_color'] or pargs['odd_color']),'background:',nil)
	args['evenstyle'] = ifnotblank((fargs['even_color'] or pargs['even_color']),'background:',nil)
	sargs['oddstyle'] = 1
	sargs['evenstyle'] = 1
	-- process name and rawname
	args['name'] = ifnotblank((fargs['name'] or pargs['name']),'',(fargs['rawname'] or pargs['rawname']))
	if isblank(args['name']) then args['navbar'] = 'plain' end
	sargs['name'] = 1
	sargs['rawname'] = 1
	
    -- copy the remaining args, with frame args overriding parent args
    for k, v in pairs(pargs) do
        if v and v ~= '' and sargs[k] == nil then
            args[k] = v
        end
    end
    for k, v in pairs(fargs) do
        if v and v ~= '' and sargs[k] == nil then
            args[k] = v
        end
    end
	-- add allow wrap
	if args['title'] and style ~= 'wide' then
		if not mw.ustring.match(args['title'], '<span class="wrap">') then
			-- probably a more efficient way to match 15 or more characters
			local m = '[^%[%]<>|][^%[%]<>|][^%[%]<>|][^%[%]<>|][^%[%]<>|]'
			m = m .. m .. m
			args['title'] = mw.ustring.gsub(args['title'], 
				'%[%[(' .. m .. '[^%[%]<>|]*)%]%]', 
				'[[%1|<span class="wrap">%1</span>]]')
			args['title'] = mw.ustring.gsub(args['title'], 
				'%[%[([^%[%]<>|]*)|(' .. m .. '[^%[%]<>|]*)%]%]', 
				'[[%1|<span class="wrap">%2</span>]]')
		end
	end
	
	-- add navbox-vertical for non-wide format
	if style ~= 'wide' then
		args['bodyclass'] = 'navbox-vertical' .. (args['bodyclass'] and (' ' .. args['bodyclass']) or '')
	end

	--fallback to "battles" for "list1" for compatibility with [[Template:Campaignbox]]
	if isblank(args['list1']) and not isblank(args.battles) then
		args['list1'] = args.battles
	end
	
    return tcats .. Navbox._navbox(args)

end  

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.