User:Cblair91/categories.js

/* Scabbed from Joeytje50

var cg; if (typeof cgwatch1 != 'undefined' && typeof cg != 'object') cg = [cgwatch1]; var isChat = wgCanonicalSpecialPageName=="Chat" && skin=="oasis"?true:false; var ts = , ttl = ; for (i=0;cg[i];i++) { var cgamount = i+1 if (i>0) { ts += ',' ttl += ',' } } ts = ts.split(','); ttl = ttl.split(','); function callCGAPI(cat, i) { if (cg[i]) { $.ajax({		url: wgServer + '/api.php',		data:{			'action':'query',			'list':'categorymembers',			'cmtitle':'Category:'+cat,			'cmprop':'ids|title|timestamp',			'cmlimit':'1',			'smsort':'timestamp',			'cmdir':'desc',			'format':'json'		},		success: function(response) {                   if(response.query.categorymembers[0].timestamp != undefined) { 			ts[i] = response.query.categorymembers[0].timestamp;			ttl[i] = response.query.categorymembers[0].title;			var n = 0;			for (i=0;cg[i];i++) {				var n = n+(cg[i]?1:0);			}			if (n==cgamount) finished                    }		}	}); } } function finished { var n = 0; for (i=0;ts[i];i++) { if (ts[i].localeCompare(ts[n])>=0) { n = i;		} }	$('#CategoryNotify>span').html('Latest edit to ' + cg[n] + ' was to ' + ttl[n]+ ''); } function callAllAPIs { for (i=0;cg[i];i++) { callCGAPI(cg[i], i); } } $(document).ready(function{ if (isChat) {	$('#ChatHeader h1.public.wordmark').prepend('  ');	$('.chattopic').css('left','250px')	$('.chattopic').css('text-align','left') } else if (skin == "oasis") {	$('head').append('#GlobalNavigation {display:none !important;} .WikiaLogo+li+li {padding:0 5px;} #CategoryNotify a {color:#FFF !important;} ');	$('#WikiaHeader nav ul').append('  '); } else if (skin == "monobook") {	$('#p-cactions .pBody').append('   '); } callAllAPIs; }) setInterval('callAllAPIs', 30000)