Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 

















Module:Team roster navbox






العربية
تۆرکجه

فارسی
Galego
Bahasa Indonesia


Português
Scots
Simple English
Slovenščina
Српски / srpski
Tagalog
Українська
اردو
Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


This module is used to implement {{Team roster navbox}}, a helper template used to implement the individual team roster navboxes for the Major League Baseball teams.

At present, it parses any list<number> arguments to the template and replaces spaces in each list item with &nbsp; in order to prevent wrapping. It then calls Module:Navbox._navbox() to create the navbox. (Note the preprocessing done by Module::Navbox.navbox() has not been copied to this module and so is skipped.)

-- This module implements {{team roster navbox}}
local me = { }

local Navbox = require('Module:Navbox')

local getArgs -- lazily initialized

local function colorlinks(v, s)
 if v and v ~= '' and s and s ~= '' then
  if not mw.ustring.match(v, '<span style') then
   v = mw.ustring.gsub(v, '%[%[([^%[%]|]*)%]%]', 
    '[[%1|<span style="' .. s .. '>%1</span>]]')
   v = mw.ustring.gsub(v, '%[%[([^%[%]|]*)|([^%[%]|]*)%]%]', 
    '[[%1|<span style="' .. s .. '>%2</span>]]')
  end
 end
 return v
end

local function extractstyle(v)
 local r = ''
 local slist = mw.text.split(mw.ustring.gsub(mw.ustring.gsub(v or '', '&#[Xx]23;', '#'), '&#35;', '#'), ';')
 for k = 1,#slist do
  local s = slist[k]
  if s:match('^[%s]*background') or s:match('^[%s]*color') then
   r = r .. s .. ';'
  end
 end
 return r
end 

function me.generateRosterNavbox(frame)
 if not getArgs then
  getArgs = require('Module:Arguments').getArgs
 end
    local args = { }
    local parentArgs = getArgs(frame)
    
    -- Default is to nowrap items
    args['nowrapitems'] = 'yes'

    -- Massage the styles for coloring the links
    local basestyle  = extractstyle(parentArgs['basestyle'] or '')
    local titlestyle = extractstyle(parentArgs['titlestyle'] or '')
    local abovestyle = extractstyle(parentArgs['abovestyle'] or '')
    local groupstyle = extractstyle(parentArgs['groupstyle'] or '')
    local belowstyle = extractstyle(parentArgs['belowstyle'] or '')
    
    if basestyle ~= '' then
     titlestyle = basestyle .. ';' .. titlestyle
     abovestyle = basestyle .. ';' .. abovestyle
     groupstyle = basestyle .. ';' .. groupstyle
     belowstyle = basestyle .. ';' .. belowstyle
    end
    
    -- Color links before passing them to the Navbox helper function
    for argName, value in pairs(parentArgs) do
        if value ~= '' then
            if type(argName) == 'string' then
                if argName == 'title' then
                    value = colorlinks(value, titlestyle)
                elseif argName == 'above' then
                    value = colorlinks(value, abovestyle)
                elseif mw.ustring.find(argName, '^group[0-9][0-9]*$') then
                 if parentArgs[argName .. 'style'] then
                     value = colorlinks(value, extractstyle(groupstyle .. ';' .. parentArgs[argName .. 'style']))
                 else
                  value = colorlinks(value, groupstyle)
                 end
                elseif argName == 'below' then
                    value = colorlinks(value, belowstyle)
                end
                args[argName] = value
            end
        end
    end
    -- Note Navbox.navbox() has a kludge to order the parent frame's args
    -- into a specific order. For now, this is omitted from this module.

    return Navbox._navbox(args)

end  -- function me.generateRosterNavbox

return me

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Team_roster_navbox&oldid=979746508"

Category: 
Modules subject to page protection
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 22 September 2020, at 15:16 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki