Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (add some lengthy comments explaining what's going on) |
Enwikipedia>Mr. Stradivarius (try tweaking the order) |
||
Line 83: | Line 83: | ||
-- Define often-used functions as local variables. |
-- Define often-used functions as local variables. |
||
local tconcat = table.concat |
local tconcat = table.concat |
||
local tinsert = table.insert |
|||
local tremove = table.remove |
|||
local ceil = math.ceil |
local ceil = math.ceil |
||
local function toTableEnd(t, pos) |
|||
-- Sends the value at position pos to the end of array t, and shifts the |
|||
-- other items down accordingly. |
|||
return tinsert(t, tremove(t, pos)) |
|||
⚫ | |||
local p = {} |
local p = {} |
||
Line 116: | Line 124: | ||
{pos = 5, val = expiry}, |
{pos = 5, val = expiry}, |
||
{pos = 3, val = p.matchNamespace(namespace)}, |
{pos = 3, val = p.matchNamespace(namespace)}, |
||
⚫ | |||
{pos = 2, val = protLevel}, |
{pos = 2, val = protLevel}, |
||
{pos = 1, val = protType} |
{pos = 1, val = protType} |
||
⚫ | |||
} |
} |
||
Line 128: | Line 136: | ||
-- vandalism categories if they were available. |
-- vandalism categories if they were available. |
||
--]] |
--]] |
||
local behavior |
local behavior |
||
if reason then |
if not reason then |
||
⚫ | |||
else |
|||
behavior = behaviors[reason] |
behavior = behaviors[reason] |
||
end |
|||
if behavior == 'namespaceFirst' then |
|||
table.insert(properties, table.remove(properties, 2)) |
|||
toTableEnd(properties, 2) -- move namespace to end |
|||
⚫ | |||
elseif behavior == 'reasonFirst' then |
|||
⚫ | |||
toTableEnd(properties, 3) -- move reason to end |
|||
⚫ | |||
else |
|||
⚫ | |||
end |
end |
||