User:Rswfan/vandalwatch.js

/* */ /** * vandalwatch.js * * Provides an easier method of watching for vandalism on the 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) {			var resptext = response.parse.text['*'];			$('#'+vwDataId).empty.html("Recent changes: " + resptext);			setupTooltips(document.getElementById(vwDataId), true);			setupTooltips(document.getElementById(vwDataId), false);			$('a').each(function { $(this).attr('onlick', '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; }); }); /* */