Модуль:TournamentNav: відмінності між версіями
Admin (обговорення | внесок) (Створена сторінка: local p = {} local tournament_order = { "Перший сезон", "Другий сезон", "Третій сезон", "Четвертий сезон", "П'ятий сезон", "Шостий сезон", "Сьомий сезон", "Восьмий сезон", "Дев'ятий сезон", "Фінал Року" } local function find_tournament_index(tournament_name) for i, name in ipairs(tournament_order) do...) |
Admin (обговорення | внесок) Немає опису редагування Мітка: Скасовано |
||
| Рядок 1: | Рядок 1: | ||
local p = {} | local p = {} | ||
--- Список турнірів у порядку | |||
local tournament_order = { | local tournament_order = { | ||
"Перший сезон", | "Перший сезон", | ||
| Рядок 14: | Рядок 15: | ||
} | } | ||
--- Знаходить індекс турніру | |||
local function find_tournament_index(tournament_name) | local function find_tournament_index(tournament_name) | ||
for i, name in ipairs(tournament_order) do | for i, name in ipairs(tournament_order) do | ||
| Рядок 23: | Рядок 25: | ||
end | end | ||
--- Повертає посилання на попередній турнір (циклічно) | |||
function p.prevLink(frame) | function p.prevLink(frame) | ||
local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text | local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text | ||
| Рядок 31: | Рядок 34: | ||
end | end | ||
-- Циклічна навігація: якщо перший, то йдемо до останнього | |||
local prev_index = index == 1 and #tournament_order or index - 1 | local prev_index = index == 1 and #tournament_order or index - 1 | ||
local prev_tournament = tournament_order[prev_index] | local prev_tournament = tournament_order[prev_index] | ||
| Рядок 37: | Рядок 41: | ||
end | end | ||
--- Повертає посилання на наступний турнір (циклічно) | |||
function p.nextLink(frame) | function p.nextLink(frame) | ||
local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text | local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text | ||
| Рядок 45: | Рядок 50: | ||
end | end | ||
-- Циклічна навігація: якщо останній, то йдемо до першого | |||
local next_index = index == #tournament_order and 1 or index + 1 | local next_index = index == #tournament_order and 1 or index + 1 | ||
local next_tournament = tournament_order[next_index] | local next_tournament = tournament_order[next_index] | ||
Версія за 15:18, 30 листопада 2025
Документацію для цього модуля можна створити у Модуль:TournamentNav/документація
local p = {}
--- Список турнірів у порядку
local tournament_order = {
"Перший сезон",
"Другий сезон",
"Третій сезон",
"Четвертий сезон",
"П'ятий сезон",
"Шостий сезон",
"Сьомий сезон",
"Восьмий сезон",
"Дев'ятий сезон",
"Фінал Року"
}
--- Знаходить індекс турніру
local function find_tournament_index(tournament_name)
for i, name in ipairs(tournament_order) do
if name == tournament_name then
return i
end
end
return nil
end
--- Повертає посилання на попередній турнір (циклічно)
function p.prevLink(frame)
local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text
local index = find_tournament_index(current_tournament)
if not index then
return '<span style="color:#666;">←</span>'
end
-- Циклічна навігація: якщо перший, то йдемо до останнього
local prev_index = index == 1 and #tournament_order or index - 1
local prev_tournament = tournament_order[prev_index]
return '[[' .. prev_tournament .. '|←]]'
end
--- Повертає посилання на наступний турнір (циклічно)
function p.nextLink(frame)
local current_tournament = frame.args[1] or mw.title.getCurrentTitle().text
local index = find_tournament_index(current_tournament)
if not index then
return '<span style="color:#666;">→</span>'
end
-- Циклічна навігація: якщо останній, то йдемо до першого
local next_index = index == #tournament_order and 1 or index + 1
local next_tournament = tournament_order[next_index]
return '[[' .. next_tournament .. '|→]]'
end
return p