请输入您要查询的百科知识:

 

词条 Module:Sports color/table
释义
-- This submodule is used to generate the-- complete color table in Baseball color

local p = {}

local data_module = "Module:Sports color/baseball"

local function stripwhitespace(text)

return text:match("^%s*(.-)%s*$")

end

local function get_colors(team, unknown)

team = stripwhitespace(team or )

unknown = unknown or {"DCDCDC", "000000", "DCDCDC", "000000"}

local use_default = {

[""] = 1,

["retired"] = 1,

["free agent"] = 1,

}

local colors = nil

if ( team and use_default[team:lower()] ) then

colors = {"DCDCDC", "000000", "DCDCDC", "000000"}

else

local all_colors = mw.loadData(data_module)

colors = all_colors[team]

if ( colors and type(colors) == 'string' ) then

colors = all_colors[colors]

end

end

return colors or unknown

end

local function team_testtable(args, style, data)

local teamlist = {}

local aliaslist = {}

if ( data ) then data_module = data end

local function table_row(t, c)

local res = mw.html.create()

if( c[1] and c[2] and c[3] and c[4] ) then

res:tag('td'):wikitext(t)

else

res:tag('td'):wikitext(t .. ' ERROR')

end

for i=1,4 do

res:tag('td'):css('background-color', '#' .. stripwhitespace(c[i] or 'ERROR'))

end

return tostring(res)

end

if( args and args[1] ) then

for k, team in pairs(args) do

if type(k) == 'number' then

table.insert(teamlist, team)

end

end

else

local all_colors = mw.loadData(data_module)

for team, colors in pairs( all_colors ) do

if type(colors) == 'string' then

aliaslist[colors] = (aliaslist[colors] or ) .. '
aka ' .. team

else

table.insert(teamlist, team)

end

end

table.sort(teamlist)

table.insert(teamlist, 'Free agent')

table.insert(teamlist, 'Retired')

end

-- build table

local root = mw.html.create('table')

root:addClass('wikitable sortable')

:css('font-size', '90%')

:css('line-height', '100%')

:cssText(style)

local row = root:tag('tr')

row:tag('th'):wikitext('Team')

for i=1,4 do

row:tag('th')

:addClass('unsortable')

:wikitext(i)

end

for k, team in pairs( teamlist ) do

row = root:tag('tr')

row:wikitext(table_row(team .. (aliaslist[team] or ), get_colors(team)))

end

return tostring(root)

end

function p.testtable(frame)

return team_testtable((frame.args[1] ~= nil) and frame.args or frame:getParent().args, frame.args['style'] or , frame.args['data'])

end

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/20 5:17:18