Module:Alert list
Appearance
This module provides functionality to Template:Alert list.
Usage
To use this module, add the following code to your wiki page:
{{#invoke:Alert_list|main}}
Inputs
See Template:Alert list#Usage.
Outputs
This module outputs a single string containing the HTML markup for the generated alert list. Each alert will include:
- The icon (either the custom icon or the one associated with the specified type)
- The label (either the custom label or the one associated with the specified type)
- The optional message, action, and timestamp (if provided)
local p = {}
local function renderNotification(args, index)
local icon = args['icon' .. index]
local label = args['label' .. index]
local msg = args['msg' .. index]
local action = args['action' .. index]
local time = args['time' .. index]
if not icon or not label then
return ''
end
local notification = {
'* [[File:' .. icon .. "|25px|link=]] <span class='notification-list-label'>" .. label .. "</span>",
}
if msg and msg ~= '' then
table.insert(notification, '*: ' .. msg)
end
if action and action ~= '' then
table.insert(notification, '*: ' .. action)
end
if time and time ~= '' then
table.insert(notification, '*: <small>' .. time .. '</small>')
end
return table.concat(notification, '\n')
end
function p.main(frame)
local args = frame:getParent().args
local output = {}
for i = 1, math.huge do
local notification = renderNotification(args, i)
if notification == '' then
break
end
table.insert(output, notification)
end
-- Wrap the output in a div with class "notification-list"
return '<div class="notification-list">\n' .. table.concat(output, '\n') .. '\n</div>'
end
return p