FANDOM


local p = {}
 
function p.YearNav(frame)
    Pattern = frame.args[1] or -1
 
    if Pattern==-1 then
        Pattern = "####-10 ・・ ####-1 ・ '''####''' ・ ####+1 ・・ ####+10" --Default. Will be overwritten if something was there.
        for i,v in pairs(frame.args) do
            Pattern= i .. "=" .. v
        end
    end
 
    ThisPageTitle = mw.title.getCurrentTitle()
    Prefix = ThisPageTitle.nsText
    Namespace = ThisPageTitle.namespace
    PageName = ThisPageTitle.text
    --Prefix = "Category"
    --Namespace = 0
    --PageName = "1987 Sandwiches"
 
    _, _, OriginalYear = string.find(PageName, "(%d%d%d%d)")
    PageWithout = string.gsub(PageName, OriginalYear, "@@@@")
 
    CurrentText = Pattern
 
    itsthere, _, _, _ = string.find(CurrentText, "####([%+%-])(%d+)")
 
    while itsthere do --Continue while there are still instances in the pattern to alter
        _, _, plusminus, amount = string.find(CurrentText, "####([%+%-])(%d+)")
        if plusminus=="-" then
            NewYear = OriginalYear - amount
        else --assume it's plus
            NewYear = OriginalYear + amount
        end
        NewPageName = string.gsub(PageWithout, "@@@@", NewYear)
        if Namespace==0 then
            ReplacementSection = "[[" .. NewPageName .. "]]"
        else
            ReplacementSection = "[[:" .. Prefix .. ":" .. NewPageName .. "|" .. NewPageName .. "]]"
        end
        CurrentText = string.gsub(CurrentText, "####[%+%-]%d+", ReplacementSection, 1)
        itsthere, _, _, _ = string.find(CurrentText, "####([%+%-])(%d+)")
    end
 
    CurrentText = string.gsub(CurrentText, "####", PageName)
 
    return CurrentText
 
end
 
function p.JustTheYear(frame)
    ThisPageTitle = mw.title.getCurrentTitle()
    PageName = ThisPageTitle.text
 
    _, _, OriginalYear = string.find(PageName, "(%d%d%d%d)")
 
    return OriginalYear
end
 
return p

您使用了广告屏蔽软件!


Wikia通过广告运营为用户提供免费的服务。我们对用户通过嵌入广告屏蔽软件访问网站进行了使用调整。

如果您使用了广告屏蔽软件,将无法使用我们的服务。请您移除广告屏蔽软件,以确保页面正常加载。

查看其他FANDOM

随机维基