Module:DropsLineTest: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
function p.determineCellStyle(r, n)
function p.determineCellStyle(r, n)
     r = tonumber(r) or 0  -- Convert r to a number or default to 0 if nil
     r = tonumber(r) or 0  -- Convert r to a number or default to 0 if nil
    mw.log("r: " .. r) -- Output the value of r to the debug log
     local color
     local color
     if n == 1 then
     if n == 1 then
Line 27: Line 28:
         color = "#afeeee"
         color = "#afeeee"
     end
     end
    mw.log("Color: " .. color) -- Output the chosen color to the debug log
     return string.format('style="background-color: %s;"', color)
     return string.format('style="background-color: %s;"', color)
end
end


return p
return p

Revision as of 16:35, 5 May 2024

Documentation for this module may be created at Module:DropsLineTest/doc

local p = {}

function p.determineColor(r)
    if tonumber(r) <= 1 then
        return "#afeeee"
    elseif tonumber(r) <= 25 then
        return "#56e156"
    elseif tonumber(r) <= 100 then
        return "#ffed4c"
    elseif tonumber(r) <= 1000 then
        return "#ff863c"
    elseif tonumber(r) <= 9999999 then
        return "#ff6262"
    else
        return "#ffffff"
    end
end

function p.determineCellStyle(r, n)
    r = tonumber(r) or 0  -- Convert r to a number or default to 0 if nil
    mw.log("r: " .. r) -- Output the value of r to the debug log
    local color
    if n == 1 then
        color = p.determineColor(r)
    elseif tonumber(r) <= 30 then
        color = "#56e156"
    else
        color = "#afeeee"
    end
    mw.log("Color: " .. color) -- Output the chosen color to the debug log
    return string.format('style="background-color: %s;"', color)
end


return p