Module:Category series navigation/sandbox explained

require('strict')local p = local horizontal = require('Module:List').horizontal

----Globals --

local currtitle = mw.title.getCurrentTitlelocal nexistingcats = 0local errors = local testcasecolon = local testcases = string.match(currtitle.subpageText, '^testcases')if testcases then testcasecolon = ':' endlocal navborder = truelocal followRs = truelocal skipgaps = falselocal skipgaps_limit = 50local term_limit = 10local hgap_limit = 6local ygap_limit = 5local listall = falselocal tlistall = local tlistallbwd = local tlistallfwd = local ttrackingcats = local avoidself = (not string.match(currtitle.text, 'Category series navigation with') and not string.match(currtitle.text, 'Category series navigation.*/doc') and not string.match(currtitle.text, 'Category series navigation.*/sandbox') and currtitle.text ~= 'Category series navigation' and currtitle.nsText:gsub('_', ' ') ~= 'User talk' and -- currtitle.nsText:gsub('_', ' ') ~= 'Template talk' and (currtitle.nsText ~= 'Template' or testcases)) --avoid nested transclusion errors (i.e.)

----Utility & category functions --

--Determine if a category exists (in a function for easier localization).local function catexists(title) return mw.title.new(title, 'Category').existsend

--Error message handling.function p.errorclass(msg) return mw.text.tag('span',, 'Error! '..string.gsub(msg, '&#', '&#'))end

--Failure handling.function p.failedcat(errors, sortkey) if avoidself then return (errors or )..'***Category series navigation failed to generate navbox***'.. ''..(sortkey or 'O')..'\n' end return end

--Tracking cat handling.-- key: 15 (when reindexing ttrackingcats, Ctrl+H 'trackcat(13,' & 'ttrackingcats[16]')-- cat: 'Category series navigation isolated'; to remove--Used by main, all nav_*, & several utility functions.local function trackcat(key, cat) if avoidself and key and cat then if cat ~= then ttrackingcats[key] = '' else ttrackingcats[key] = end end returnend

--Check for unknown parameters.--Used by main only.local function checkforunknownparams(tbl) local knownparams = for k, _ in pairs (tbl) do if knownparams[k]

nil then trackcat(3, 'Category series navigation using unknown parameter') break end endend

--Check for nav_* navigational isolation (not necessarily an error).--Used by all nav_*.local function isolatedcat if nexistingcats

0 then trackcat(16, 'Category series navigation isolated') endend

--Returns the target of, if it exists, else returns the original cat.--, etc., if found, are evaluated.--Used by catlinkfollowr, and so indirectly by all nav_*.local function rtarget(frame, cat) local catcontent = mw.title.new(cat or , 'Category'):getContent if string.match(catcontent or , '