Модуль:ClosedNav

Версія від 08:41, 14 січня 2026, створена Admin (обговорення | внесок)
(різн.) ← Попередня версія | Поточна версія (різн.) | Новіша версія → (різн.)

Документацію для цього модуля можна створити у Модуль:ClosedNav/документація

local p = {}

--- Список турнірів у порядку
local series_order = {
    "Women's Closed Cup I",
    "Men's Closed Cup I",
    "Combined Closed Cup I",
    "Score Open Battle I",
    "Women's Closed Cup II",
    "Men's Closed Cup II",
    "Combined Closed Cup II",
    "Score Open Battle II",
    "The Elite Series I"
}

--- Знаходить індекс турніру
local function find_series_index(series_name)
    for i, name in ipairs(series_order) do
        if name == series_name then
            return i
        end
    end
    return nil
end

--- Повертає посилання на попередній турнір (циклічно)
function p.prevLink(frame)
    local current_series = frame.args[1] or mw.title.getCurrentTitle().text
    local index = find_series_index(current_series)
    
    if not index then
        return '<span style="color:#666;">←</span>'
    end
    
    -- Циклічна навігація: якщо перший, то йдемо до останнього
    local prev_index = index == 1 and #series_order or index - 1
    local prev_series = series_order[prev_index]
    
    return '[[' .. prev_series .. '|←]]'
end

--- Повертає посилання на наступний турнір (циклічно)
function p.nextLink(frame)
    local current_series = frame.args[1] or mw.title.getCurrentTitle().text
    local index = find_series_index(current_series)
    
    if not index then
        return '<span style="color:#666;">→</span>'
    end
    
    -- Циклічна навігація: якщо останній, то йдемо до першого
    local next_index = index == #series_order and 1 or index + 1
    local next_series = series_order[next_index]
    
    return '[[' .. next_series .. '|→]]'
end

return p