User:Mike Dillon/Scripts/namespaces.js

var wgNsMedia = -2; var wgNsSpecial = -1; var wgNsMain = 0; var wgNsTalk = 1; var wgNsUser = 2; var wgNsUserTalk = 3; var wgNsProject = 4; var wgNsProjectTalk = 5; var wgNsImage = 6; var wgNsImageTalk = 7; var wgNsMediawiki = 8; var wgNsMediawikiTalk = 9; var wgNsTemplate = 10; var wgNsTemplateTalk = 11; var wgNsHelp = 12; var wgNsHelpTalk = 13; var wgNsCategory = 14; var wgNsCategoryTalk = 15;

var wgNamespaceNames = { // Standard namespaces '-2': 'Media', '-1': 'Special', '0': 'Main', '1': 'Talk', '2': 'User', '3': 'User talk', '4': 'Wikipedia', '5': 'Wikipedia talk', '6': 'Image', '7': 'Image talk', '8': 'Mediawiki', '9': 'Mediawiki talk', '10': 'Template', '11': 'Template talk', '12': 'Help', '13': 'Help talk', '14': 'Category', '15': 'Category talk',

// Custom namespaces '100': 'Appendix', '101': 'Appendix talk', '102': 'Concordance', '103': 'Concordance talk', '104': 'Index', '105': 'Index talk', '106': 'Rhymes', '107': 'Rhymes talk', '108': 'Transwiki', '109': 'Transwiki talk', '110': 'Wikisaurus', '111': 'Wikisaurus talk', '112': 'WT', '113': 'WT talk', '114': 'Citations', '115': 'Citations talk', };

function getNamespaceNumber(title) { if (title && title.match) { for (var num in wgNamespaceNames) { if (num == wgNsMain) continue;

if (title.replace("_", " ").match(wgNamespaceNames[num] + ":")) { return num; }       }    }

return wgNsMain; }

function getNamespaceName(title) { return wgNamespaceNames[getNamespaceNumber(title)]; }