Content deleted Content added
Theopolisme (talk | contribs) ←Created page with '/** * ajaxWatchlist.js * * A watchlist that automatically updates, so you can * spend less time refreshing and more time... er, * doing whatever you do. *...' |
Maintenance: mw:RL/MGU - Removed redundant module |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 7:
*
* @author Theopolisme
* @author He7d3r
*/
( function ( $, mw ) {
"use strict";
var jqxhr, interval, $ajaxWatchlist;
function updateWatchlist () {
var $loadingIndicator = $( '.watchlistLoadingIndicator' ),
$content = $( '#mw-content-text' )
// If this is the first time we run the script, wrap everything
Line 21 ⟶ 24:
if ( $ajaxWatchlist.length === 0 ) {
$content.find( '#mw-watchlist-form' ).nextAll().addBack().wrapAll( '<div id="ajaxWatchlist"></div>' );
$ajaxWatchlist = $( '#ajaxWatchlist' )
.hover( function () {
jqxhr.abort();
clearInterval( interval );
}, function () {
interval = setInterval( updateWatchlist, window.watchlistUpdateFrequency || 20000 );▼
} );
}
Line 42 ⟶ 51:
// Make the ajax request to actually update the watchlist
jqxhr = $.ajax( {
url: ___location.href,
dataType: 'html'
} )
if ( textStatus !== 'abort' ) {
mw.notify( 'ajaxWatchlist: Unable to automatically update watchlist.' ); }
} );
Line 64 ⟶ 75:
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Watchlist' ) {
mw.loader.using( [ 'mediawiki.util', 'jquery.spinner' ], function () {
// Add custom css for the loading indicator
mw.util.addCSS( '.watchlistLoadingIndicator { float: right; font-size: 12px; } ' );
// Run updateWatchlist() every 20 seconds by default (can be configured via window.watchlistUpdateFrequency)
▲ setInterval( updateWatchlist, window.watchlistUpdateFrequency || 20000 );
interval = setInterval( updateWatchlist, window.watchlistUpdateFrequency || 20000 );
} );
}
}( jQuery, mediaWiki ) );
|