Anonymous user
Module:Protection banner: Difference between revisions
simplify Protection:makeProtectionCategory and update the comments
(rm unnecessary do/end blocks) |
(simplify Protection:makeProtectionCategory and update the comments) |
||
Line 150:
end
-- Get the expiry key fragment.
local
if
expiryFragment = self.expiry
expiry = 'temp'▼
elseif type(self.expiry)
end
-- Get the namespace
local
do
▲ if not nskey and namespace % 2 == 1 then
▲ nskey = 'talk'
end
end
-- Define the order that key fragments are tested in. This is done with an
-- array of tables containing the value to be tested, along with its
-- position in the cfg.protectionCategories table.
{val = expiryFragment, keypos = 1},
{val = namespaceFragment, keypos = 2},
▲ local properties = {
}
-- To generate the correct category for some reason values, we need to
-- prioritise the position of the namespace key fragment over that of the
-- reason key fragment. For these reasn values, swap the namespace subtable
-- and the reason subtable around.
table.insert(order, 3, table.remove(order, 2))
▲ local namespaceFirst = reason and reasonsWithNamespacePriority[reason] or false
end
--[[
-- Define the attempt order.
-- fields) are moved to the end, where they will later be given the
-- "all". This is to cut down on the number of table lookups in
-- cfg.protectionCategories, which grows exponentially with the number of
-- non-nil keys. We keep track of the number of active
-- noActive parameter.
--]]
local noActive, attemptOrder
do
local active, inactive = {}, {}
for i, t in ipairs(
if t.val then
active[#active + 1] = t
Line 235 ⟶ 212:
--[[
-- Check increasingly generic key combinations until we find a match. If a
--
--
--
-- "all-all-all-all-all".
--
-- To generate the keys, we index the
--
--
--
-- 1 corresponding to
--
-- j 1 2 3
Line 259 ⟶ 235:
-- 8 0 0 0
--
-- Values of j higher than the number of active
-- to the string "all".
--
-- A key for
-- The
-- each subtable.
--]]
local cats = cfg.protectionCategories
Line 271 ⟶ 247:
for j, t in ipairs(attemptOrder) do
if j > noActive then
key[t.
else
local quotient = i / 2 ^ (j - 1)
quotient = math.ceil(quotient)
if quotient % 2 == 1 then
key[t.
else
key[t.
end
end
|