×
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)
    Keine Bearbeitungszusammenfassung
    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 geben Sie die maximale Seitenanzahl an."
         end
         end


    Zeile 15: Zeile 15:
          
          
         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 = "#4caf50"  -- Grün (Startfarbe)
            colorEnd = "#81c784"    -- Hellgrün (Endfarbe)
        else
            colorStart = "#e0eafc"  -- Helles Blau (Startfarbe)
            colorEnd = "#cfdef3"    -- Sehr helles Blau (Endfarbe)
        end
     
         local bgColor = "#d4e4f7" -- Sanftes Blau
     
         -- 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="border: 1px solid #ccc; width: 100%%; background-color: %s; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);">' ..
             '<div style="width: %.2f%%; background-color: %s; color: #fff; text-align: center;">' ..
             '<div style="width: %.2f%%; background: linear-gradient(90deg, %s, %s); color: #000; text-align: center; padding: 5px 0; border-radius: 10px 0 0 10px; box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.1);">' ..
             '%d / %d (%s%%)</div></div>',
             '%d / %d (%s%%)</div></div>',
             bgColor, prozent, color, currentSeiten, maxSeiten, prozentFormatted
             bgColor, prozent, colorStart, colorEnd, currentSeiten, maxSeiten, prozentFormatted
         )
         )
          
          

    Version vom 10. Juli 2024, 15: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 geben Sie die maximale 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
        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 = "#4caf50"  -- Grün (Startfarbe)
            colorEnd = "#81c784"    -- Hellgrün (Endfarbe)
        else
            colorStart = "#e0eafc"  -- Helles Blau (Startfarbe)
            colorEnd = "#cfdef3"    -- Sehr helles Blau (Endfarbe)
        end
    
        local bgColor = "#d4e4f7"  -- Sanftes Blau
    
        -- Fortschrittsbalken HTML
        local progressBar = string.format(
            '<div style="border: 1px solid #ccc; width: 100%%; background-color: %s; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);">' ..
            '<div style="width: %.2f%%; background: linear-gradient(90deg, %s, %s); color: #000; text-align: center; padding: 5px 0; border-radius: 10px 0 0 10px; box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.1);">' ..
            '%d / %d (%s%%)</div></div>',
            bgColor, prozent, colorStart, colorEnd, currentSeiten, maxSeiten, prozentFormatted
        )
        
        return progressBar
    end
    
    return p