User:Leviathan 89/common.js

//======================= //  AbuseFilter in RC //======================= // http://runescape.wikia.com/wiki/User%3ASuppa_chuppa/abuselog.js $(function {	var refreshTimer = null;	var itemSince = null;	var itemIds = [];	var loadingHtml = '';	function articleURL(article) {		return wgArticlePath.replace('$1', encodeURI(article.replace(/ /g, '_')));	}	function scriptURL(article) {		return wgScript + '?title=' + encodeURIComponent(article.replace(/ /g, '_'));	}	function callAPI(data, method, callback) {		data['format'] = 'json';		$.ajax({ data: data, dataType: 'json', url: wgScriptPath + '/api.php', type: method, success: function(response) { if (response.error) { //alert('API error: ' + response.error.info); } else { callback(response); }			},			//error: function(xhr, error) { alert('AJAX error: ' + error); }, timeout: 10000 });	}	function reloadComplete {		if ($('#abAutoRefresh:checked').length) {			window.clearTimeout(refreshTimer);			refreshTimer = window.setTimeout(reloadData, 10 *1000);		}		$('#ab_update img').hide;		$('#abLastUpdate').text((new Date).toUTCString);	}	function reloadData {		$('#ab_update img').show;		var itemQuery = {			'afllimit': '1',			'action': 'query',			'list': 'abuselog'		};		if (itemSince) {			itemQuery['itemend'] = itemSince;		}		callAPI(itemQuery, 'GET', function(response) { var revs = []; var curDate = ''; for (var i in response.query.abuselog) { var item = response.query.abuselog[i]; // Remove duplicates which may occur during autorefresh if ($.inArray(item.id, itemIds) > -1) { continue; }                               if(itemIds.length != 0) $('#abHeader').nextAll.remove; itemIds.push(item.id); var date = item.timestamp.substring(0, 10); var time = item.timestamp.substring(11, 19); itemSince = item.timestamp; $('#abHeader').after( '' +	' ' + date + ' ' + time + ' ' +	' ' +		'' + item.title + ' (diff)' +	' ' + '' + '' + item.user + '' + ' ' + ' ' +	'Triggered abuse filter: ' + item.filter_id + ' ' +       ' &raquo; ' +		'talk &bull; ' +		'contribs</a> &bull; ' + 'abuse log</a> &bull; ' + 'block</a> ' + ' '				);			}			if (revs.length == 0) {				reloadComplete;				return;			}		}); }	if ((wgPageName == 'Special:RecentChanges') && (wgAction == 'view' || wgAction == 'purge')) { $('#ab_options').empty.append( ' ' +	' ' +		' Abuse Log Watch options ' +		'<input type="checkbox" id="abAutoRefresh" checked="checked" /> <label for="abAutoRefresh">Auto-refresh table  ' +                '<input type="checkbox" id="abRefresh" checked="unchecked" /> <label for="abRefresh">Click here if table gets stuck ' +	' ' + ' '		); $('#ab_update').html('Last update: ' + loadingHtml); var $table = $(' ').addClass('wikitable').attr('id', 'ewData').css('width', '100%'); $table.append( '<tr id="abHeader">' +	' Time ' +	' Title ' +	' User ' + ' '		); $('#ab_main').empty.append($table); $('#abRefresh').click(function {			$('#abHeader').nextAll.remove;			itemIds = [];			itemSince = null;			reloadData;		}); reloadData; } });

// Adding table to RC if ( wgCanonicalSpecialPageName === 'Recentchanges' ) { $( '#mw-content-text' ).before('<div id="ab_msg"> <div id="ab_options"> <div id="ab_update"> <div id="ab_main"> '); }