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

730 байтів вилучено ,  У вівторок о 10:10
нема опису редагування
Немає опису редагування
Немає опису редагування
 
(Не показані 3 проміжні версії цього користувача)
Рядок 12: Рядок 12:
     "Повар", "Кузя", "Ніколетта", "Космос", "Дантес", "Комедіант", "Справа",
     "Повар", "Кузя", "Ніколетта", "Космос", "Дантес", "Комедіант", "Справа",
     "Хуаніта", "Фенікс", "Керміт", "Іуда", "Меля", "Міна", "Ротація", "Доктор Хаус",
     "Хуаніта", "Фенікс", "Керміт", "Іуда", "Меля", "Міна", "Ротація", "Доктор Хаус",
     "Індиго", "Расм", "Безкiнечнiсть", "Ната", "Клей", "Фінлі", "Аристократ",
     "Індиго", "Расм", "Безкінечність", "Ната", "Клей", "Фінлі", "Аристократ",
     "Муза", "Медді", "Клайд", "Бейбі", "Патрон", "Кінік", "Бейтман", "Гросмейстер",
     "Муза", "Медді", "Клайд", "Бейбі", "Патрон", "Кінік", "Бейтман", "Гросмейстер",
     "Васильович", "Тіна", "Дежаву", "Мальвінка", "Ачоровал", "Протон", "Аріель",
     "Васильович", "Тіна", "Дежаву", "Мальвінка", "Ачоровал", "Протон", "Аріель",
Рядок 20: Рядок 20:
     "Шостік", "Філоріан", "Назавжди", "Вотер", "Каратель", "Жовтень", "Нелл",
     "Шостік", "Філоріан", "Назавжди", "Вотер", "Каратель", "Жовтень", "Нелл",
     "Тайєр", "Еморі", "Лілія", "Дюймовочка", "Седвік", "Скромний", "Кобальт",
     "Тайєр", "Еморі", "Лілія", "Дюймовочка", "Седвік", "Скромний", "Кобальт",
     "Радист", "Привіт, киця", "Марвел", "Македонський", "Пікассо", "Борщ", "Гроза",
     "Радист", "Привіт, киця", "Марвел", "Македонський", "Пікассо", "Борщ",
    "Бембі", "Вишня", "Меріманго", "Флекс", "Стеля", "Посейдон", "Оксі", "Зірка",
    "Спейс Кадет", "Шредер", "Аміра", "Гроза", "Бембі", "Вишня", "Меріманго",
    "Блінк", "Фолд", "Зодіак", "Андервуд", "Абракадабра", "Жасмін", "Кіноманка",
    "Флекс", "Стеля", "Посейдон", "Оксі", "Зірка", "Блінк", "Фолд", "Бандера",
     "Бонд", "Фея", "Сутінки", "Ананасік", "Боб", "Лектоp", "Динамо", "Магуз",
    "Зодіак", "Андервуд", "Сід", "Хрещена", "Абракадабра", "Жасмін", "Кіноманка",
    "Палац Україна"
     "Бонд", "Фея", "Сутінки", "Ананасік", "Апріорі", "Продажник", "Флейм", "Боб",
    "Лектоp", "Динамо", "Магуз", "Палац Україна"
}
}


-- Знайти індекс гравця
local function findIndex(name)
local function findIndex(name)
     for i, player in ipairs(players) do
     for i, player in ipairs(players) do
Рядок 37: Рядок 37:
end
end


-- Отримати попереднього гравця
function p.prevLink(frame)
function p.prev(frame)
     local name = frame.args[1] or frame.args.player or mw.title.getCurrentTitle().text
     local name = frame.args[1] or frame.args.player or mw.title.getCurrentTitle().text
     local index = findIndex(name)
     local index = findIndex(name)
      
      
     if index and index > 1 then
     if not index then
         return players[index - 1]
         return ""
     end
     end
    return ""
end
-- Отримати наступного гравця
function p.next(frame)
    local name = frame.args[1] or frame.args.player or mw.title.getCurrentTitle().text
    local index = findIndex(name)
      
      
     if index and index < #players then
    local prevIndex
         return players[index + 1]
     if index == 1 then
        prevIndex = #players
    else
         prevIndex = index - 1
     end
     end
     return ""
   
     return '[[' .. players[prevIndex] .. '|←]]'
end
end


-- Повна навігація (HTML) - ОНОВЛЕНА ФУНКЦІЯ
function p.nextLink(frame)
function p.navigation(frame)
     local name = frame.args[1] or frame.args.player or mw.title.getCurrentTitle().text
     local name = frame.args[1] or frame.args.player or mw.title.getCurrentTitle().text
     local index = findIndex(name)
     local index = findIndex(name)
      
      
    local prevLink = ""
     if not index then
    local nextLink = ""
         return ""
   
     if index and index > 1 then
         local prevPlayer = players[index - 1]
        local prevUrl = mw.uri.encode(prevPlayer, "WIKI")
        prevLink = string.format('<a href="/index.php/%s" title="%s">←</a>', prevUrl, prevPlayer)
     end
     end
      
      
     if index and index < #players then
    local nextIndex
         local nextPlayer = players[index + 1]
     if index == #players then
        local nextUrl = mw.uri.encode(nextPlayer, "WIKI")
         nextIndex = 1
         nextLink = string.format('<a href="/index.php/%s" title="%s">→</a>', nextUrl, nextPlayer)
    else
         nextIndex = index + 1
     end
     end
      
      
     return string.format(
     return '[[' .. players[nextIndex] .. '|→]]'
        '<div class="player-nav"><span class="player-nav-prev">%s</span><span class="player-nav-name">%s</span><span class="player-nav-next">%s</span></div>',
        prevLink, name, nextLink
    )
end
end


return p
return p