User:Leviathan 89/wikia.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 + '' + ' ' + ' ' +	'Filtro attivato: ' + item.filter_id + ' ' +       ' &raquo; ' +		'discussione &bull; ' +		'contributi</a> &bull; ' + 'abuse log</a> &bull; ' + 'blocca</a> ' + ' '				);			}			if (revs.length == 0) {				reloadComplete;				return;			}		}); }	if ((wgPageName == 'Utente:Leviathan_89/Sandbox' || wgPageName == 'Speciale:UltimeModifiche') && (wgAction == 'view' || wgAction == 'purge')) { $('#ab_options').empty.append( ' ' +	' ' +		' Opzioni Abuse Log Watch ' +		'<input type="checkbox" id="abAutoRefresh" checked="checked" /> <label for="abAutoRefresh">Aggiornamento automatico tabella  ' +                '<input type="checkbox" id="abRefresh" checked="unchecked" /> <label for="abRefresh">Clicca qui se la tabella si blocca ' +	' ' + ' '		); $('#ab_update').html('Ultimo aggiornamento: ' + loadingHtml); var $table = $(' ').addClass('wikitable').attr('id', 'ewData').css('width', '100%'); $table.append( '<tr id="abHeader">' +	' Ora ' +	' Titolo ' +	' Utente ' + ' '		); $('#ab_main').empty.append($table); $('#abRefresh').click(function {			$('#abHeader').nextAll.remove;			itemIds = [];			itemSince = null;			reloadData;		}); reloadData; } });

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