User:Reguyla/WikipediaTab.js

// Define "WikipediatabMainTab" variable before cloning it. var WikipediatabMainTab = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9'); // Clone main page tab var WikipediatabTab = WikipediatabMainTab.clone(true).attr('id', simpletabMainTab.attr('id')+'-').css('opacity','0.9').removeClass('new'); // Construct URL for English Wikipedia var WikipediatabURL = 'http://' + 'en.wikipedia.org/wiki/' + wgPageName;

// Set English Wikipedia tab URL, text, and title WikipediatabTab.find('a').attr('href', WikipediattabURL).empty.text('Wikipediat').attr('title', "Navigate to this page on English Wikipedia"); // Get sandbox existence status via Ajax $.ajax({  url:"http://en.wikipedia.org/w/api.php?action=query&titles=" + encodeURIComponent(wgPageName) + "&format=xml",    dataType: "xml",    type: "GET",   success:parseIt }); // 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") WikipediattabTab.addClass('new'); } sWikipediattabTab.insertBefore($('#right-navigation li').slice(0,1)); // ** Making tab red still doesn't work for some reason, haven't figured that out yet, // ** but the ajax url is correct as you can see if you navigate to it manually: // ** http://en.wikipedia.org/w/api.php?action=query&titles=monkey&format=xml