Site notice
Welcome! Please check To-Do List to see what pages need help, who is working on what, etc.

Module:Header

From Mega Man Wiki

Documentation for this module may be created at Module:Header/doc

local p = {} --p stands for package

function p.header(frame)
	-- A passthrough that gets args from the frame and all
	mArguments = require('Module:Arguments')
	args = mArguments.getArgs(frame)
	return p._header(args)
end

function p._header(args, options) 
    if args["show_title"] ~= nil and args["show_title"] == "yes"  then  
		title_text = args["title"] .. "-related pages"  
	else 
		title_text = "" 
	end	
	
	if mw.site.namespaces ~= 0 and args["title"] ~= nil  then 
		article_text = "[[" .. args["title"] .. "|Article]]" 
	else 
		article_text = "Article" 
	end

	if mw.site.namespaces ~= 14 and args["title"] ~= nil then 
		category_text = "[[:Category:" .. args["title"] .. "|Category]]" 
	else 
		category_text = "Category" 
	end
	
	if mw.site.namespaces ~= 100 and args["title"] ~= nil then 
		gallery_text = "[[Gallery:" .. args["title"] .. "|Gallery]]" 
	else 
		gallery_text = "Gallery" 
	end
	
    if mw.site.namespaces ~= 102 and args["title"] ~= nil  then 
		quote_text = "[[Quotes:" .. args["title"] .. "|Quotes]]" 
	else 
		quote_text = "Quotes" 
	end
	
    if mw.site.namespaces ~= 104 and args["title"] ~= nil  then 
		walkthrough_text = "[[Walkthrough:" .. args["title"] .. "|Walkthrough]]" 
	else 
		walkthrough_text = "Walkthrough" 
	end
	
    if mw.site.namespaces ~= 106 and args["title"] ~= nil  then 
		damage_data_text = "[[Damage Data Chart:" .. args["title"] .. "|Damage data]]" 
	else 
		damage_data_text = "Damage data" 
	end
	
    if mw.site.namespaces ~= 108 and args["title"] ~= nil  then 
		script_text = "[[Script:" .. args["title"] .. "|Script]]" 
	else 
		script_text = "Script" 
    end

	local title_cell = ""
	local article_cell 
	local gallery_cell
	local walkthrough_cell
	local damage_data_cell
	local quote_cell
	local script_cell
	local category_cell
	local t
	
    if args["links-only"] ~= nil and args["links-only"] == "yes" then
		title_cell = mw.html.create( 'span' )
			:wikitext( title_text )
	    
		article_cell = mw.html.create( 'span' )
	     :wikitext( article_text )
	     
	     gallery_cell = mw.html.create( 'span' )
	     :wikitext( gallery_text )
	     
	    walkthrough_cell = mw.html.create( 'span' )
	     :wikitext( walkthrough_text )
	     
	    damage_data_cell = mw.html.create( 'span' )
	     :wikitext( damage_data_text )
	     
	    quote_cell = mw.html.create( 'span' )
	     :wikitext( quote_text )
	     
	    script_cell = mw.html.create( 'span' )
	     :wikitext( script_text )
	     
	     category_cell = mw.html.create( 'span' )
	     :wikitext( category_text )
		
		if args["subtype"] ~= nil and args["subtype"] == "game" then
	        t = mw.html.create( 'span' )
	        	:wikitext(tostring(title_cell) .. " • " 
	          	.. tostring(article_cell) .. " • "
	          	.. tostring(gallery_cell) .. " • "
	            .. tostring(walkthrough_cell) .. " • "
	          	.. tostring(damage_data_cell) .. " • "
	          	.. tostring(script_cell) .. " • "
	          	.. tostring(category_cell) 
	          	) 
		elseif args["subtype"] ~= nil and args["subtype"] == "other" then
	        t = mw.html.create( 'span' )
	        	:wikitext(tostring(title_cell) .. " • " 
	          	.. tostring(article_cell) .. " • "
	          	.. tostring(gallery_cell) .. " • "
	          	.. tostring(script_cell) .. " • "
	          	.. tostring(quote_cell) .. " • "
	          	.. tostring(category_cell) 
	          	)
    	else 
	        t = mw.html.create( 'span' )
	        	:wikitext(tostring(title_cell) .. " • " 
          	.. tostring(article_cell)  .. " • "
          	.. tostring(gallery_cell) .. " • "
            .. tostring(walkthrough_cell) .. " • "
          	.. tostring(quote_cell) 
          	)
		end
	else 
		if args["show_title"] ~= nil and args["show_title"] == "yes"  then 
			title_cell = mw.html.create( 'div' )
	    	:wikitext( title_text )
		end
    
		article_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( article_text )
	     
	     gallery_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( gallery_text )
	     
	    walkthrough_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( walkthrough_text )
	     
	    damage_data_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( damage_data_text )
	     
	    quote_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( quote_text )
	     
	    script_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( script_text )
	     
	     category_cell = mw.html.create( 'div' )
	     :addClass('button')
	     :wikitext( category_text )
     
     if args["subtype"] ~= nil and args["subtype"] == "game" then
        t = mw.html.create( 'div' )
          t:css( 'width', '100%' )
          t:css( 'margin-bottom', '0px;')
          t:css( 'margin-top', '0px;')
          t:css( 'text-align', 'center;')
          :wikitext( tostring(title_cell) 
          	.. tostring(article_cell) 
          	.. tostring(gallery_cell) 
            .. tostring(walkthrough_cell) 
          	.. tostring(damage_data_cell) 
          	.. tostring(script_cell) 
          	.. tostring(category_cell) 
          	)  
	elseif args["subtype"] ~= nil and args["subtype"] == "other" then
        t = mw.html.create( 'div' )
          t:css( 'width', '100%' )
          t:css( 'margin-bottom', '0px;')
          t:css( 'margin-top', '0px;')
          t:css( 'text-align', 'center;')
        	:wikitext(tostring(title_cell)
          	.. tostring(article_cell)
          	.. tostring(gallery_cell)
          	.. tostring(script_cell)
          	.. tostring(quote_cell)
          	.. tostring(category_cell) 
          	)
     else 
      t = mw.html.create( 'div' )
          t:css( 'width', '100%' )
          t:css( 'margin-bottom', '0px;')
          t:css( 'margin-top', '0px;')
          t:css( 'text-align', 'center;')
          :wikitext( tostring(title_cell) 
          	.. tostring(article_cell) 
          	.. tostring(gallery_cell) 
            .. tostring(walkthrough_cell) 
          	.. tostring(quote_cell) 
          )
     end
         end
return tostring( t )
end	

return p