Tritt unserem Discord bei und informiere dich auf unserem Twitter-Kanal über die aktuellsten Themen rund um Fallout!
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 zu erreichende Seitenanzahl an."
end
local categoryName = mw.title.getCurrentTitle().text -- Name der aktuellen Kategorie
local cat = mw.site.stats.pagesInCategory(categoryName)
local currentSeiten = tonumber(cat) or 0
local prozent = (currentSeiten / maxSeiten) * 100
local prozentFormatted = string.format("%.2f", prozent)
local color = "#0057b7" -- Blau
local bgColor = "#ffd700" -- Gelb
-- Fortschrittsbalken HTML
local progressBar = string.format(
'<div style="border: 1px solid #ccc; width: 100%%; background-color: %s;">' ..
'<div style="width: %.2f%%; background-color: %s; color: #fff; text-align: center;">' ..
'%d / %d (%s%%)</div></div>',
bgColor, prozent, color, currentSeiten, maxSeiten, prozentFormatted
)
return progressBar
end
return p