Editing
Module:Team roster navbox
From Thetacola Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- 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;', '#'), '#', '#'), ';') 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
Summary:
Please note that all contributions to Thetacola Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Template link expanded
(
edit
)
Template:Tlx
(
edit
)
Module:Arguments
(
edit
)
Module:Effective protection level
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:Message box/ombox.css
(
edit
)
Module:Team roster navbox/doc
(
edit
)
Module:Template link general
(
edit
)
Module:Yesno
(
edit
)
Navigation menu
Page actions
Module
Discussion
Read
Edit source
History
Page actions
Module
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information