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

768 байтів вилучено ,  У вівторок о 10:10
нема опису редагування
(Створена сторінка: local p = {} local players = { "Демон", "Кексік", "Малена", "Маска", "Нюта", "Сімон", "Артерія", "Бетмен", "Сенаторс", "Ноунейм", "Легасі", "Гробік", "Кіфа", "Панда", "Берлін", "Леві", "Х'юґо", "Рендал", "Малюк", "Браун", "Маджест", "Пірожуля", "Лев", "Рауль", "Механік", "Фейт", "Ліна", "Мір...)
 
Немає опису редагування
 
(Не показані 4 проміжні версії цього користувача)
Рядок 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)
Рядок 68: Рядок 63:
     end
     end
      
      
     local prevPlayer = index > 1 and players[index - 1] or nil
     local nextIndex
     local nextPlayer = index < #players and players[index + 1] or nil
     if index == #players then
   
         nextIndex = 1
    local prevLink = ""
    local nextLink = ""
   
    if prevPlayer then
         prevLink = string.format('<span class="player-nav-prev">[[%s|←]]</span>', prevPlayer)
    else
        prevLink = '<span class="player-nav-prev" style="visibility:hidden;">←</span>'
    end
   
    if nextPlayer then
        nextLink = string.format('<span class="player-nav-next">[[%s|→]]</span>', nextPlayer)
     else
     else
         nextLink = '<span class="player-nav-next" style="visibility:hidden;">→</span>'
         nextIndex = index + 1
     end
     end
      
      
     return string.format(
     return '[[' .. players[nextIndex] .. '|→]]'
        '<div class="player-nav">%s<span class="player-nav-name">%s</span>%s</div>',
        prevLink, name, nextLink
    )
end
end


return p
return p