Tritt unserem Discord bei und informiere dich auf unserem Twitter-Kanal über die aktuellsten Themen rund um Fallout!
Keine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
| (11 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 7: | Zeile 7: | ||
-- Sicherstellen, dass maxSeiten definiert und eine Zahl ist | -- Sicherstellen, dass maxSeiten definiert und eine Zahl ist | ||
if not maxSeiten then | if not maxSeiten then | ||
return "Fehler: Bitte | return "Fehler: Bitte gib eine Ziel-Seitenanzahl an." | ||
end | end | ||
local categoryName = mw.title.getCurrentTitle().text -- Name der aktuellen Kategorie | local categoryName = mw.title.getCurrentTitle().text -- Name der aktuellen Kategorie | ||
local | local cat = mw.site.stats.pagesInCategory(categoryName) | ||
local | local currentSeiten = cat and tonumber(cat) or 0 | ||
local prozent = (currentSeiten / maxSeiten) * 100 | local prozent = (currentSeiten / maxSeiten) * 100 | ||
| Zeile 31: | Zeile 30: | ||
-- Fortschrittsbalken HTML | -- Fortschrittsbalken HTML | ||
local progressBar = string.format( | local progressBar = string.format( | ||
'<div style="width: 100%%; background-color: # | '<div style="width: 100%%; background-color: #2e3f4e; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); margin: 0 auto 12px;">' .. | ||
'<div style="width: %.2f%%; background: linear-gradient(90deg, %s, %s); color: # | '<div style="width: %.2f%%; background: linear-gradient(90deg, %s, %s); color: #fff; white-space: nowrap; text-align: center; padding: 7px 0; border-radius: 10px 0 0 10px; box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.1);">' .. | ||
'%d / %d Seiten (%s%%)</div></div>', | '<span style="padding:0 15px;">%d / %d Seiten <span style="color:#f7da8b">(%s%%)</span></span></div></div>', | ||
prozent, colorStart, colorEnd, currentSeiten, maxSeiten, prozentFormatted | prozent, colorStart, colorEnd, currentSeiten, maxSeiten, prozentFormatted | ||
) | ) | ||
Aktuelle Version vom 12. Dezember 2024, 21:40 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Fortschrittsbalken/Doku erstellt werden
local p = {}
function p.fortschritt(frame)
local args = frame:getParent().args
local maxSeiten = tonumber(args[1])
-- Sicherstellen, dass maxSeiten definiert und eine Zahl ist
if not maxSeiten then
return "Fehler: Bitte gib eine Ziel-Seitenanzahl an."
end
local categoryName = mw.title.getCurrentTitle().text -- Name der aktuellen Kategorie
local cat = mw.site.stats.pagesInCategory(categoryName)
local currentSeiten = cat and tonumber(cat) or 0
local prozent = (currentSeiten / maxSeiten) * 100
if prozent > 100 then prozent = 100 end
local prozentFormatted = string.format("%.2f", prozent)
-- Farben für den Balken
local colorStart, colorEnd
if prozent == 100 then
colorStart = "#3b9d3e" -- Grün (Startfarbe)
colorEnd = "#3b9d3e" -- Grün (Endfarbe)
else
colorStart = "#004775" -- Blau (Startfarbe)
colorEnd = "#0072bd" -- Blau (Endfarbe)
end
-- Fortschrittsbalken HTML
local progressBar = string.format(
'<div style="width: 100%%; background-color: #2e3f4e; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); margin: 0 auto 12px;">' ..
'<div style="width: %.2f%%; background: linear-gradient(90deg, %s, %s); color: #fff; white-space: nowrap; text-align: center; padding: 7px 0; border-radius: 10px 0 0 10px; box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.1);">' ..
'<span style="padding:0 15px;">%d / %d Seiten <span style="color:#f7da8b">(%s%%)</span></span></div></div>',
prozent, colorStart, colorEnd, currentSeiten, maxSeiten, prozentFormatted
)
return progressBar
end
return p