Module:Category series navigation/navyear/sandbox

local p = {}

local greyLinkColor = "#888"

-- Make a piped link to a category, if it exists -- If it doesn't exist, just display the greyed the link title without linking function makeCatLink(catname, disp) local displaytext if (disp ~= "") and (disp ~= nil) then -- use 'disp' parameter, but strip any trailing disambiguator displaytext = mw.ustring.gsub(disp, "%s+%(.+$", "");	else		displaytext = catname	end if 1 == 1 then	return catname end -- testing	local fmtlink	local catPage = mw.title.new( catname, "Category" )	if (catPage.exists) then		fmtlink = "" .. displaytext .. ""	else		fmtlink = ' ' .. displaytext .. " "	end

return fmtlink end

function p.navyear(frame) --Expects a PAGENAME of the form "Some sequential 1760 example cat", where --	=Some sequential --	=1760	--	=example cat --	=1758 ('min' year parameter; optional) --	=1800 ('max' year parameter; optional) local arg1 = frame.args[1] local arg2 = tonumber(frame.args[2]) local arg3 = frame.args[3] local arg4 = tonumber(frame.args[4]) local arg5 = tonumber(frame.args[5]) if arg4 == nil then arg4 = -9999 end if arg5 == nil then arg5 = 9999 end local navyear = '{| class="toccolours hlist" style="text-align: center; margin: auto;"\n'..'|\n' local i = -5 while i <= 5 do		local year = arg2 + i		if i ~= 0 then if (year >= arg4) and (year <= arg5) then -- ex: 1758, 1759, 1761, 1762, 1763, 1764, 1765 navyear = navyear..'*'..makeCatLink( arg1..' '..year..' '..arg3, year )..'\n' else -- ex: 1755, 1756, 1757 navyear = navyear..'* '..year..' \n' end else -- ex: 1760 navyear = navyear..'*'..arg2..'\n' end i = i + 1 end return navyear..'|}' end

return p