if (mw.config.get('wgNamespaceNumber') == 10) { // Only if we're in Template: space
// Grab main page tab
var sandtabMainTab = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9');
// Clone main page tab
var sandtabTab = sandtabMainTab.clone(true).attr('id', sandtabMainTab.attr('id')+'-').css('opacity','0.9').removeClass('new');
// Construct URL
var sandtabURL = 'http://' + wgPageContentLanguage + '.' + wgNoticeProject + '.org/w/index.php?title=' + wgPageName + '/sandbox';
// Set sandbox tab URL, text, and title
sandtabTab.find('a').attr('href', sandtabURL).empty().text('Sandbox').attr('title', "Navigate to this page's sandbox");
// Get sandbox existence status via Ajax
$.ajax({
url:"http://en.wikipedia.org/w/api.php?action=query&titles=" + encodeURIComponent(wgPageName + '/sandbox') + "&format=xml",
dataType: "xml",
type: "GET",
success:parseIt
});
sandtabTab.insertBefore($('#right-navigation li').slice(0,1));
}
// Ajax function on data return: If 'missing' field is defined, page is missing, so add 'new' class to tab, which turns it red
function parseIt (xml){
var missing = $(xml).find('page').attr('missing');
if (typeof missing != "undefined") sandtabTab.addClass('new');
}