Last edited 2 months ago
by WikiSysop

IndicatorProcess

No content


local p = {} -- p stands for package

function p.forDate( frame )
    local todayU = frame:callParserFunction( '#time:U' )
    local soonU = frame:callParserFunction( '#time:U', '+2 months' )
    local timeU = frame:callParserFunction( '#time:U', frame.args[1] )
    local color = 'green'
    local shape = '◉'  -- different shapes for accessibility WCAG 1.4.1
    local statusind = 'aktuell'
    if ( timeU < soonU ) then
    	color = '#CC8500'
    	shape = '&#9680;'
    	statusind = 'ablaufend'
    end
    if ( timeU < todayU ) then
    	color = 'red'
    	shape = '&#9678;'
    	statusind = 'abgelaufen'
    end
    return p.getIndicator( frame, color, shape, statusind )
end

function p.getIndicator( frame, color, shape, statusind )
	-- adding the statusind in hidden text makes the indicator sortable in tables
    return "<span class='date-indicator' title='" .. statusind .. "' role='img' style='color: " .. color .. ";font-size:1em;' aria-label='" .. statusind .. "'>" .. shape .. "<span style='display:none'>" .. statusind .. "</span></span>";
end

return p