Modul:Spiel-Info: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 22: | Zeile 22: | ||
local function addMatchRow(box, label, date, stadium, result) | local function addMatchRow(box, label, date, stadium, attendance, result) | ||
if date ~= "" or stadium ~= "" or result ~= "" then | if date ~= "" or stadium ~= "" or result ~= "" then | ||
| Zeile 60: | Zeile 60: | ||
:done() | :done() | ||
end | end | ||
if attendance ~= "" then | |||
box | |||
:tag("tr") | |||
:tag("th") | |||
:wikitext("Besucheranzahl") | |||
:done() | |||
:tag("td") | |||
:wikitext(attendance) | |||
:done() | |||
:done() | |||
end | |||
if result ~= "" then | if result ~= "" then | ||
box | box | ||
| Zeile 81: | Zeile 91: | ||
-- Liste der normalen Felder | -- Liste der normalen Felder | ||
local fields = { | local fields = { | ||
{"coach", "Trainer"}, | {"coach", "Trainer"}, | ||
{"opponent", "Gegner"} | |||
} | } | ||
| Zeile 100: | Zeile 110: | ||
local date_first_leg = args.date_first_leg or "" | local date_first_leg = args.date_first_leg or "" | ||
local stadium_first_leg = args.stadium_first_leg or "" | local stadium_first_leg = args.stadium_first_leg or "" | ||
local result_first_leg = args.result_first_leg or "" | local attendance_first_leg = args.attendance_first_leg or "" | ||
local result_first_leg= args.result_first_leg or "" | |||
local date_second_leg = args.date_second_leg or "" | local date_second_leg = args.date_second_leg or "" | ||
local stadium_second_leg = args.stadium_second_leg or "" | local stadium_second_leg = args.stadium_second_leg or "" | ||
local attendance_second_leg = args.result_first_leg or "" | |||
local result_second_leg = args.result_second_leg or "" | local result_second_leg = args.result_second_leg or "" | ||
| Zeile 111: | Zeile 123: | ||
date_second_leg ~= "" or | date_second_leg ~= "" or | ||
stadium_second_leg ~= "" or | stadium_second_leg ~= "" or | ||
attendance_second_leg ~= "" or | |||
result_second_leg ~= "" | result_second_leg ~= "" | ||
| Zeile 141: | Zeile 154: | ||
-- Spiele | -- Spiele | ||
if has_second_leg then | if has_second_leg then | ||
addRow(box, "Endergebnis", args.result or "") | |||
addMatchRow( | addMatchRow( | ||
| Zeile 147: | Zeile 161: | ||
date_first_leg, | date_first_leg, | ||
stadium_first_leg, | stadium_first_leg, | ||
attendance_first_leg, | |||
result_first_leg | result_first_leg | ||
) | ) | ||
| Zeile 155: | Zeile 170: | ||
date_second_leg, | date_second_leg, | ||
stadium_second_leg, | stadium_second_leg, | ||
attendance_second_leg, | |||
result_second_leg | result_second_leg | ||
) | ) | ||
else | else | ||
| Zeile 165: | Zeile 180: | ||
date_first_leg, | date_first_leg, | ||
stadium_first_leg, | stadium_first_leg, | ||
attendance_first_leg, | |||
result_first_leg | result_first_leg | ||
) | ) | ||
Aktuelle Version vom 3. September 2026, 18:22 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Spiel-Info/Doku erstellt werden
local p = {}
-- Erstellt eine normale Zeile der Infobox
local function addRow(box, label, value)
if value and value ~= "" then
box
:tag("tr")
:tag("th")
:wikitext(label)
:done()
:tag("td")
:wikitext(value)
:done()
:done()
end
end
local function addMatchRow(box, label, date, stadium, attendance, result)
if date ~= "" or stadium ~= "" or result ~= "" then
box
:tag("tr")
:tag("th")
:attr("colspan", "4")
:css("text-align", "center")
:css("font-weight", "bold")
:wikitext(label)
:done()
:done()
if date ~= "" then
box
:tag("tr")
:tag("th")
:wikitext("Datum")
:done()
:tag("td")
:wikitext(date)
:done()
:done()
end
if stadium ~= "" then
box
:tag("tr")
:tag("th")
:wikitext("Stadion")
:done()
:tag("td")
:wikitext(stadium)
:done()
:done()
end
if attendance ~= "" then
box
:tag("tr")
:tag("th")
:wikitext("Besucheranzahl")
:done()
:tag("td")
:wikitext(attendance)
:done()
:done()
end
if result ~= "" then
box
:tag("tr")
:tag("th")
:wikitext("Ergebnis")
:done()
:tag("td")
:wikitext(result)
:done()
:done()
end
end
end
-- Liste der normalen Felder
local fields = {
{"coach", "Trainer"},
{"opponent", "Gegner"}
}
-- Hauptfunktion
function p.main(frame)
-- Parameter der Vorlage holen
local args = frame:getParent().args
-- Grundparameter
local titel = args.titel or ""
-- Werte für Hin- und Rückspiel
local date_first_leg = args.date_first_leg or ""
local stadium_first_leg = args.stadium_first_leg or ""
local attendance_first_leg = args.attendance_first_leg or ""
local result_first_leg= args.result_first_leg or ""
local date_second_leg = args.date_second_leg or ""
local stadium_second_leg = args.stadium_second_leg or ""
local attendance_second_leg = args.result_first_leg or ""
local result_second_leg = args.result_second_leg or ""
-- Prüfen, ob ein Rückspiel vorhanden ist
local has_second_leg =
date_second_leg ~= "" or
stadium_second_leg ~= "" or
attendance_second_leg ~= "" or
result_second_leg ~= ""
-- Tabelle erstellen
local box = mw.html.create("table")
:addClass("infobox")
-- Titel
if titel ~= "" then
box
:tag("caption")
:wikitext(titel)
:done()
end
for _, field in ipairs(fields) do
local parameter = field[1]
local label = field[2]
local value = args[parameter]
addRow(box, label, value)
end
-- Spiele
if has_second_leg then
addRow(box, "Endergebnis", args.result or "")
addMatchRow(
box,
"Hinspiel",
date_first_leg,
stadium_first_leg,
attendance_first_leg,
result_first_leg
)
addMatchRow(
box,
"Rückspiel",
date_second_leg,
stadium_second_leg,
attendance_second_leg,
result_second_leg
)
else
addMatchRow(
box,
"Spiel",
date_first_leg,
stadium_first_leg,
attendance_first_leg,
result_first_leg
)
end
-- HTML zurückgeben
return tostring(box)
end
return p