Anonymous user
Module:Protection banner: Difference between revisions
make the category attempt order more configurable
(more data table restructuring, plus some fiddling around with the category name function; this is a progress save, so the code is horribly broken at the moment) |
(make the category attempt order more configurable) |
||
Line 196:
--[[
-- Define the initial order to test properties in. The subtable position
-- is the order the properties will be tested in, and the
-- each subtable is the position of the value in the category key.
--]]
local properties = {
expiry = {
namespace = {
reason = {
level = {
action = {
}
Line 214:
-- vandalism categories if they were available.
--]]
local categoryOrder▼
local categoryOrder = reasonTable and reasonTable.categoryOrder
if not reason then▼
local categoryOrderType = type(categoryOrder)
local configOrder = {}
if categoryOrderType == 'table' then
for i = 1, 5 do
if not propertiesKey then
error('no properties key')
local property = properties[propertiesKey]
error('invalid properties key')
end
if dupes[property] then
error('dupe detected')
dupes[property] = true
end
configOrder[i] = property
end
else
for propertiesKey, t in pairs(properties) do
▲ categoryOrder = cfg.reasons[reason].categoryOrder
configOrder[t.order] = t
▲ end
end
if categoryOrderType == 'string' then
local property = properties[categoryOrder]
if not property then
error('invalid category order string')
▲ else
end
toTableEnd(configOrder, property.order)
end
end
Line 237 ⟶ 258:
--]]
local active, inactive = {}, {}
for i, t in ipairs(
if t.val then
active[#active + 1] = t
Line 285 ⟶ 306:
local key = {}
for j, t in ipairs(attemptOrder) do
▲ local pos = t.pos
if j > noActive then
key[
else
local quotient = i / 2 ^ (j - 1)
quotient = ceil(quotient)
if quotient % 2 == 1 then
key[
else
key[
end
end
|