User:Pintor Kagamine/global.js

var ajaxPages = ["Special:WikiActivity", "Special:Log", "Special:RecentChanges", "Especial:WikiActivity", "Especial:Registro", "Especial:CambiosRecientes"]; var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true;

importArticles({	type: 'script',	articles: [		'u:dev:AjaxRC/code.js',		'u:dev:NoImageLightbox/code.js',		'u:dev:PortableCSSPad/code.js',       'u:dev:QuickCreateUserPage/code.js',		'u:dev:ReferencePopups/code.js',		'u:dev:QuickTools/advanced.js'	] });

$('.activity-items').ready(function {	var items = 20;	var i18n = {		en: {			'before': '',			'second': '1 second ago',			'seconds': ' seconds ago',			'minute': '1 minute ago',			'minutes': ' minutes ago',			'hour': '1 hour ago',			'hours': ' hours ago',			'day': '1 day ago',			'days': ' days ago',			'month': '1 month ago',			'months': ' months ago',			'year': '1 year ago',			'years': ' years ago'		},		es: {			'before': 'hace ',			'second': 'hace 1 segundo',			'seconds': ' segundos',			'minute': 'hace 1 minuto',			'minutes': ' minutos',			'hour': 'hace 1 hora',			'hours': ' horas',			'day': 'hace 1 día',			'days': ' días',			'month': 'hace 1 mes',			'months': ' meses',			'year': 'hace 1 año',			'years': ' años'		}	}	function timeDifference(previous) {		var current = new Date;		current = current.getTime;		var msPerMinute = 60 * 1000;		var msPerHour = msPerMinute * 60;		var msPerDay = msPerHour * 24; var msPerMonth = msPerDay * 30; var msPerYear = msPerDay * 365; var elapsed = current - previous; if (elapsed < msPerMinute) { return Math.round(elapsed / 1000) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / 1000) +  + i18n[wgUserLanguage]['before'] : i18n[wgUserLanguage]['second']; } 		else if (elapsed < msPerHour) { return Math.round(elapsed / msPerMinute) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / msPerMinute) +  + i18n[wgUserLanguage]['minutes'] : i18n[wgUserLanguage]['minute']; } 		else if (elapsed < msPerDay) { return Math.round(elapsed / msPerHour) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / msPerHour) +  + i18n[wgUserLanguage]['hours'] : i18n[wgUserLanguage]['hour']; } 		else if (elapsed < msPerMonth) { return Math.round(elapsed / msPerDay) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / msPerDay) +  + i18n[wgUserLanguage]['days'] : i18n[wgUserLanguage]['day']; } 		else if (elapsed < msPerYear) { return Math.round(elapsed / msPerMonth) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / msPerMonth) +  + i18n[wgUserLanguage]['months'] : i18n[wgUserLanguage]['month']; } 		else { return Math.round(elapsed / msPerYear) > 1 ? i18n[wgUserLanguage]['before'] +  + Math.round(elapsed / msPerYear) +  + i18n[wgUserLanguage]['years'] : i18n[wgUserLanguage]['year']; }	}	function updateRC { $.getJSON(mw.config.get('wgServer') + '/api.php?action=query&list=recentchanges&rclimit=' + items + '&rctype=edit&rcprop=user|timestamp|title|ids&format=json', function (data) {			var rc = data.query.recentchanges;			$('.activity-items li').each(function (i) { var timestamp = new Date(rc[i].timestamp); timestamp = timestamp.getTime; $(this).html(' ' + rc[i].title + ' ' + rc[i].user + ' • ' + timeDifference(timestamp) + ' '); });		});	}	var li = ''; for (var i = 0; i < items; i++) { li += ''; }	$('.activity-items').append(li) updateRC; $('.activity-items').css('height', 215).css('overflow-y', 'scroll'); })