Zum Inhalt springen

„Modul:Handballteam“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
[gesichtete Version][gesichtete Version]
Inhalt gelöscht Inhalt hinzugefügt
Modul erstellt
 
Keine Bearbeitungszusammenfassung
 
(7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 5: Zeile 5:
local data_module = "Module:Handballteam/data"
local data_module = "Module:Handballteam/data"


local function stripwhitespace(text)
local function team_datas(team, data)
local all_datas = mw.loadData(data_module)
return text:match("^%s*(.-)%s*$")
local datas = all_datas[team]
end
if type(datas) == 'table' then

return datas [data]
local function get_datas(team, unknown)
elseif type(datas) == 'string' then
team = stripwhitespace(team or '')
local datas2 = all_datas[datas]
unknown = unknown or {"DCDCDC", "000000", "000000", "FFFFFF"}
return datas2 [data]
local use_default = {
[""] = 1,
["retired"] = 1,
["free agent"] = 1,
}
local colors = nil
if ( team and use_default[team:lower()] ) then
colors = {"DCDCDC", "000000", "DCDCDC", "FFFFFF"}
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
end

return colors or unknown
end
end


local function team_color(team, num)
local function team_check(team, unknown)
local colors = get_colors(team, nil)
local all_datas = mw.loadData(data_module)
local datas = all_datas[team]

if type(datas) == 'table' or type(datas) == 'string' then
num = tonumber(num:match('[1-4]') or '0')
return 'known'
if ( num ) then
return colors[num]
else
else
return ''
return 'unknown'
end
end
end
end


local function team_type(team, unknown)

local function team_link(team)
local all_datas = mw.loadData(data_module)
local all_datas = mw.loadData(data_module)
local datas = all_datas[team]
local datas = all_datas[team]
return datas [0]
return type(datas)
end
end


function p.link(frame)
local function team_colorcell(team, borderwidth, bg, fg, bd)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
local colors = get_colors(team, nil)
return team_datas(args[1] or '', 1)
local border = ''
borderwidth = borderwidth or ''
if (borderwidth ~= '') then
border = 'border:' .. borderwidth .. 'px solid #' .. stripwhitespace(colors[bd]) .. ';'
end
return 'background-color:#' .. stripwhitespace(colors[bg]) .. ';color:#' .. stripwhitespace(colors[fg]) .. ';' .. border
end
end


local function team_check(team, unknown)
function p.logo(frame)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
local datas = get_datas(team, unknown)
return team_datas(args[1] or '', 2)
if type(datas) == 'table' then
return 'known'
else
return unknown
end
end
end


function p.link(frame)
function p.lat(frame)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
return team_link(args[1] or '', args[2] or '')
return team_datas(args[1] or '', 3)
end
end


function p.logo(frame)
function p.long(frame)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
return team_colorcell(args[1] or '', args['border'] or '', 1, 2, 3)
return team_datas(args[1] or '', 4)
end
end



function p.check(frame)
function p.check(frame)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
return team_check(args[1] or '', args[2] or '')
return team_check(args[1] or '')
end
end

function p.type(frame)
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
return team_type(args[1] or '')
end



return p
return p

Aktuelle Version vom 14. April 2017, 16:32 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Handballteam/Doku erstellt werden

--
--
local p = {}

local data_module = "Module:Handballteam/data"

local function team_datas(team, data)
	local all_datas = mw.loadData(data_module)
	local datas = all_datas[team]
	if type(datas) == 'table' then
		return datas [data]
	elseif type(datas) == 'string' then
		local datas2 = all_datas[datas]
		return datas2 [data]
	end
end

local function team_check(team, unknown)
	local all_datas = mw.loadData(data_module)
	local datas = all_datas[team]
	if type(datas) == 'table' or type(datas) == 'string' then
		return 'known'
	else
		return 'unknown'
	end
end

local function team_type(team, unknown)
	local all_datas = mw.loadData(data_module)
	local datas = all_datas[team]
	return type(datas)
end

function p.link(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_datas(args[1] or '', 1)
end

function p.logo(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_datas(args[1] or '', 2)
end

function p.lat(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_datas(args[1] or '', 3)
end

function p.long(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_datas(args[1] or '', 4)
end

function p.check(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_check(args[1] or '')
end

function p.type(frame)
	local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
	return team_type(args[1] or '')
end


return p