MediaWiki:Common.js/ajaxrefresh.js

/* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code courtesy of "pcj" of Wowpedia. * Modified by Monchoman45 */ if (!window.ajaxPages) {ajaxPages = ['Special:RecentChanges', 'Special:Watchlist', 'Special:WikiActivity', 'Jar_Locations'];} if (!window.ajaxCallAgain) {ajaxCallAgain = [];} var ajaxTimer; var doRefresh = true; function preloadAJAXRL { ajaxRLCookie = (readCookie('ajaxload-' + wgPageName) == 'on') ? true : false; appTo = ($('#WikiaPageHeader').length) ? $('#WikiaPageHeader') : $('.firstHeading'); appTo.append(' AJAX: Refresh now    '); $('#ajaxLoadProgress').ajaxSend(function (event, xhr, settings){		if (location.href == settings.url) {$(this).show;}	}).ajaxComplete (function (event, xhr, settings){		if (location.href == settings.url) {$(this).hide;}		for(i in ajaxCallAgain) {ajaxCallAgain[i];}	}); $('#ajaxToggle').click(toggleAjaxReload); $('#ajaxToggle').attr('checked', ajaxRLCookie); if (readCookie('ajaxload-' + wgPageName) == 'on') {loadPageData;} } function toggleAjaxReload { if ($('#ajaxToggle').attr('checked') == true) { createCookie('ajaxload-' + wgPageName, 'on', 30); doRefresh = true; loadPageData; }	else { createCookie('ajaxload-' + wgPageName, 'off', 30); doRefresh = false; clearTimeout(ajaxTimer); } } function loadPageData { cC = ($('#WikiaArticle').length) ? '#WikiaArticle' : '#bodyContent'; $(cC).load(location.href + ' ' + cC + ' > *', function (data) { 		if (doRefresh) {ajaxTimer = setTimeout('loadPageData;', 60000);}	}); } addOnloadHook(function { 	for (i in ajaxPages) {		if (wgPageName == ajaxPages[i] && $('#ajaxToggle').length == 0) {preloadAJAXRL;}	} });