×
Einen neuen Artikel erstellen
Schreibe den Seitennamen hierhin:
Wir haben derzeit 9.055 Artikel auf Vaultpedia. Gib deinen Artikelnamen oberhalb von oder klicke auf einen der unten stehenden Titel und beginne zu schreiben! ein



    Vaultpedia
    9.055Artikel

    Modul:Fortschrittsbalken: Unterschied zwischen den Versionen

    Tritt unserem Discord bei und informiere dich auf unserem Twitter-Kanal über die aktuellsten Themen rund um Fallout!
    Huu.Psii (Diskussion | Beiträge)
    Test
     
    Huu.Psii (Diskussion | Beiträge)
    KKeine Bearbeitungszusammenfassung
     
    (16 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 gib eine zu erreichende Seitenanzahl an."
             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 cat = mw.site.stats.pagesInCategory(categoryName)
         local cat = mw.site.stats.pagesInCategory(categoryName)
         local currentSeiten = tonumber(cat) or 0
         local currentSeiten = cat and tonumber(cat) or 0
          
          
         local prozent = (currentSeiten / maxSeiten) * 100
         local prozent = (currentSeiten / maxSeiten) * 100
        if prozent > 100 then prozent = 100 end
         local prozentFormatted = string.format("%.2f", prozent)
         local prozentFormatted = string.format("%.2f", prozent)
         local color = "#0057b7"  -- Blau
     
        local bgColor = "#ffd700" -- Gelb
        -- 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
         -- Fortschrittsbalken HTML
         local progressBar = string.format(
         local progressBar = string.format(
             '<div style="border: 1px solid #ccc; width: 100%%; background-color: %s;">' ..
             '<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-color: %s; color: #fff; text-align: center;">' ..
             '<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 (%s%%)</div></div>',
             '<span style="padding:0 15px;">%d / %d Seiten <span style="color:#f7da8b">(%s%%)</span></span></div></div>',
             bgColor, prozent, color, 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