FANDOM


local p = {};
 
-- Update these on Sunday
local upcoming = "38";
local latest = "37";
local secondLatest = "36";
local first = "1";
local second = "2";
 
local specialLatest = "4";
 
function p.getLink(frame)
    local ep = tonumber(frame:getParent().args['episode']);
    local theme = frame:getParent().args['theme'];
    local link = p.getLinkRaw(ep, theme);
    return link;
end
 
function p.getLatestLink()
    local ep = tonumber(latest) + 4
    return "http://webtoons.com/viewer?titleNo=1022&episodeNo=" .. ep
end
 
function p.getLinkRaw(ep, theme)
    local link = "http://webtoons.com/viewer?titleNo=1022&episodeNo="
    local epNum = 0
    local epName = ""
 
    if(theme == "" or theme == nil) then
        if(ep <= 14) then
            epNum = ep
        elseif(ep < 19) then
            epNum = ep + 1
        elseif(ep < 28) then
            epNum = ep + 2
        elseif(ep < 37) then
            epNum = ep + 3
        elseif(ep >= 37) then
            epNum = ep + 4
        end
 
        epName = "Episode " .. ep
    else
        if(ep == 1) then
            epNum = 20
            epName = "Halloween Episode"
        elseif(ep == 2) then
            epNum = 30
            epName = "Lumine Bonus"
        elseif(ep == 3) then
            epNum = 40
            epName = "Lumine Shorts"
        end
    end
 
    return "[" .. link .. epNum .. " " .. epName .. "]"
 
end
 
 
function p.firstLabel(frame)
    local ep = frame:getParent().args['episode']
    local theme = frame:getParent().args['theme']
 
    if(ep == first and (theme == "" or theme == nil)) then
        return ""
    elseif(ep == second and (theme == "" or theme == nil)) then
        return ""
    else
        return "⇐ First"
    end
 
end
 
function p.firstValue(frame)
    local ep = frame:getParent().args['episode']
    local theme = frame:getParent().args['theme']
 
    if(ep == first and (theme == "" or theme == nil)) then
        return ""
    elseif(ep == second and (theme == "" or theme == nil)) then
        return ""
    else
        return "[[Episode 1]]"
    end
 
end
 
function p.latestLabel(frame)
    local ep = frame:getParent().args['episode']
    local theme = frame:getParent().args['theme']
 
    if(theme == "" or theme == nil) then
        if(ep == latest or ep == secondLatest) then
            return ""
        else
            return "Latest ⇒"
        end
    elseif(ep == specialLatest) then
            return ""
    else
        return "Latest ⇒"
    end
 
end
 
function p.latestValue(frame)
    local ep = frame:getParent().args['episode']
    local theme = frame:getParent().args['theme']
 
    if(theme == "" or theme == nil) then
        if(ep == latest or ep == secondLatest) then
            return ""
        else
            return p.getLatestPage()
        end
    elseif(ep == specialLatest) then
            return ""
    else
        return p.getLatestPage()
    end
end
 
function p.getLatestPage()
    return "[[Episode " .. latest .. "]]";
end
 
function p.nextLabel(frame)
    return "Next →"
end
 
function p.nextValue(frame)
    local ep = frame:getParent().args['episode']
    local epn = tonumber(ep)
    return "[[Episode " .. epn+1 .. "]]"
end
 
function p.previousLabel(frame)
    if(ep == first and (theme == "" or theme == nil)) then
        return ""
    else
        return "← Previous"
    end
end
 
function p.previousValue(frame)
    if(ep == first and (theme == "" or theme == nil)) then
        return ""
    end
 
    local ep = tonumber(frame:getParent().args['episode']);
    return "[[Episode " .. ep-1 .. "]]"
end
 
return p