„Modul:Handballteam“ – Versionsunterschied
Erscheinungsbild
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
Malo95 (Diskussion | Beiträge) Modul erstellt |
Malo95 (Diskussion | Beiträge) 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 |
local function team_datas(team, data) |
||
⚫ | |||
return text:match("^%s*(.-)%s*$") |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
team = stripwhitespace(team or '') |
|||
local datas2 = all_datas[datas] |
|||
unknown = unknown or {"DCDCDC", "000000", "000000", "FFFFFF"} |
|||
⚫ | |||
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 |
|||
⚫ | |||
colors = all_colors[team] |
|||
⚫ | |||
colors = all_colors[colors] |
|||
end |
|||
end |
end |
||
return colors or unknown |
|||
end |
end |
||
local function |
local function team_check(team, unknown) |
||
local |
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') |
|||
⚫ | |||
if ( num ) then |
|||
⚫ | |||
else |
else |
||
return '' |
return 'unknown' |
||
end |
end |
||
end |
end |
||
⚫ | |||
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 |
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 |
||
function p.logo(frame) |
|||
local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args |
|||
⚫ | |||
return team_datas(args[1] or '', 2) |
|||
⚫ | |||
⚫ | |||
else |
|||
⚫ | |||
end |
|||
end |
end |
||
function p. |
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 |
return team_datas(args[1] or '', 3) |
||
end |
end |
||
function p. |
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 |
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 |
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 '') |
|||
⚫ | |||
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