+
+ // Use action=setnotificationtimestamp to mark all as visited,
+ // then set all watchlist lines accordingly
+ new mw.Api().postWithToken( 'csrf', {
+ formatversion: 2,
+ action: 'setnotificationtimestamp',
+ entirewatchlist: true
+ } ).done( function () {
+ // Enable button again
+ $button.prop( 'disabled', false );
+ // Hide the button because further clicks can not generate any visual changes
+ $button.css( 'visibility', 'hidden' );
+ $progressBar.css( 'visibility', 'hidden' );
+ $( '.mw-changeslist-line-watched' )
+ .removeClass( 'mw-changeslist-line-watched' )
+ .addClass( 'mw-changeslist-line-not-watched' );
+ } ).fail( function () {
+ // On error, fall back to server-side reset
+ // First remove this submit listener and then re-submit the form
+ $resetForm.off( 'submit' ).submit();
+ } );