Модуль:SeriesNav: відмінності між версіями

нема опису редагування
(Створена сторінка: local p = {} --- Список турнірів у порядку local series_order = { "Women's Closed Cup I", "Men's Closed Cup I", "Combined Closed Cup I" -- Додай інші турніри в правильному порядку } --- Знаходить індекс турніру local function find_series_index(series_name) for i, name in ipairs(series_order) do if name == series_name then return i...)
 
Немає опису редагування
 
(Не показано одну проміжну версію цього користувача)
Рядок 3: Рядок 3:
--- Список турнірів у порядку
--- Список турнірів у порядку
local series_order = {
local series_order = {
     "Women's Closed Cup I",
     "Get Names 01",
     "Men's Closed Cup I",
     "Get Names 02",
     "Combined Closed Cup I"
     "Get Names 03",
     -- Додай інші турніри в правильному порядку
    "Get Names 04",
    "Get Names 05",
    "Get Names 06",
    "Get Names 07",
     "Get Names 08",
    "Get Names 09"
}
}


Рядок 19: Рядок 24:
end
end


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


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


return p
return p