User:Mike Dillon/Scripts/namespaces.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
// <pre><nowiki> 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': 'Portal', '101': 'Portal 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)]; } // </nowiki></pre>