User:The last username left/global.js/vandalwatch.js

/* */ /** * vandalwatch.js * * Provides an easier method of watching for vandalism on a wiki. * REQUIRES: jQuery Framework (www.jquery.com) * * By The last username left * Based on Quarenon's calc.js */

var vwDataId = 'vwTLUL_Data'; var vwInterval;

function vwLoadRCData {	$.ajax({		data: {			action: 'parse',			text: '',			prop: 'text',			title: 'Special:RecentChanges',			format: 'json'		},		dataType: 'json',		type: 'POST',		url: wgScriptPath + '/api.php',		success: function(response) {			$('a').each(function { if ($(this).attr('navpopup') != null) $(this).attr('navpopup').banish; });			var resptext = response.parse.text['*'];			$('#'+vwDataId).empty.html("Recent Changes: " + resptext);			setupTooltips(document.getElementById(vwDataId), true);			setupTooltips(document.getElementById(vwDataId), false);			$('#' + vwDataId + ' a').click(function { if ($(this).attr('href') == '#' || $(this).attr('href') == document.location.href + '#') return true; if ($(this).attr('onClick') != undefined) eval($(this).attr('onClick')); vwLoadPageData($(this).attr('href')); return false; });		},		error: function(xhr, error) {			$('#'+vwDataId).empty.html(' Error: ' + error + ' ');		},		timeout: 10000 // msec	}); }

function vwReloadRCData {	clearInterval(vwInterval); vwInterval = setInterval(vwLoadRCData, 60000); vwLoadRCData; }

function vwLoadPageData(loc) {	clearInterval(vwInterval); $('#'+vwDataId).empty.html(' '); }

$(document).ready(function {	$('.vwConfig').each(function { var lines = $(this).text.split(($(this).text.indexOf('\r') != -1) ? '\r' : '\n'); for (var i in lines) { var temp = lines[i].split('=', 2);

if (temp.length != 2) { continue; }

var vals = temp[1].split('|');

for (var j in vals) { vals[j] = $.trim(vals[j]); }

switch ($.trim(temp[0])) { case 'data': vwDataId = vals[0]; break; }		}		vwReloadRCData; }); }); /* */